Module Relude_Ior

Ior is similar to result, but it has the ability to collect "non-fatal warning" information during applicative validation.

E.g. if you are doing applicative validation to construct a User model, you could parse a phone number and allow it, but collect a warning that certain phone number formats are deprecated.

include Relude_Ior_Type;
type t('a, 'b) = Relude_Ior_Type.t('a'b) =
| This('a)
| That('b)
| Both('a, 'b)
;
let this: 'a => t('a'b);

Constructs a This value with the given success value

let that: 'b => t('a'b);

Constructs an That value with the given that value

let both: 'a => 'b => t('a'b);

Constructs an Both value with the given this and that values

let isThis: a b. t('a'b) => bool;

Indicates if the Ior is This with any value

let isThat: a b. t('a'b) => bool;

Indicates if the Ior is That with any value

let isBoth: a b. t('a'b) => bool;

Indicates if the Ior is Both with any values

let getThis: a b. t('a'b) => option('a);

Gets the 'a value out of the Ior

let getThat: a b. t('a'b) => option('b);

Gets the 'b value out of the Ior

let partition: a b. list(t('a'b)) => (list('a), list('b), list(('a, 'b)));

Partitions a list of Iors into lists of the values for each constructor

let catThis: a b. list(t('a'b)) => list('a);

Extracts that 'a values out of a list of Iors

let catThat: a b. list(t('a'b)) => list('b);

Extracts that 'b values out of a list of Iors

let mapThis: a b c. ('a => 'c) => t('a'b) => t('c'b);

Maps a pure function over the this channel of the Ior

let map: ('a => 'b) => t('a'c) => t('b'c);

Alias for mapThis

let mapThat: a b c. ('b => 'c) => t('a'b) => t('a'c);

Maps a pure function over the that channel of the Ior

let tap: a b. ('a => unit) => ('b => unit) => ('a => 'b => unit) => t('a'b) => t('a'b);

Applies a side effect function if the value is This, That, or Both

let tapThis: a b. ('a => unit) => t('a'b) => t('a'b);

Applies a side-effect function if the value is This

let tapThat: a b. ('b => unit) => t('a'b) => t('a'b);

Applies a side-effect function if the value is That

let tapBoth: a b. ('a => 'b => unit) => t('a'b) => t('a'b);

Applies a side-effect function if the value is Both

let tapThisOrBoth: a b. ('a => unit) => t('a'b) => t('a'b);

Applies a side effect function to the 'a value in an This or an Both

let tapThatOrBoth: a b. ('b => unit) => t('a'b) => t('a'b);

Applies a side effect function to the 'b value in an That or an Both

let applyWithAppendThats: ('b => 'b => 'b) => t('a => 'c'b) => t('a'b) => t('c'b);

Applies a wrapped function to the success channel, with that collecting semantics.

let pure: a b. 'a => t('a'b);

Lifts a pure value into an This

let bind: t('a'b) => ('a => t('c'b)) => t('c'b);

Applies a monadic function to the success channel of the Ior

let flatMap: ('a => t('c'b)) => t('a'b) => t('c'b);

Applies a monadic function to the success channel of the Ior

let map2: ('x => 'x => 'x) => ('a => 'b => 'c) => t('a'x) => t('b'x) => t('c'x);

Maps the results of 2 Ior values using the given function

let map3: ('x => 'x => 'x) => ('a => 'b => 'c => 'd) => t('a'x) => t('b'x) => t('c'x) => t('d'x);

Maps the results of 3 Ior values using the given function

let map4: ('x => 'x => 'x) => ('a => 'b => 'c => 'd => 'e) => t('a'x) => t('b'x) => t('c'x) => t('d'x) => t('e'x);

Maps the results of 4 Ior values using the given function

let map5: ('x => 'x => 'x) => ('a => 'b => 'c => 'd => 'e => 'f) => t('a'x) => t('b'x) => t('c'x) => t('d'x) => t('e'x) => t('f'x);

Maps the results of 5 Ior values using the given function

let fold: a b c. ('a => 'c) => ('b => 'c) => ('a => 'b => 'c) => t('a'b) => 'c;

Folds an Ior into a value by applying a function for each case

let toTuple: a b. 'a => 'b => t('a'b) => ('a, 'b);

Converts an Ior into a tuple by filling in default values if needed

let merge: a. ('a => 'a => 'a) => t('a'a) => 'a;

Collapses an Ior containing two same-typed values into a value of that type, combining the values if needed

let mergeWith: a b c. ('a => 'c) => ('b => 'c) => ('c => 'c => 'c) => t('a'b) => 'c;

Collapses an Ior by converting each side into a same-typed value, and combining them if needed

module WithThats: (Thats: BsBastet.Interface.SEMIGROUP_ANY) => (That: BsBastet.Interface.TYPE) => { ... };

Creates a module that locks in the That TYPE and SEMIGROUP_ANY modules, so that we can implement the typeclass instances for the single-type-parameter type classes.