control.monads¶| Stability: | 1 - Experimental |
|---|---|
| Bug Tracker: | https://github.com/folktale/control.monads/issues |
| Version: | 0.6.0 |
| Repository: | https://github.com/folktale/control.monads |
| Portability: | Portable |
| npm package: | control.monads |
Common monadic combinators and sequencing operations.
Require the control.monads package, after installing it:
var monads = require('control.monads')
control.monads.sequence(type, monads)¶| Returns: | A monad containing an array of the values. |
|---|
m:Monad(_) => m → Array(m(α)) → m(Array(α))
control.monads.mapM(type, transformation, values)¶| Returns: | A monad containing an array of the values. |
|---|
m:Monad(_) => m → (α → m(β)) → Array(α) → m(Array(β))
Converts each value into a monadic action, then evaluates such actions, left to right, and collects their results.
control.monads.compose(f, g, value)¶| Returns: | A composition of the given functions on monads. |
|---|
m:Monad(_) => (α → m(β)) → (β → m(γ)) → α → m(γ)
Left-to-right Kleisi composition of monads.
control.monads.rightCompose(f, g, value)¶| Returns: | A composition of the given functions on monads. |
|---|
m:Monad(_) => (β → m(γ)) → (α → m(β)) → α → m(γ)
Right-to-left Kleisi composition of monads.
control.monads.join(monad)¶| Returns: | The nested monad. |
|---|
m:Monad(_) => m(m(α)) → m(α)
Removes one level of nesting for a nested monad.
control.monads.filterM(type, predicate, values)¶| Returns: | An array with values that pass the predicate, inside a monad. |
|---|
m:Monad(_) => m → (α → m(Boolean)) → Array(α) → m(Array(α))
Filters the contents of an array with a predicate returning a monad.
control.monads.concat(left, right)¶| Returns: | A new semigroup with the values combined. |
|---|
s:Semigroup(_) => s(α) → s(α) → s(α)
Concatenates two semigroups.
control.monads.map(transformation, functor)¶| Returns: | A functor with its contents transformed by f. |
|---|
f:Functor(_) => (α → β) → f(α) → f(β)
Maps over a functor instance.
control.monads.of(value, type)¶| Returns: | A new applicative instance containing the given value. |
|---|
f:Applicative(_) => α → f → f(α)
Constructs a new applicative intance.