Started work for type inference

This commit is contained in:
elvis
2024-11-06 17:21:14 +01:00
parent a6daee916e
commit 19c11ad9c8
5 changed files with 112 additions and 173 deletions

View File

@ -1,12 +1,21 @@
type variable = string
let globalIdentifier = ref 1
module VariableMap = Map.Make(String)
module VariableSet = Set.Make(String)
type ftype =
IntegerType
| BooleanType
| PolimorphicType of string
| FunctionType of ftype list * ftype
type fsubstitution = (* goes from polimorphic types to types *)
ftype VariableMap.t
type fenvironment = (* goes from variables to types *)
ftype VariableMap.t
type typingshape = (* tuple of a simple type environment and a simple type *)
fenvironment * ftype
type t_exp =
Integer of int (* x := a *)
@ -32,7 +41,7 @@ type t_exp =
| CmpGreaterEq of t_exp * t_exp (* x >= x *)
| IfThenElse of t_exp * t_exp * t_exp (* if b then c else c *)
| LetIn of variable * t_exp * t_exp (* let x = x in x *)
| LetFun of variable * variable list * ftype * t_exp * t_exp (* let rec x: t. x in x*)
| LetFun of variable * variable list * ftype * t_exp * t_exp (* let rec x: t. x in x *)
type permittedValues =
IntegerPermitted of int