Re: Beginners Digest, Vol 110, Issue 20

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Beginners Digest, Vol 110, Issue 20

Andrey Klaus
Hello

f ma = fmap ((Proxy a) -> Just a) ma 

or even shorter

f = fmap ((Proxy a) -> Just a)


2017-08-25 15:00 GMT+03:00 <[hidden email]>:
Send Beginners mailing list submissions to
        [hidden email]

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
        [hidden email]

You can reach the person managing the list at
        [hidden email]

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


Today's Topics:

   1.  Maybe a -> Maybe b (PICCA Frederic-Emmanuel)


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

Message: 1
Date: Fri, 25 Aug 2017 08:05:34 +0000
From: PICCA Frederic-Emmanuel
        <[hidden email]>
To: "[hidden email]" <[hidden email]>
Subject: [Haskell-beginners] Maybe a -> Maybe b
Message-ID:
        <[hidden email]>

Content-Type: text/plain; charset="us-ascii"

Hello, I have this

data Proxy = Proxy String

And I want to write a function

f :: Maybe Proxy -> Maybe String
f ma = case ma of
           (Just (Proxy a)) -> Just a
           Nothing -> Nothing

I was wondering if there is no simpler way to do this ?

thanks

Frederic

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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


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

End of Beginners Digest, Vol 110, Issue 20
******************************************


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Beginners Digest, Vol 110, Issue 20

Andrey Klaus
sorry, these 2 should be correct

f ma = fmap (\(Proxy a) -> a) ma 

f = fmap (\(Proxy a) -> a)

2017-08-25 15:58 GMT+03:00 Andrey Klaus <[hidden email]>:
Hello

f ma = fmap ((Proxy a) -> Just a) ma 

or even shorter

f = fmap ((Proxy a) -> Just a)


2017-08-25 15:00 GMT+03:00 <[hidden email]>:
Send Beginners mailing list submissions to
        [hidden email]

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
        [hidden email]

You can reach the person managing the list at
        [hidden email]

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


Today's Topics:

   1.  Maybe a -> Maybe b (PICCA Frederic-Emmanuel)


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

Message: 1
Date: Fri, 25 Aug 2017 08:05:34 +0000
From: PICCA Frederic-Emmanuel
        <[hidden email]>
To: "[hidden email]" <[hidden email]>
Subject: [Haskell-beginners] Maybe a -> Maybe b
Message-ID:
        <[hidden email]>

Content-Type: text/plain; charset="us-ascii"

Hello, I have this

data Proxy = Proxy String

And I want to write a function

f :: Maybe Proxy -> Maybe String
f ma = case ma of
           (Just (Proxy a)) -> Just a
           Nothing -> Nothing

I was wondering if there is no simpler way to do this ?

thanks

Frederic

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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


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

End of Beginners Digest, Vol 110, Issue 20
******************************************



_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Beginners Digest, Vol 110, Issue 20

Dmitry Mamontov
In reply to this post by Andrey Klaus
Hello,

Maybe, using fmap would be enough?

data Proxy = Proxy String

f :: Maybe Proxy -> Maybe String
f = fmap (\(Proxy a) -> a)


2017-08-25 15:00 GMT+03:00 <[hidden email]>:
Send Beginners mailing list submissions to
        [hidden email]

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
        [hidden email]

You can reach the person managing the list at
        [hidden email]

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


Today's Topics:

   1.  Maybe a -> Maybe b (PICCA Frederic-Emmanuel)


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

Message: 1
Date: Fri, 25 Aug 2017 08:05:34 +0000
From: PICCA Frederic-Emmanuel
        <[hidden email]>
To: "[hidden email]" <[hidden email]>
Subject: [Haskell-beginners] Maybe a -> Maybe b
Message-ID:
        <[hidden email]>

Content-Type: text/plain; charset="us-ascii"

Hello, I have this

data Proxy = Proxy String

And I want to write a function

f :: Maybe Proxy -> Maybe String
f ma = case ma of
           (Just (Proxy a)) -> Just a
           Nothing -> Nothing

I was wondering if there is no simpler way to do this ?

thanks

Frederic

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

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


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

End of Beginners Digest, Vol 110, Issue 20
******************************************


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners