the-sett / salix / L2

Defines the level 2 language for data models that have been checked for consitency, and have been processed for general data modelling concerns without regard to specific code generators.

The L2 data modelling language.


type alias L2 pos =
Dict String (L1.Declarable pos RefChecked)

L2 is a dictionary of named data model components, which has also been reference checked to ensure that all references in the model have named entries in the dictionary.

Ref checking status - L2 is checked.


type RefChecked
    = RcEnum
    | RcRestricted L1.Basic
    | RcSum
    | RcTUnit
    | RcTBasic L1.Basic
    | RcTNamed
    | RcTProduct
    | RcTEmptyProduct
    | RcTContainer
    | RcTFunction

Indicates that named types in the model have been reference checked to enusure that they name something that actually exists in the L2 dictionary.

Some summary information of what they refer to is also cached during ref checking. This can be very convenient during code generation to avoid having to look up in the dictionary all the time, to find out what kind of thing a named type is.

Standardized interface to an L2 processor.


type alias Processor pos =
{ name : String
, check : L1 pos -> ResultME Errors.Error (L2 pos) 
}

API for an L2 model processor.


type alias ProcessorImpl pos err =
{ name : String
, check : L1 pos -> ResultME err (L2 pos)
, buildError : Errors.ErrorBuilder pos err 
}

SPI for an L2 model processor. Use the builder to turn one of these into a Processor.

builder : (pos -> SourcePos.SourceLines) -> ProcessorImpl pos err -> Processor pos

Builds an L2 Processor API from an implementation. A function to turn source code positions into quoted lines of source code needs to be supplied.

Meta information on the model.

refCheckedConsName : RefChecked -> String

Yields the constructor name for a RefChecked.