Akh Javascript Monad Library
Reader Monad and Monad Transformer forThe ReaderT transformer, ReaderT
, adds error control to a monad. The base type, Reader
, provides error logic on its own.
# To use as standalone package $ npm install --save akh.reader # To use as part of akh library $ npm install --save akh
Usage
ReaderT
and Reader
implement the Fantasy Land monad, functor, and applicative functor interfaces. ``ReaderT` is also a monoid if the underlying type is.
// Reader monadReaderReader // Reader monad transformerReaderTReaderT
Reader.run(m, r)
, m.run(r)
Perform a reader computation m
in environment r
and return result
Reader === 20
ReaderT.run(t)
, t.run()
Same as Reader.run
but for a monad transformer. Returns an Reader
value inside of the inner monad.
Reader Interface
Reader.ask
ReaderT(M).ask
Return the current environment.
Reader.asks(f)
ReaderT(M).asks(f)
Extract a value from the current environment using f
.
m.local(f)
t.local(f)
Execute the current computation in a modified enviroment. f
maps current enviroment to a new enviroment.
Contributing
Contributions are welcome.
To get started:
$ cd akh-reader$ npm install # install dev packages $ npm test # run tests