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

The Maybe type in cyclops-react is a totally lazy Option or Optional type modelled on Maybe from Haskell. Maybe's can represent one of two states - Just a value (present / some ) or None.

Maybe is an instance of the following cyclops types (and others) ApplicativeFunctor, Filterable, Foldable, Functor, MonadicValue1, To, Value,Visitable and Zippable

In cyclops we can use the visit operator to pattern match on the state the Maybe is in.

int result = Maybe.just(10)
                  .visit(some->some+5,()->-1); 
Clone this wiki locally