the-sett / salix / L1

Defines the level 1 language for data modelling.

The L1 data modelling AST.


type Basic
    = BBool
    | BInt
    | BReal
    | BString

The basic data types.


type Container pos ref
    = CList (Type pos ref)
    | CSet (Type pos ref)
    | CDict (Type pos ref) (Type pos ref)
    | COptional (Type pos ref)

Containers for 0..n instances of some type.


type alias Field pos ref =
( String
, Type pos ref
, Properties 
)

Re-usable field definition.


type Type pos ref
    = TUnit pos
    | TBasic pos Basic
    | TNamed pos String ref
    | TProduct pos (List.Nonempty.Nonempty (Field pos ref))
    | TEmptyProduct pos
    | TContainer pos (Container pos ref)
    | TFunction pos (Type pos ref) (Type pos ref)

The possible type constructs.


type Restricted
    = RInt ({ min : Maybe Basics.Int, max : Maybe Basics.Int, width : Maybe Basics.Int })
    | RString ({ minLength : Maybe Basics.Int, maxLength : Maybe Basics.Int, regex : Maybe String })

Restricted forms that are subsets of the basic data types.


type Declarable pos ref
    = DAlias pos Properties (Type pos ref)
    | DSum pos Properties (List.Nonempty.Nonempty ( String, List (Field pos ref) ))
    | DEnum pos Properties (List.Nonempty.Nonempty String)
    | DRestricted pos Properties Restricted

Things that can be declared as named constructs.


type alias L1 pos =
List ( String
, Declarable pos Unchecked 
}

L1 is a list of unchecked declarables.

Properties that can be held against the L1 mode.


type PropSpec
    = PSString
    | PSEnum (Enum String)
    | PSQName
    | PSBool
    | PSOptional PropSpec

Defines the kinds of additional property that can be placed in the model.


type Property
    = PString String
    | PEnum (Enum String) String
    | PQName (List String)
    | PBool Basics.Bool

Allows additional properties from a variety of possible kinds to be placed in the model.


type alias Properties =
Dict String Property

A set of additional properties on the model.


type alias PropSpecs =
Dict String PropSpec

A set of additional property kinds that can or must be defined against the model.

defineProperties : List ( String, PropSpec ) -> List ( String, Property ) -> ( PropSpecs, Properties )

Defines a set of property specifications with possible defaults. The first argument is a list of property specs, and the second is a list of default values.

Values may appear in the second argument that are not in the first, in which case a specification for them will be infered.

Values in the second argument that are also in the first should be of the same kind, but will be overriden by the second argument if not.

emptyProperties : Properties

Creates an empty set of properties.

Ref checking status - L1 is unchecked.


type Unchecked
    = Unchecked

Indicates that the model has not been checked.

Helper functions for extracting info from the L1 model.

positionOfDeclarable : Declarable pos ref -> pos

Gets the position context from a Declarable.

positionOfType : Type pos ref -> pos

Gets the position context from a Type.

propertiesOfDeclarable : Declarable pos ref -> Properties

Gets the properties from a Declarable.

updatePropertiesOfDeclarable : (Properties -> Properties) -> Declarable pos ref -> Declarable pos ref

Updates the properties from a Declarable.

Meta information on the model.

declarableConsName : Declarable pos ref -> String

Yields the constructor name for a Declarable.

typeConsName : Type pos ref -> String

Yields the constructor name for a Type.