Category:Monads: Difference between revisions
Content added Content deleted
(Add reference to Writer monad) |
No edit summary |
||
Line 2: | Line 2: | ||
In functional programming, the [[wp:Monad_(functional_programming)|Monad]] pattern is a general solution to the problem of nesting (or 'composing') functions when the data to which they apply is enclosed in some kind of useful wrapping. It involves implementing two higher-order functions which, between them, can take care of ensuring that the nested (data-transforming) functions are not choked by being called on unexpected types of data. (Wrapped data, when they were expecting something raw and unwrapped). |
In functional programming, the [[wp:Monad_(functional_programming)|Monad]] pattern is a general solution to the problem of nesting (or 'composing') functions when the data to which they apply is enclosed in some kind of useful wrapping. It involves implementing two higher-order functions which, between them, can take care of ensuring that the nested (data-transforming) functions are not choked by being called on unexpected types of data. (Wrapped data, when they were expecting something raw and unwrapped). |
||
The two higher-order functions which make up the monad pattern handle the details of: 1. wrapping |
The two higher-order functions which make up the monad pattern handle the details of: 1. wrapping data, and 2. Providing other functions with direct access to the unwrapped data contents. Delegating the mechanics to these two meta-functions allows the programmer to work with a simple and well-understood generic model, and to nest functions transparently. |
||
The two monad functions are sometimes named as follows: |
The two monad functions are sometimes named as follows: |