Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Adding 1 to Just 9 (Olumide)
   2. Re:  Adding 1 to Just 9 (David McBride)


----------------------------------------------------------------------

Message: 1
Date: Mon, 14 May 2018 13:15:31 +0100
From: Olumide <50...@web.de>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: [Haskell-beginners] Adding 1 to Just 9
Message-ID: <7b423875-731c-8cb6-f4a7-410f59940...@web.de>
Content-Type: text/plain; charset=utf-8; format=flowed

Dear List,

Chapter 14 of LYH appears to suggest that a Just value can be added to 
an Int. Quote from 
http://learnyouahaskell.com/for-a-few-monads-more#useful-monadic-functions

"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)."

I've tried the following in ghci but got the error:

<interactive>:12:1: error:
     • Non type-variable argument in the constraint: Num (Maybe a)
       (Use FlexibleContexts to permit this)
     • When checking the inferred type
         it :: forall a. (Num (Maybe a), Num a) => Maybe a


Am I reading the quote wrong? Is Just (Just 10) a hypothetical?

Regards,

- Olumide


------------------------------

Message: 2
Date: Mon, 14 May 2018 08:18:31 -0400
From: David McBride <toa...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Adding 1 to Just 9
Message-ID:
        <can+tr41yylwfc0157tm_fsg05z6mwio8g4imeyp3qxcf-oy...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

let foo = \x -> Just (x + 1)
fmap foo (Just 9)

Just (Just 10)


On Mon, May 14, 2018 at 8:15 AM, Olumide <50...@web.de> wrote:

> Dear List,
>
> Chapter 14 of LYH appears to suggest that a Just value can be added to an
> Int. Quote from http://learnyouahaskell.com/fo
> r-a-few-monads-more#useful-monadic-functions
>
> "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)."
>
> I've tried the following in ghci but got the error:
>
> <interactive>:12:1: error:
>     • Non type-variable argument in the constraint: Num (Maybe a)
>       (Use FlexibleContexts to permit this)
>     • When checking the inferred type
>         it :: forall a. (Num (Maybe a), Num a) => Maybe a
>
>
> Am I reading the quote wrong? Is Just (Just 10) a hypothetical?
>
> Regards,
>
> - Olumide
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20180514/dee40098/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 119, Issue 5
*****************************************

Reply via email to