Liquidsoap_lang_types.Type_baseThe raw representation behind Type, for the few places that need to build or traverse it directly.
Type information comes attached to the AST from the parsing, with appropriate sharing of the type variables. Then the type inference performs in-place unification.
In order to report precise type error messages, we put very dense parsing location information in the type. Every layer of it can have a location. Destructive unification introduces links in such a way that the old location is still accessible.
The level annotation represents the number of abstractions which surround the type in the AST -- function arguments and let-in definitions. It is used to safely generalize types.
Finally, constraints can be attached to existential (unknown, '_a) and universal ('a) type variables.
Type description
module R : sig ... endA type constructor applied to arguments (e.g. source).
and var = {name : int;mutable level : int;mutable constraints : constr Liquidsoap_lang_types__.Type_constraints.t;}Contents of a variable.
and meth = {meth : string;name of the method
*)optional : bool;is the method optional?
*)scheme : scheme;type scheme
*)doc : meth_doc;documentation
*)json_name : string option;name when represented as JSON
*)}A method.
and custom_handler = {typ : custom;serialize : custom -> string;copy_with : (t -> t) -> custom -> custom;occur_check : (t -> unit) -> custom -> unit;filter_vars : (var list -> t -> var list) -> var list -> custom -> var list;repr : (var list -> t -> constr R.t) -> var list -> custom -> constr R.t;subtype : (t -> t -> unit) -> custom -> custom -> unit;sup : (t -> t -> t) -> custom -> custom -> custom;}What a custom type carries, and what can be done with it. None of it can be written out: the payload is the process's own, the rest are closures, which is what serialize is for.
and custom_handler_state = | Resolved of custom_handler| Dumped of {payload_id : int;payload : string;types : t list;}A custom type read back from a dump arrives Dumped: its payload's serialized form, the types that payload holds, and which payload it was, since types that shared one on the way out have to share one again.
and descr = | String| Int| Float| Bool| Never| Custom of custom_instance| Constr of constructed| Getter of ta getter: something that is either a t or () -> t
*)| List of repr_t| Tuple of t list| Nullable of tsomething that is either t or null
*)| Meth of meth * tt with a method added
*)| Arrow of t argument list * ta function
*)| Var of var_ta type variable
*)module Constraints : sig ... endmodule DS : sig ... endval registered_constraints : (string, constr) Stdlib.Hashtbl.tval registered_constraint : string -> constr optionval string_of_constr : constr -> stringval unit : descrmodule Var : sig ... endOperations on variables.
module Vars : sig ... endSets of variables.
val custom_handler : custom_instance -> custom_handlerDereferencing gives you the meaning of a term, going through links created by instantiations. One should (almost) never work on a non-dereferenced type.
val make : ?pos:Liquidsoap_lang_prelude.Pos.Option.base -> descr -> tCreate a type from its value.
val has_meth : t -> string -> boolDo we have a method with given label?
val meth :
?pos:Liquidsoap_lang_prelude.Pos.Option.base ->
?json_name:??? ->
?category:??? ->
?optional:??? ->
string ->
scheme ->
?doc:??? ->
t ->
tAdd a method to a type.
val meths :
?invoke:??? ->
?pos:Liquidsoap_lang_prelude.Pos.Option.base ->
string list ->
scheme ->
t ->
tAdd a submethod to a type.
val var :
?constraints:??? ->
?level:??? ->
?pos:Liquidsoap_lang_prelude.Pos.Option.base ->
unit ->
tmodule Fresh : sig ... endval is_fun : t -> boolval is_source : t -> boolval custom_types : (string, unit -> t) Stdlib.Hashtbl.tval register_single_type : string -> (unit -> t) -> unitval register_type : string -> (unit -> t) -> unitRegister a type under a possibly dotted name, creating the intermediate method types as needed.
val find_opt_typ : string -> (unit -> t) optionval mk_invariant : t -> unit