Pickles_types.HlistBasic primitives for inductive rules. In particular, heterogeneous lists (H1, H2, ...) whose length and element types are known at compile-time.
To get started, read some basic usage examples in Hlist0.H1, H1 and H1.Map.
In a normal value-level computation analogy:
Poly_types.T0 are values,In the rest of this documentation, we will use the terms "type values", "type functions" and "higher-order type functions" w.r.t this analogy. Where possible, we will give for each symbol its equivalent translation at the value-level.
The basic concept of this implementation of heterogeneous lists is inspired from Haskell's Hlist library: https://okmij.org/ftp/Haskell/HList-ext.pdf
The following modules and functors are support tools used to manipulate types that are then fed to the heterogeneous lists defined below (see Heterogeneous lists).
The following higher-order functions artificially increase the number of arguments of a function (or value), by creating a function that ignores extra parameters.
module E01 (T : Poly_types.T0) : sig ... endMap arity 0 to 1: let e01 t = fun _ -> t
module E02 (T : Poly_types.T0) : sig ... endMap arity 0 to 2: let e02 t = fun _ _ -> t
module E03 (T : Poly_types.T0) : sig ... endMap arity 0 to 3: let e02 t = fun _ _ _ -> t
module E04 (T : Poly_types.T0) : sig ... endMap arity 0 to 4: let e02 t = fun _ _ _ _ -> t
module E06 (T : Poly_types.T0) : sig ... endMap arity 0 to 6: let e06 t = fun _ _ _ _ _ _ -> t
module E13 (T : Poly_types.T1) : sig ... endMap arity 1 to 3: let e13 t = fun a _ _ -> t a
module E23 (T : Poly_types.T2) : sig ... endMap arity 2 to 3: let e23 t = fun a b _ -> t a b
The following higher-order functions take multiple functions F, G, ... and return a function which applies all of its arguments to F, G, ... and packs the result in a tuple.
module Tuple2 (F : Poly_types.T3) (G : Poly_types.T3) : sig ... endTuple of 2 function applications: let tuple2 f g = fun a b c -> (f a b c, g a b c)
module Tuple3
(F : Poly_types.T3)
(G : Poly_types.T3)
(H : Poly_types.T3) :
sig ... endTuple of 3 function applications: let tuple3 f g h = fun a b c -> (f a b c, g a b c, h a b c)
module Tuple4
(F : Poly_types.T3)
(G : Poly_types.T3)
(H : Poly_types.T3)
(I : Poly_types.T3) :
sig ... endTuple of 4 function applications: let tuple4 f g h i = fun a b c -> (f a b c, g a b c, ..., i a b c)
module Tuple5
(F : Poly_types.T3)
(G : Poly_types.T3)
(H : Poly_types.T3)
(I : Poly_types.T3)
(J : Poly_types.T3) :
sig ... endTuple of 5 function applications: let tuple4 f g h i = fun a b c -> (f a b c, g a b c, ..., j a b c)
The following Functions just return one of their arguments.
module Arg1 : sig ... endAlways return first argument: let fst a _ = a
module Arg2 : sig ... endAlways return second argument: let snd _ b = b
The following higher-order functions composes function applications in specific ways.
module Apply2
(F : Poly_types.T2)
(X : Poly_types.T1)
(Y : Poly_types.T1) :
sig ... endCompose one binary function F and two unary functions X and Y into a binary function that applies X (resp. Y) to its first (resp. second) argument before passing both to F: let apply2 f x y = fun a b -> f (x a) (y b)
module Dup (F : Poly_types.T2) : sig ... endTransforms a binary function into an unary one by duplicating its argument. let dup f = fun x -> f x x
module Length = Hlist0.LengthReification of list length with Peano integers, see Hlist0.Length.
The following modules are named as with the following scheme:
X is the type of (and operations on) heterogeneous lists whose content type varies over X different type parameters. See H1 for a detailed example.X_Y is the type of (and operations on) heterogeneous lists whose content type varies over X different type parameters from cell to cell, but also varies from list to list over Y other homogeneous type parameters. See Hlist0.H1_1 for a detailed example.module H1 : sig ... endOperations on heterogeneous lists whose content type varies over a single type parameter. Read Hlist0.H1 first.
module HlistId = Hlist0.HlistIdSimplest heterogeneous list, see Hlist0.HlistId.
module H2 : sig ... endOperations on heterogeneous lists whose content type varies over a two type parameters.
module H2_1 : sig ... endData type of heterogeneous lists whose content type varies over two type parameters, but also varies homogeneously over one other type parameter. It supports operations similar to H1. See also Hlist0.H1_1.
module H3 : sig ... endOperations on heterogeneous lists whose content type varies over a tree type parameters.
Data type of heterogeneous lists whose content type varies over three type parameters, but also varies homogeneously over one other type parameters. It supports no operations. See Hlist0.H1_1.
module H3_2 : sig ... endData type of heterogeneous lists whose content type varies over three type parameters, but also varies homogeneously over two other type parameters. It supports no operations. See Hlist0.H1_1.
module H3_3 : sig ... endData type of heterogeneous lists whose content type varies over three type parameters, but also varies homogeneously over three other type parameters. It supports no operations. See Hlist0.H1_1.
module H3_4 : sig ... endData type of heterogeneous lists whose content type varies over three type parameters, but also varies homogeneously over four other type parameters. It supports no operations. See Hlist0.H1_1.
module H4 : sig ... endOperations on heterogeneous lists whose content type varies over a four type parameters.
module H6 : sig ... endOperations on heterogeneous lists whose content type varies over a four type parameters.
module H4_2 : sig ... endData type of heterogeneous lists whose content type varies over four type parameters, but also varies homogeneously over two other type parameters. It supports no operations. See Hlist0.H1_1.
module H4_4 : sig ... endData type of heterogeneous lists whose content type varies over four type parameters, but also varies homogeneously over four other type parameters. It supports no operations. See Hlist0.H1_1.
module H4_6 : sig ... endData type of heterogeneous lists whose content type varies over four type parameters, but also varies homogeneously over six other type parameters. It supports no operations. See Hlist0.H1_1.
module H6_2 : sig ... endData type of heterogeneous lists whose content type varies over six type parameters, but also varies homogeneously over two other type parameters. It supports no operations. See Hlist0.H1_1.
module H6_4 : sig ... endData type of heterogeneous lists whose content type varies over six type parameters, but also varies homogeneously over four other type parameters. It supports no operations. See Hlist0.H1_1.
Utilities to compute the maximum of heterogeneous lists containing natural integers whose type represent their value (hence the need for heterogeneous lists).
module type Max_s = sig ... endType of the maximum for heterogeneous lists containing types 'ns.
val max : ('n * 'ns) H1.T(Nat).t -> ('n * 'ns) maxFind the maximum of a non-empty (ensured by the type system) list of naturals.
val max_exn : 'ns H1.T(Nat).t -> 'ns maxFind the maximum of a list of naturals, raising an exception if it is empty.
module Maxes : sig ... endBuild the (heterogeneous) list of maximums from a vector of vectors of integers. See Vector.
module Map_1_specific
(A : Poly_types.T2)
(B : Poly_types.T2)
(C : sig ... end) :
sig ... endBuild a function which transforms a Hlist0.H1_1 list into another Hlist0.H1_1 which has the same varying type parameter but a different homogeneous type parameter.