|
Marjoram
0.01
Library for Functional Programming in C++
|
Reader Monad, supporting constants and functions. More...
Classes | |
| class | ma::Reader< A, R > |
| Reader Monad. More... | |
Reader Monad, supporting constants and functions.
Represents computation that requires a shared resource A to run. Can be used to implement Dependency Injection (see test/test_reader.cxx and this blogpost for illustration).
| class ma::Reader |
Reader Monad.
Essentially std::function with sugar on top.
Represents computations that require a shared resource A to run. map/flatMap composes further computations.
Public Member Functions | |
| Reader (std::function< R(A)> f) | |
| R | run (const A &a) const |
| Run the function. | |
| template<typename F > | |
| auto | map (F f) const -> Reader< A, std::result_of_t< F(R)>> |
| template<typename F > | |
| auto | flatMap (F f) -> std::result_of_t< F(R)> |
|
inline |
|
inline |
| f | Function object. |
Type requirement:
F::operator() when called with const R& argument has non-void return type C.Reader<A, C>.