commenting a little bit the typesystem
This commit is contained in:
parent
c0397f68a0
commit
770bdda9df
@ -1,17 +1,19 @@
|
||||
type type_variable = string
|
||||
type type_variable = (*Type_variable *) string
|
||||
|
||||
let fresh_type_variable : ?name:string -> unit -> type_variable =
|
||||
(* generate a new type variable and gave it an id *)
|
||||
let fresh_type_variable : ?name:string -> unit -> type_variable =
|
||||
let id = ref 0 in
|
||||
let inc () = id := !id + 1 in
|
||||
fun ?name () ->
|
||||
inc () ;
|
||||
match name with
|
||||
| None -> "type_variable_" ^ (string_of_int !id)
|
||||
| Some name -> "tv_" ^ name ^ "_" ^ (string_of_int !id)
|
||||
| None -> (*Type_variable*) "type_variable_" ^ (string_of_int !id)
|
||||
| Some name -> (*Type_variable*)"tv_" ^ name ^ "_" ^ (string_of_int !id)
|
||||
|
||||
|
||||
type constant_tag =
|
||||
| C_arrow (* * -> * -> * *)
|
||||
(* add information on the type or the kind for operator*)
|
||||
type constant_tag =
|
||||
| C_arrow (* * -> * -> * *) (* isn't this wrong*)
|
||||
| C_option (* * -> * *)
|
||||
| C_tuple (* * … -> * *)
|
||||
| C_record (* ( label , * ) … -> * *)
|
||||
@ -35,34 +37,38 @@
|
||||
| C_operation (* * *)
|
||||
| C_contract (* * -> * *)
|
||||
|
||||
type label =
|
||||
type label =
|
||||
| L_int of int
|
||||
| L_string of string
|
||||
|
||||
type type_value =
|
||||
(* Weird stuff; please explain *)
|
||||
type type_value =
|
||||
| P_forall of p_forall
|
||||
| P_variable of type_variable
|
||||
| P_variable of type_variable (* how a value can be a variable? *)
|
||||
| P_constant of (constant_tag * type_value list)
|
||||
| P_apply of (type_value * type_value)
|
||||
|
||||
and p_forall = {
|
||||
and p_forall = {
|
||||
binder : type_variable ;
|
||||
constraints : type_constraint list ;
|
||||
body : type_value
|
||||
}
|
||||
}
|
||||
|
||||
and simple_c_constructor = (constant_tag * type_variable list) (* non-empty list *)
|
||||
and simple_c_constant = (constant_tag) (* for type constructors that do not take arguments *)
|
||||
and c_const = (type_variable * type_value)
|
||||
and c_equation = (type_value * type_value)
|
||||
and c_typeclass = (type_value list * typeclass)
|
||||
and c_access_label = (type_value * label * type_variable)
|
||||
(* Different type of constraint *) (* why isn't this a variant ? *)
|
||||
and simple_c_constructor = (constant_tag * type_variable list) (* non-empty list *)
|
||||
and simple_c_constant = (constant_tag) (* for type constructors that do not take arguments *)
|
||||
and c_const = (type_variable * type_value)
|
||||
and c_equation = (type_value * type_value)
|
||||
and c_typeclass = (type_value list * typeclass)
|
||||
and c_access_label = (type_value * label * type_variable)
|
||||
|
||||
and type_constraint =
|
||||
(*What i was saying just before *)
|
||||
and type_constraint =
|
||||
(* | C_assignment of (type_variable * type_pattern) *)
|
||||
| C_equation of c_equation (* TVA = TVB *)
|
||||
| C_typeclass of c_typeclass (* TVL ∈ TVLs, for now in extension, later add intensional (rule-based system for inclusion in the typeclass) *)
|
||||
| C_access_label of c_access_label (* poor man's type-level computation to ensure that TV.label is type_variable *)
|
||||
(* | … *)
|
||||
(* | … *)
|
||||
|
||||
and typeclass = type_value list list
|
||||
(* is the first list in case on of the type of the type class as a kind *->*->* ? *)
|
||||
and typeclass = type_value list list
|
||||
|
@ -3,6 +3,7 @@ open Core
|
||||
let pair_map = fun f (x , y) -> (f x , f y)
|
||||
|
||||
module Substitution = struct
|
||||
(* Replace Types variables by the infered type *)
|
||||
|
||||
module Pattern = struct
|
||||
|
||||
|
@ -14,6 +14,7 @@ let forall_tc binder f =
|
||||
let (tc, ty) = f (P_variable freshvar) in
|
||||
P_forall { binder = freshvar ; constraints = tc ; body = ty }
|
||||
|
||||
(* chained forall *)
|
||||
let forall2 a b f =
|
||||
forall a @@ fun a' ->
|
||||
forall b @@ fun b' ->
|
||||
|
Loading…
Reference in New Issue
Block a user