Module MiniAlgebra (.ml)

module MiniAlgebra: sig .. end
This module provides the type algebra for the Mini language.


The type algebra augments the CoreAlgebra to relate it with the Mini source language.
type symbol 
Head symbols.
type associativity = 
| AssocLeft
| NonAssoc
| AssocRight
| EnclosedBy of string * string
Associativity of a symbol.
val as_symbol : MiniAst.tname -> symbol option
as_symbol s maps the string s to a symbol if s is a valid symbol name.
val associativity : symbol -> associativity
associativity s returns the associativity of s.
val priority : symbol -> int
priority s returns the priority of s.
val infix : symbol -> bool
infix s tests if s is infix.
type 'a environment = MiniAst.tname -> 'a CoreAlgebra.arterm 
A type constructor is a type variable with higher-order kind. It is introduced as any type variable in the multi-equation set during the constraint generation. Then, an environment is given to the algebra in order to retrieve the type variable associated to the string representation of the type constructor.
val tuple : 'a environment ->
'a CoreAlgebra.arterm list -> 'a CoreAlgebra.arterm
tuple env ts returns t0 * ... * tn.
val pre : 'a environment -> 'a CoreAlgebra.arterm -> 'a CoreAlgebra.arterm
pre env t returns the type pre t.
val abs : 'a environment -> 'a CoreAlgebra.arterm
abs env return the type abs.
val record_constructor : 'a environment -> 'a CoreAlgebra.arterm -> 'a CoreAlgebra.arterm
record_constructor env return the type constructor {.}.
val arrow : 'a environment ->
'a CoreAlgebra.arterm -> 'a CoreAlgebra.arterm -> 'a CoreAlgebra.arterm
arrow env t1 t2 return the type t1 -> t2.
val n_arrows : 'a environment ->
'a CoreAlgebra.arterm list -> 'a CoreAlgebra.arterm -> 'a CoreAlgebra.arterm
arrow env ts returns the type t0 -> ... -> tn.
val result_type : 'a environment -> 'a CoreAlgebra.arterm -> 'a CoreAlgebra.arterm
result_type env t returns the result type of the type t if t is an arrow type.
val arg_types : 'a environment ->
'a CoreAlgebra.arterm -> 'a CoreAlgebra.arterm list
result_type env t returns the argument types of the type t if t is an arrow type.
val tycon_args : 'a CoreAlgebra.arterm -> 'a CoreAlgebra.arterm list
val tycon_name : 'a CoreAlgebra.arterm -> 'a CoreAlgebra.arterm
val type_of_primitive : 'a environment -> MiniAst.primitive -> 'a CoreAlgebra.arterm
type_of_primitive p returns the type of a source language primitive.
type builtin_dataconstructor = MiniAst.dname * MiniAst.tname list * MiniAst.typ 
The type of predefined data constructors.
val init_builtin_env : (?name:MiniAst.tname -> unit -> 'a) ->
(MiniAst.tname *
(MiniAst.kind * 'a CoreAlgebra.arterm *
builtin_dataconstructor list))
list
init_builtin_env variable_maker uses variable_maker to built a typing environment that maps type constructor names to their arities and their type variables.
val builtin_env : (MiniAst.tname *
(bool * associativity * int * MiniAst.kind *
(MiniAst.dname * MiniAst.tname list * MiniAst.typ) list))
array