module App: Generic_util_app
Type application and defunctionalisation.
Type Application
module T: sig
.. end
type ('a, 'b)
t = ('a, 'b) T.app
Synonym for convenience, when namespace Generic_util
is
opened, and one doesn't want to open App.T
, one can
refer to App.T.app
as App.t
.
Core parametric types
type
option'
type ('_, '_)
Generic_util_app.t +=
val get_option : ('a, option') t -> 'a option
type
list'
type ('_, '_)
Generic_util_app.t +=
| |
List : 'a list -> ('a, list') t |
val get_list : ('a, list') t -> 'a list
type
array'
type ('_, '_)
Generic_util_app.t +=
| |
Array : 'a array -> ('a, array') t |
val get_array : ('a, array') t -> 'a array
Identity Functor
type
id =
type ('_, '_)
Generic_util_app.t +=
val get_id : ('a, id) t -> 'a
Constant Functor
type 't
const =
The type
't const
doesn't build useful values, we use
it as a "code" to be interpreted by
app
so that
('a, 't
const) app
is isomorphic to
't
.
It would have been better to make 't const
an abstract
type, but it then makes typechecking troublesome for the
constructor Const : 't -> ('a, 't const) app
type ('_, '_)
Generic_util_app.t +=
| |
Const : 'b -> ('a, 'b const) t |
('a, 'b const) app
is isomorphic to 't
val get_const : ('a, 'b const) t -> 'b
Get the argument of the Const
constructor
Exponential Functor
type 'b
exponential =
The type 'b exponential
doesn't build useful values,
consider it abstract. We use it as a "code" to be
interpreted by app
so that ('a, 'b exponential) app
is
isomorphic to 'a -> 'b
.
type ('_, '_)
Generic_util_app.t +=
('a, 'b exponential) app
is isomorphic to 'a -> 'b
.
val get_exponential : ('a, 'b exponential) t -> 'a -> 'b
Get the argument of the Exponential
constructor
Functor Composition
type ('f, 'g)
comp =
type ('_, '_)
Generic_util_app.t +=
| |
Comp : (('a, 'f) t, 'g) t -> ('a, ('f, 'g) comp) t |
val get_comp : ('a, ('f, 'g) comp) t ->
(('a, 'f) t, 'g) t