package decoders

  1. Overview
  2. Docs

Module Decoders.DecoderSource

Sourcetype ('i, 'o) t = 'i -> ('o, 'i Error.t) result

An ('i, 'o) t is a decoder that

  • consumes a value of type 'i
  • produces a value of type 'o or an error of type 'i Error.t
Sourceval pure : 'o -> ('i, 'o) t

pure x always succeeds with x

Sourceval fail : string -> ('i, 'o) t

fail msg always fails with msg, capturing the error context from 'i

Sourceval fail_with : 'i Error.t -> ('i, 'o) t

fail_with e always fails with e

Sourceval of_result : ('o, 'i Error.t) Util.My_result.t -> ('i, 'o) t
Sourceval bind : ('a -> ('i, 'b) t) -> ('i, 'a) t -> ('i, 'b) t
Sourceval map : ('a -> 'b) -> ('i, 'a) t -> ('i, 'b) t
Sourceval map_err : ('i Error.t -> 'i Error.t) -> ('i, 'o) t -> ('i, 'o) t
Sourceval apply : ('i, 'a -> 'b) t -> ('i, 'a) t -> ('i, 'b) t
Sourcemodule Infix : sig ... end
Sourceval fix : (('i, 'a) t -> ('i, 'a) t) -> ('i, 'a) t
Sourceval value : ('i, 'i) t
Sourceval maybe : ('i, 'a) t -> ('i, 'a option) t
Sourceval one_of : ('i, 'o) t list -> ('i, 'o) t
Sourceval pick : ('i, ('i, 'o) t) t list -> ('i, 'o) t
Sourceval of_to_opt : ('i -> 'o option) -> ('i -> ('o, 'i Error.t) result) -> ('i, 'o) t
Sourceval decode_sub : 'a -> ('a, 'b) t -> ('a, 'b) t