Module Relude_HList
type t('l)
=
;|
HNil : t(nil)
|
HCons('h, t('t)) : t(cons('h, 't))
HList.t
is a heterogenous list type which can store a list of differently- typed values while retaining full type safety.Originally this was using the special constructors
[]
and::
, but these seem to constantly conflict with the list versions in Pervasives.
let second: t(cons('a, cons('b, 'c))) => 'b;
Returns the second element of an HList of at least 2 elements
let third: t(cons('a, cons('b, cons('c, 'd)))) => 'c;
Returns the third element of an HList of at least 3 elements
let fourth: t(cons('a, cons('b, cons('c, cons('d, 'e))))) => 'd;
Returns the fourth element of an HList of at least 4 elements
let fifth: t(cons('a, cons('b, cons('c, cons('d, cons('e, 'f)))))) => 'e;
Returns the fifth element of an HList of at least 5 elements
let fromTuple3: ('a, 'b, 'c) => t(cons('a, cons('b, cons('c, nil))));
Creates an HList from a 3-tuple
let fromTuple4: ('a, 'b, 'c, 'd) => t(cons('a, cons('b, cons('c, cons('d, nil)))));
Creates an HList from a 4-tuple
let fromTuple5: ('a, 'b, 'c, 'd, 'e) => t(cons('a, cons('b, cons('c, cons('d, cons('e, nil))))));
Creates an HList from a 5-tuple
let toTuple3: t(cons('a, cons('b, cons('c, nil)))) => ('a, 'b, 'c);
Converts an HList of 3 elements to a tuple