= 768" x-on:close-sidebar="sidebar=window.innerWidth >= 768 && true">
package travesty
-
travesty
-
-
travesty.containers
-
-
travesty.core_kernel_exts
Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
Generic
is a generic interface for traversable containers, used to build S0
(arity-0) and S1
(arity-1).
include Types_intf.Generic
module On_monad
(M : Base.Monad.S) :
Generic_on_monad
with type 'a t := 'a t
and type 'a elt := 'a elt
and module M := M
On_monad
implements monadic traversal operators for a given monad M
.
We can do generic container operations.
include Base.Container.Generic with type 'a t := 'a t and type 'a elt := 'a elt
val length : _ t -> int
val is_empty : _ t -> bool
val fold_result :
'a t ->
init:'accum ->
f:('accum -> 'a elt -> ('accum, 'e) Base.Result.t) ->
('accum, 'e) Base.Result.t
val fold_until :
'a t ->
init:'accum ->
f:('accum -> 'a elt -> ('accum, 'final) Base.Container.Continue_or_stop.t) ->
finish:('accum -> 'final) ->
'final
val sum :
(module Base.Container.Summable with type t = 'sum) ->
'a t ->
f:('a elt -> 'sum) ->
'sum
We can do non-monadic mapping operations.
include Mappable.Generic with type 'a t := 'a t and type 'a elt := 'a elt
Generic
refers to the container type as 'a t
, and the element type as 'a elt
; substitute t
/elt
(arity-0) or 'a t
/'a
(arity-1) accordingly below.
include Types_intf.Generic with type 'a t := 'a t with type 'a elt := 'a elt
fold_map c ~f ~init
folds f
over every t
in c
, threading through an accumulator with initial value init
.
mapi ~f t
maps f
across t
, passing in an increasing position counter.
module With_errors :
Generic_on_monad
with type 'a t := 'a t
and type 'a elt := 'a elt
and module M := Base.Or_error
With_errors
specialises On_monad
to the error monad.