- 
                Notifications
    
You must be signed in to change notification settings  - Fork 138
 
Type Interfaces : MonadicValue1
        johnmcclean-aol edited this page Nov 22, 2016 
        ·
        1 revision
      
    A MonadicValue1 represents a Value with a single type parameter (e.g. a Maybe or FutureW opposed to an Xor or Try) that is also a monad.
In cyclops-react it has the following methods
- flatMap : flattening transformation operation
 - combineEager : eagerly combine two Monadic values
 - flatMapIterable : flatMap this MonadicValue with an Iterable type taking the first value if the Iterable has more than 1
 - flatMapPublisher : flatMap this MonadicValue with an Publisher type taking the first value if the Publisher has more than 1
 
Monoid<Integer> add = Monoid.of(1,Semigroups.intSum);
  Maybe.of(10).combineEager(add,Maybe.none());
  //Maybe[10]
  
  Maybe.none().combineEager(add,Maybe.of(10));
  //Maybe[10]
  
  Maybe.none().combineEager(add,Maybe.none());
  //Maybe.none()
  
  Maybe.of(10).combineEager(add,Maybe.of(10));
  //Maybe[20]
  
  Monoid<Integer> firstNonNull = Monoid.of(null , Semigroups.firstNonNull());
  Maybe.of(10).combineEager(firstNonNull,Maybe.of(10));
  //Maybe[10]Eval, FeatureToggle, Maybe
oops - my bad