Generalised_signatures.IndexableA type of indexable containers with parametric element type, such as array.
module type Indexable1 = sig ... endmodule Array : Indexable1 with type 'a t = 'a arrayA type of indexable containers with fixed element type, such as string.
module type Indexable0 = sig ... endmodule String : Indexable0 with type t = string and type elt = charA signature that generalises both Indexable1 and Indexable0.
module type IndexableN = sig ... endWe can use functors to demonstrate that IndexableN is indeed a generalisation of the other two:
module Indexable0_to_N (X : Indexable0) : IndexableN with type 'a t = X.t and type 'a elt = X.eltIndexable0 is a special-case of IndexableN.
module Indexable1_to_N (X : Indexable1) : IndexableN with type 'a t = 'a X.t and type 'a elt = 'aIndexable1 is a special-case of IndexableN.
We can now define some behaviours on top of IndexableN:
module Foldable_of_indexable (I : IndexableN) : sig ... end... and then apply this functor to both of our Indexable containers:
module Array_foldable : sig ... endmodule String_foldable : sig ... end