Created by edlc on 12/9/16.
Contains basic Monad
class and associated methods.
For 'what is a monad'/back-story
- See:
-
Maybe
reference: http://hackage.haskell.org/package/base-4.10.1.0/docs/Data-Maybe.htmlEither
reference: http://hackage.haskell.org/package/base-4.10.1.0/docs/Data-Either.html
Classes
Methods
-
static ap(applicative, functor) → {Applicative}
-
Applies function contained by applicative to contents of given functor. (Same as functional applicative
apply
).Parameters:
Name Type Description applicative
Applicative functor
Functor Returns:
Applicative -
static flatMap(fn, monad) → {Monad}
-
Flat maps a function over given monad's contained value.
Parameters:
Name Type Description fn
function monad
Monad Returns:
Monad -
static fmap(fn, x) → {Functor}
-
Maps given function over given functor.
Parameters:
Name Type Description fn
function x
Functor Returns:
Functor -
static getMonadUnWrapper(Type) → {Array.<*>}
-
A recursive monad un-wrapper - Returns monad's unwrapped, inner-mostly, contained value (recursively).
Parameters:
Name Type Description Type
function Returns:
Array.<*> -- [unWrapFunction, tailCallFuncName (used by
trampoline
@see module:fjl.trampoline)]
- [unWrapFunction, tailCallFuncName (used by
-
static isMonad(value) → {boolean}
-
Returns boolean indicating whether given value is an instance of monad or not.
Parameters:
Name Type Description value
* Returns:
boolean -
static join(x) → {*}
-
Calls
valueOf
on given value. Same as monadicjoin
operation (extracts inner value of container/object).Parameters:
Name Type Description x
* Returns:
* -
static toMonad(x) → {*}
-
Always returns a monad; If given value is not a monad creates one using given value.
Parameters:
Name Type Description x
Monad | * Monad or any.
Returns:
* -
static unWrapMonadByType(Type, monad) → {*}
-
Unwraps monad by type.
Parameters:
Name Type Description Type
function monad
Monad Returns:
* -
static valueOf(x) → {*}
-
Calls
valueOf
on value (use for functional composition).Parameters:
Name Type Description x
* Returns:
*