Skip to content
johnmcclean-aol edited this page Nov 23, 2016 · 4 revisions

Inclusive Or

Ior can be one of Primary, Secondary or Both Primary and Secondary, and as such it can behave either like a product (Tuple) or sum (either) type. As an Either or Union type, it is right biased. Primary and Secondary are used instead of Right & Left.

Ior inherits from the following cyclops types (and others) ApplicativeFunctor, Filterable, Foldable, Functor, MonadicValue1, To, Value,Visitable and Zippable.

Right' (or primary type) biased disjunct union. No 'projections' are provided, swap() and secondaryXXXX alternative methods can be used instead.

Ior.<Integer,Integer>primary(10).map(i->i+1);
//Ior.primary[11]

Ior.<Integer,Integer>secondary(10).map(i->i+1);
//Ior.secondary[10]

Ior.<Integer,Integer>secondary(10).swap().map(i->i+1);
//Ior.primary[11]

Ior<String,Ingeger> kv = Ior.both("hello",90);
//Ior["hello",90]

See also Ior in Cats

Clone this wiki locally