[Haskell-beginners] About monad
Trung Quang Nguyen
trungnq97 at gmail.com
Thu Dec 20 15:45:00 CET 2012
Hi David,
Yours is more precise. f should output (ValueConstructor value) instead of
(Monad value) :)
--Trung
2012/12/20 David McBride <toad3k at gmail.com>
> The way I like to reason about these things
> Prelude> :t (>>=)
>
> (>>=) :: Monad m => m a -> (a -> m b) -> m b
>
> Since the Monad m in this definition is Maybe, I'll just substitute it in
> like so:
> Maybe a -> (a -> Maybe b) -> Maybe b
>
> Then you notice that f is not (a -> b), it is (a -> Maybe b).
>
> On Thu, Dec 20, 2012 at 9:07 AM, Trung Quang Nguyen <trungnq97 at gmail.com>wrote:
>
>> Hi all,
>>
>> I saw this
>>
>>
>> 1. instance Monad Maybe where
>> 2. return x = Just x
>> 3. Nothing >>= f = Nothing
>> 4. Just x >>= f = f x
>> 5. fail _ = Nothing
>>
>>
>> I am wondering about the implementation of function (>>=). Why don't it
>> be *Just x >>= f = Just (f x)*?
>>
>> Any body knows about this?
>>
>> --Trung
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
--
*Trung Nguyen*
Mobile: +45 50 11 10 63
LinkedIn: http://www.linkedin.com/pub/trung-nguyen/36/a44/187
View my blog at http://www.onextrabit.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121220/7dedd86a/attachment.htm>
More information about the Beginners
mailing list