package dolmen

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
Usual definitions
type t = ty

The type of types.

type subst = (ty_var, ty) Subst.t

The type of substitutions over types.

type 'a tag = 'a Tag.t

A type for tags to attach to arbitrary types.

exception Bad_arity of ty_cst * t list

Raised when applying a type constant to the wrong number of arguments.

exception Prenex_polymorphism of t

Raised when the type provided is polymorphic, but occurred in a place where polymorphic types are forbidden by prenex/rank-1 polymorphism.

val hash : t -> int

A hash function for types, should be suitable to create hashtables.

val equal : t -> t -> bool

An equality function on types. Should be compatible with the hash function.

val compare : t -> t -> int

Comparison function over types. Should be compativle with the equality function.

val print : Format.formatter -> t -> unit

Printing function.

Alias management
val alias_to : ty_cst -> ty_var list -> ty -> unit

Alias the given type constant.

val expand_head : t -> t

Expand head aliases.

View
type view = [
  1. | `Prop
    (*

    Propositions/booleans

    *)
  2. | `Int
    (*

    Integers

    *)
  3. | `Rat
    (*

    Rationals

    *)
  4. | `Real
    (*

    Reals

    *)
  5. | `Array of ty * ty
    (*

    Function arrays, from source to destination type.

    *)
  6. | `Bitv of int
    (*

    Bitvectors of fixed length.

    *)
  7. | `Float of int * int
    (*

    Floating points.

    *)
  8. | `String
    (*

    Strings

    *)
  9. | `String_reg_lang
    (*

    Regular languages over strings

    *)
  10. | `Var of ty_var
    (*

    Variables (excluding wildcards)

    *)
  11. | `Wildcard of ty_var
    (*

    Wildcards

    *)
  12. | `App of [ `Generic of ty_cst | `Builtin of builtin ] * ty list
    (*

    Generic applications.

    *)
  13. | `Arrow of ty list * ty
  14. | `Pi of ty_var list * ty
]

View on types.

val view : t -> view

View on types.

val pi_arity : t -> int

Returns the number of expected type arguments that the given type expects (i.e. the number of prenex polymorphic variables in the given type).

val poly_sig : t -> ty_var list * ty list * ty

Split a type into a polymorphic signature.

Type structure definition
type def = ty_def

Alias for type definitions.

val define : ty_cst -> def -> unit

Register a type definition.

val definition : ty_cst -> def option

Return the definition of a type (if it exists).

Variables and constants
module Var : sig ... end

A module for variables that occur in types.

module Const : sig ... end

A module for constant symbols the occur in types.

val prop : t

The type of propositions

val bool : t

Alias for prop.

val unit : t

The unit type.

val base : t

An arbitrary type.

val int : t

The type of integers

val rat : t

The type of rationals

val real : t

The type of reals.

val string : t

The type of strings

val string_reg_lang : t

The type of regular language over strings.

val of_var : Var.t -> t

Create a type from a variable.

val apply : Const.t -> t list -> t

Application for types.

val arrow : t list -> t -> t

Create an arrow type (i.e. function type)

val pi : Var.t list -> t -> t

Create a prenex/rank-1 polymorphic type.

val array : t -> t -> t

Build an array type from source to destination types.

val bitv : int -> t

Bitvectors of a given length.

val float : int -> int -> t

Floating point of given exponent and significand.

val roundingMode : t

Type for the various Floating point rounding modes.

val subst : ?fix:bool -> subst -> t -> t

Substitution on types.

val fv : t -> Var.t list

Returns the list of free variables in the type.

val freshen : t -> t

Freshen a type, replacing all its bound variables by new/fresh type variables.

val unify : t -> t -> t option

Try and unify two types.

val match_ : t list -> t list -> subst option

Try and pattern mathc a list of patterns agains a list of types.

val instance_of : t -> t -> t list option

instance_of poly t decides whether t is an instance of poly, that is whether there are some types l such that a term of type poly applied to type arguments l gives a term of type t.

val set_wildcard : ty_var -> t -> unit

Instantiate the given wildcard.

val add_wildcard_hook : hook:(ty_var -> ty -> unit) -> ty_var -> unit

Tag for hooks called upon the wildcard instantiation.

val get_tag : t -> 'a Tag.t -> 'a option

Get the value bound to a tag.

val get_tag_list : t -> 'a list Tag.t -> 'a list

Get the list of values bound to a list tag, returning the empty list if no value is bound.

val get_tag_last : t -> 'a list Tag.t -> 'a option

Get the last value bound to a list tag.

val set_tag : t -> 'a Tag.t -> 'a -> unit

Set the value bound to the tag.

val add_tag : t -> 'a list Tag.t -> 'a -> unit

Bind an additional value to a list tag.

val add_tag_opt : t -> 'a list Tag.t -> 'a option -> unit

Optionally bind an additional value to a list tag.

val add_tag_list : t -> 'a list Tag.t -> 'a list -> unit

Bind a list of additional values to a list tag.

val unset_tag : t -> _ Tag.t -> unit

Remove the binding to the given tag.

OCaml

Innovation. Community. Security.