Travesty.Traversable
Signatures and functors for containers and data structures that can be mapped across with a monadic side-effect.
Modules based on this pattern resembles the Haskell Traversable typeclass, but with two differences:
map_m
.For input and output module signatures for this module's functors, see Traversable_types
.
Monadic traversal is sufficient to define fold
, and, therefore, all of the key functionality for a Base-style container. As such, our signatures and functors subsume those for building containers.
module Make0
(I : Traversable_types.Basic0) :
Traversable_types.S0 with module Elt = I.Elt and type t = I.t
module Make1
(I : Traversable_types.Basic1) :
Traversable_types.S1 with type 'a t = 'a I.t
module Make0_container
(I : Traversable_types.Basic0_container) :
Traversable_types.S0 with module Elt = I.Elt and type t = I.t
Make0_container
makes an S0 from a Basic0_container.
module Make1_container
(I : Traversable_types.Basic1_container) :
Traversable_types.S1 with type 'a t = 'a I.t
Make1_container
makes an S1 from a Basic1_container.
module Chain0
(Outer : Traversable_types.S0)
(Inner : Traversable_types.S0 with type t := Outer.Elt.t) :
Traversable_types.S0 with module Elt = Inner.Elt and type t = Outer.t
Chain0
chains two S0 instances together, traversing each element of the outer instance with the inner instance.
module Fix_elt
(I : Traversable_types.S1)
(Elt : Base.Equal.S) :
Traversable_types.S0 with module Elt = Elt and type t = Elt.t I.t