3 ms·
well, a 'reader' monad is a monad over a Function[A, B]. So yes, when you say 'the reader monad', what you (probably?) mean is the instance it operates on, whi
by runT1ME 10y ago
well, a 'reader' monad is a monad over a Function[A, B]. So yes, when you say 'the reader monad', what you (probably?) mean is the instance it operates on, which would be a function.
You use the reader monad the thread the same input to multiple functions that may also take additional intput, and also have their own outputs.
You have to keep in mind that since Monads are so common and useful, many languages have syntactic support for them. C#'s LINQ query syntax, scala for expressions and haskell 'do' are all 'monadic comprehension'.
- wrong_variable 10y agoSo A reader Monad is similar to class inheritance. Where you provide a dependency ( like a inner class ). The resulting class can also have other variables and inputs. Is that a correct analogy ?
- greydius 10y agoI think a better analogy with OO languages would be a Function object for which you've provided one of the arguments in its constructor. Inheritance is more similar to monad transformers.