Monads compared to InputRanges?

Timon Gehr timon.gehr at gmx.ch
Wed Dec 4 02:03:51 PST 2013


On 12/04/2013 12:49 AM, Max Klyga wrote:
>
>
> range.map(...).flatten.map(...) might look similar and it could be
> possible to squeeze monads to work with this api,  but the thing is that
> not every monad could provide a meaningful map function

Yes, every monad provides a meaningful way to map morphisms.

In Haskell this is not explicit however:

map :: Monad m => (a -> b) -> m a -> m b
map f = (return . f =<<)

> and as a whole
> calling flatten after every map is a bit tiresome.



More information about the Digitalmars-d-learn mailing list