Monads compared to InputRanges?

Max Klyga max.klyga at gmail.com
Wed Dec 4 05:58:17 PST 2013


On Wednesday, 4 December 2013 at 10:03:51 UTC, Timon Gehr wrote:
> 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.

You are right. Now looking at provided implementation this seems 
obvoius


More information about the Digitalmars-d-learn mailing list