package spotlib

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Spotlib.Poly_resultSource

Sourcetype ('a, 'error) t = [
  1. | `Ok of 'a
  2. | `Error of 'error
]
include Monad.T2 with type ('a, 'error) t := ('a, 'error) t
Sourceval return : 'a -> ('a, 'z) t
Sourceval bind : ('a, 'z) t -> ('a -> ('b, 'z) t) -> ('b, 'z) t
Sourceval fmap : ('a -> 'b) -> ('a, 'z) t -> ('b, 'z) t

fmap in Haskell

Sourceval liftM : ('a -> 'b) -> ('a, 'z) t -> ('b, 'z) t

Synonym of fmap

Sourceval fmap2 : ('a -> 'b -> 'c) -> ('a, 'z) t -> ('b, 'z) t -> ('c, 'z) t

fmap2 in Haskell

Sourceval liftM2 : ('a -> 'b -> 'c) -> ('a, 'z) t -> ('b, 'z) t -> ('c, 'z) t

synonym of fmap2 in Haskell

Sourceval void : ('a, 'z) t -> (unit, 'z) t
Sourceval seq : ('a, 'z) t list -> ('a list, 'z) t

sequence in Haskell. Not tail recursive.

Sourceval seq_ : (unit, 'z) t list -> (unit, 'z) t

sequence_ in Haskell. Not tail recursive.

Sourceval mapM : ('a -> ('b, 'z) t) -> 'a list -> ('b list, 'z) t

Not tail recursive by default

Sourceval mapM_ : ('a -> (unit, 'z) t) -> 'a list -> (unit, 'z) t

Not tail recursive by default

Sourceval iteri : (int -> 'a -> (unit, 'z) t) -> 'a list -> (unit, 'z) t

Iteration with index starting from 0. Not tail recursive by default.

Sourceval for_ : int -> int -> (int -> (unit, 'z) t) -> (unit, 'z) t

for like iteration. Not tail recursive by default

Sourceval join : (('a, 'z) t, 'z) t -> ('a, 'z) t
Sourceval prod : ('a, 'z) t -> ('b, 'z) t -> ('a * 'b, 'z) t
Sourcemodule Infix : sig ... end
Sourcemodule Syntax : Monad.Syntax2 with type ('a, 'b) t := ('a, 'b) t
Sourceval fail : 'a -> [> `Error of 'a ]
Sourceval catch : (fail:('error -> 'exn) -> 'a) -> [> ('a, 'error) t ]

catch f runs f ~fail.

If f ~fail returns a value v then catch f returns `Ok v.

If f ~fail calls fail e, then the execution of the f ~fail immediately exists and catch f returns `Error e

Any exception raised in f ~fail is not caught.

Sourceval catch_exn : (unit -> 'a) -> [> ('a, exn) t ]

catch_exn f runs f ().

If f () returns a value v then catch f returns `Ok v.

If an exception exn raised in f (), catch f returns `Error exn.

Sourceval from_Ok : [< ('a, 'error) t ] -> 'a

Haskell's fromJust

Sourceval result : ('a -> 'b) -> ('c -> 'b) -> [< ('a, 'c) t ] -> 'b

Haskell's either

Sourceval map_error : ('e -> 'f) -> ('a, 'e) t -> ('a, 'f) t
Sourceval at_Error : ('err -> 'a) -> [< ('a, 'err) t ] -> 'a

at_Error = result id

Sourceval to_option : [< ('a, 'err) t ] -> 'a option

Conversion to option type

Sourcemodule Stdlib : sig ... end
OCaml

Innovation. Community. Security.