-
travesty
-
-
travesty.containers
-
-
travesty.core_kernel_exts
Library
Module
Module type
Parameter
Class
Class type
Non-monadic mapping.
Mappable
contains signatures and extensions for types that can be (non-monadically) mapped over. It resembles the Haskell (but not the OCaml!) notion of a functor, though we call the mapping function map
.
Signatures
Mappable_intf contains the signatures for Mappable
.
include module type of Mappable_intf
The generic signature
As with Traversable, we define the signature of mappable structures in an arity-generic way, then specialise it for arity-0 and arity-1 types.
module type Generic = sig ... end
Generic
describes mapping on either an arity-0 or arity-1 type.
Basic signatures
The basic signatures are S0, which defines mapping across an arity-0 type t
(with a fixed, associated element type elt
), and S1, which defines mapping across an arity-1 type 'a t
(with element type 'a
).
module type S0 = sig ... end
S0
is the signature of an arity-0 mappable type.
module type S1 = sig ... end
S1
is the signature of an arity-1 mappable type.
Mappable container signatures
Unlike with Traversable's map_m
, we can't actually implement the Core container signatures over map
alone. We still define versions of the Mappable
interfaces that include their respective container signatures, both for symmetry and to allow for extensions.
module type S0_container = sig ... end
S0_container
is the signature of an arity-0 mappable container.
module type S1_container = sig ... end
S1_container
is the signature of an arity-1 mappable container.
Extensions
The signatures below describe various functions we can derive from mappable types and mappable containers. To apply them to existing types, use the functors in Mappable.
module type Extensions1 = sig ... end
Extensions1
describes various extensions of arity-1 mappable containers.
Extending mappable containers
We define several derived functions for mappable containers in Mappable_intf---here, we define functors to generate them.
module Extend1 (S : S1_container) : Extensions1 with type 'a t := 'a S.t
Extend1
implements Extensions1
for an arity-1 mappable container.