package higher_kinded
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=a9f046111d35745d60e13eaa212d621a8bdad315f350fe1b024d0854f99e0551
doc/higher_kinded/Higher_kinded/index.html
Module Higher_kinded
Source
This library allows you to use higher-kinded types in OCaml. See the README for a short tutorial on what that means and how to use it.
Types
If A
implements the signature S
, (a, A.witness1) t
is equivalent to a A.t
.
If A
implements the signature S
, ('a, A.higher_kinded) t1
is equivalent to 'a A.t
.
If A
implements the signature S2
, ('a, 'b, A.higher_kinded) t2
is equivalent to ('a, 'b) A.t
.
If A
implements the signature S3
, ('a, 'b, 'c, A.higher_kinded) t3
is equivalent to ('a, 'b, 'c) A.t
.
If A
implements the signature S4
, ('a, 'b, 'c, 'd, A.higher_kinded) t4
is equivalent to ('a, 'b, 'c, 'd) A.t
.
If A
implements the signature S5
, ('a, 'b, 'c, 'd, 'e, A.higher_kinded) t5
is equivalent to ('a, 'b, 'c, 'd, 'e) A.t
.
If A
implements the signature S6
, ('a, 'b, 'c, 'd, 'e, 'f, A.higher_kinded) t6
is equivalent to ('a, 'b, 'c, 'd, 'e, 'f) A.t
.
If A
implements the signature S7
, ('a, 'b, 'c, 'd, 'e, 'f, 'g, A.higher_kinded) t7
is equivalent to ('a, 'b, 'c, 'd, 'e, 'f, 'g) A.t
.
If A
implements the signature S8
, ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, A.higher_kinded) t8
is equivalent to ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h) A.t
.
Signatures
include sig ... end
Functors
This is the meat of the library. Use these functors to implement the higher_kinded interface.
module Make_monad_using_witness
(M : Base.Monad.S)
(X : S with type 'a t := 'a M.t) :
Monad with type 'a t := 'a M.t with type higher_kinded := X.higher_kinded
module Make_monad_using_witness2
(M : Base.Monad.S2)
(X : S2 with type ('a, 'b) t := ('a, 'b) M.t) :
Monad2
with type ('a, 'b) t := ('a, 'b) M.t
with type higher_kinded := X.higher_kinded
module Make_monad_using_witness3
(M : Base.Monad.S3)
(X : S3 with type ('a, 'b, 'c) t := ('a, 'b, 'c) M.t) :
Monad3
with type ('a, 'b, 'c) t := ('a, 'b, 'c) M.t
with type higher_kinded := X.higher_kinded
Implementations
Base
, Core
, and Async
don't depend on Higher_kinded
, so we put these implementations here instead of in the respective modules where they might have been a nicer fit.