<div dir="ltr">let foo = \x -> Just (x + 1)<br><div>fmap foo (Just 9)</div><div><br></div>Just (Just 10)<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 14, 2018 at 8:15 AM, Olumide <span dir="ltr"><<a href="mailto:50295@web.de" target="_blank">50295@web.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear List,<br>
<br>
Chapter 14 of LYH appears to suggest that a Just value can be added to an Int. Quote from <a href="http://learnyouahaskell.com/for-a-few-monads-more#useful-monadic-functions" rel="noreferrer" target="_blank">http://learnyouahaskell.com/fo<wbr>r-a-few-monads-more#useful-mon<wbr>adic-functions</a><br>
<br>
"For instance, say we have Just 9 and the function \x -> Just (x+1). If we map this function over Just 9, we're left with Just (Just 10)."<br>
<br>
I've tried the following in ghci but got the error:<br>
<br>
<interactive>:12:1: error:<br>
• Non type-variable argument in the constraint: Num (Maybe a)<br>
(Use FlexibleContexts to permit this)<br>
• When checking the inferred type<br>
it :: forall a. (Num (Maybe a), Num a) => Maybe a<br>
<br>
<br>
Am I reading the quote wrong? Is Just (Just 10) a hypothetical?<br>
<br>
Regards,<br>
<br>
- Olumide<br>
______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>