Send Beginners mailing list submissions to
[email protected]
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
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Maybe a -> Maybe b (Olivier Iffrig)
2. Re: Maybe a -> Maybe b (PICCA Frederic-Emmanuel)
3. Re: Maybe a -> Maybe b (Imants Cekusins)
4. Re: Beginners Digest, Vol 110, Issue 20 (Andrey Klaus)
5. Re: Beginners Digest, Vol 110, Issue 20 (Andrey Klaus)
----------------------------------------------------------------------
Message: 1
Date: Fri, 25 Aug 2017 14:27:57 +0200
From: Olivier Iffrig <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Maybe a -> Maybe b
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
PICCA Frederic-Emmanuel wrote (2017-08-25 08:05:34):
> 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 ?
Maybe implements the Functor type class (as an exercise, you can try to
figure out the implementation), therefore you can simply use fmap, which
in the case of Maybe, has type (a -> b) -> Maybe a -> Maybe b
You just need a function to "unwrap" the String inside of the Proxy, and
you're done.
--
Olivier
------------------------------
Message: 2
Date: Fri, 25 Aug 2017 12:45:37 +0000
From: PICCA Frederic-Emmanuel
<[email protected]>
To: "The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell" <[email protected]>
Subject: Re: [Haskell-beginners] Maybe a -> Maybe b
Message-ID:
<a2a20ec3b8560d408356cac2fc148e53bb41b...@sun-dag3.synchrotron-soleil.fr>
Content-Type: text/plain; charset="us-ascii"
> Maybe implements the Functor type class (as an exercise, you can try to
> figure out the implementation), therefore you can simply use fmap, which
> in the case of Maybe, has type (a -> b) -> Maybe a -> Maybe b
Thanks I reallized this after sending the email
thanks
Frederic
------------------------------
Message: 3
Date: Fri, 25 Aug 2017 15:56:41 +0300
From: Imants Cekusins <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Maybe a -> Maybe b
Message-ID:
<cap1qinbrbj8ch6me7ssixt03pj9hnrwzud0o2zjpgrg1cyc...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
> as an exercise, you can try to figure out the implementation
.. time is up :-P
Here is an answer for slightly more generic Proxy and f:
data Proxy a = Proxy a
exProxy::Functor f =>
f (Proxy a) -> f a
exProxy = (un1 <$>)
where un1 (Proxy a1) = a1
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20170825/96892427/attachment-0001.html>
------------------------------
Message: 4
Date: Fri, 25 Aug 2017 15:58:05 +0300
From: Andrey Klaus <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Beginners Digest, Vol 110, Issue 20
Message-ID:
<cafsn60sp+acwni2g5xx-0tahoevrvdd6zq28asocbvzfa9p...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
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 <[email protected]>:
> Send Beginners mailing list submissions to
> [email protected]
>
> 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
> [email protected]
>
> You can reach the person managing the list at
> [email protected]
>
> 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
> <[email protected]>
> To: "[email protected]" <[email protected]>
> Subject: [Haskell-beginners] Maybe a -> Maybe b
> Message-ID:
> <A2A20EC3B8560D408356CAC2FC148E53BB41B8D4@SUN-DAG3.
> synchrotron-soleil.fr>
>
> 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
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
> ------------------------------
>
> End of Beginners Digest, Vol 110, Issue 20
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20170825/b400b818/attachment-0001.html>
------------------------------
Message: 5
Date: Fri, 25 Aug 2017 16:03:49 +0300
From: Andrey Klaus <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Beginners Digest, Vol 110, Issue 20
Message-ID:
<CAFsn60T_dagaj0E6KK+Mrxg0AgiwyZyF5G=vhwur9p1tlld...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
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 <[email protected]>:
> 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 <[email protected]>:
>
>> Send Beginners mailing list submissions to
>> [email protected]
>>
>> 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
>> [email protected]
>>
>> You can reach the person managing the list at
>> [email protected]
>>
>> 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
>> <[email protected]>
>> To: "[email protected]" <[email protected]>
>> Subject: [Haskell-beginners] Maybe a -> Maybe b
>> Message-ID:
>> <[email protected]
>> on-soleil.fr>
>>
>> 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
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>>
>> ------------------------------
>>
>> End of Beginners Digest, Vol 110, Issue 20
>> ******************************************
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20170825/3745a2cb/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 110, Issue 21
******************************************