Proposal: Data.Functor.<.> for `fmap f2 . f1`

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

Proposal: Data.Functor.<.> for `fmap f2 . f1`

Ömer Sinan Ağacan
I don't know if "I find this very useful" is enough for adding a function to
base, but here it goes:

    infixl 4 <.>
    (<.>) :: Functor f => (b -> c) -> (a -> f b) -> (a -> f c)
    f1 <.> f2 = fmap f1 . f2
    {-# INLINE (<.>) #-}

I first defined this couple of months ago and I find myself looking for this
function all the time now.

One problem with this is that the name is used by widely used `filepath`
library.
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Data.Functor.<.> for `fmap f2 . f1`

Phil Scott
That should just be (fmap.fmap).

> I don't know if "I find this very useful" is enough for adding a function to
> base, but here it goes:
>
>     infixl 4 <.>
>     (<.>) :: Functor f => (b -> c) -> (a -> f b) -> (a -> f c)
>     f1 <.> f2 = fmap f1 . f2
>     {-# INLINE (<.>) #-}
>
> I first defined this couple of months ago and I find myself looking for this
> function all the time now.
>
> One problem with this is that the name is used by widely used `filepath`
> library.
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

--
Sent with my mu4e

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

Re: Proposal: Data.Functor.<.> for `fmap f2 . f1`

Joachim Breitner-2
In reply to this post by Ömer Sinan Ağacan
Hi,

Am Samstag, den 19.09.2015, 21:30 -0400 schrieb Ömer Sinan Ağacan:
> One problem with this is that the name is used by widely used
> `filepath` library.

I would say that this kills this proposal right away...

Greetings,
Joachim


--
Joachim “nomeata” Breitner
  [hidden email]http://www.joachim-breitner.de/
  Jabber: [hidden email]  • GPG-Key: 0xF0FBF51F
  Debian Developer: [hidden email]

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

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Data.Functor.<.> for `fmap f2 . f1`

Andreas Abel
I also defined this <.> for my own use, see

 
https://hackage.haskell.org/package/Agda-2.4.0/docs/Agda-Utils-Functor.html

(<.>) relates to (.) as (<$>) relates to ($).

I find myself in quite often in the need of my own "Functor" <.>, and at
least 100 times more seldom I require the "filepath" <.>.

Do we juggle around filepathes all the time when we program Haskell!?
Don't we rather combine functions a lot?

So, a conflict with filepath is not the final word.

Cheers,
Andreas


On 20.09.2015 12:03, Joachim Breitner wrote:

> Hi,
>
> Am Samstag, den 19.09.2015, 21:30 -0400 schrieb Ömer Sinan Ağacan:
>> One problem with this is that the name is used by widely used
>> `filepath` library.
>
> I would say that this kills this proposal right away...
>
> Greetings,
> Joachim
>
>
>
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>


--
Andreas Abel  <><      Du bist der geliebte Mensch.

Department of Computer Science and Engineering
Chalmers and Gothenburg University, Sweden

[hidden email]
http://www2.tcs.ifi.lmu.de/~abel/
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Data.Functor.<.> for `fmap f2 . f1`

Marcin Mrotek
Hello,


Best regards,
Marcin Mrotek

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

Re: Proposal: Data.Functor.<.> for `fmap f2 . f1`

Ivan Lazar Miljenovic
In reply to this post by Ömer Sinan Ağacan
On 20 September 2015 at 11:30, Ömer Sinan Ağacan <[hidden email]> wrote:

> I don't know if "I find this very useful" is enough for adding a function to
> base, but here it goes:
>
>     infixl 4 <.>
>     (<.>) :: Functor f => (b -> c) -> (a -> f b) -> (a -> f c)
>     f1 <.> f2 = fmap f1 . f2
>     {-# INLINE (<.>) #-}
>
> I first defined this couple of months ago and I find myself looking for this
> function all the time now.
>
> One problem with this is that the name is used by widely used `filepath`
> library.

Apart from the clashing with other libraries, I mislike this because
of it's lack of symmetry: to me it seems odd that the Functor is only
on one side (admittedly though, the variant of type (b -> f c) -> (a
-> f b) -> a -> f c requires Monad rather than just Functor).

--
Ivan Lazar Miljenovic
[hidden email]
http://IvanMiljenovic.wordpress.com
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Data.Functor.<.> for `fmap f2 . f1`

Ömer Sinan Ağacan
In reply to this post by Andreas Abel
2015-09-20 6:19 GMT-04:00 Andreas Abel <[hidden email]>:
> (<.>) relates to (.) as (<$>) relates to ($).

This is the reason why I like this so much.
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Data.Functor.<.> for `fmap f2 . f1`

Edward Kmett-2
In reply to this post by Ömer Sinan Ağacan
This operator is usually named .: or the like. It is a weaker form of fmap.fmap.

I'm pretty strongly -1 on including it in base under the <.> name. 

I'm less strongly -1 on some .: variant.

-Edward

On Sat, Sep 19, 2015 at 9:30 PM, Ömer Sinan Ağacan <[hidden email]> wrote:
I don't know if "I find this very useful" is enough for adding a function to
base, but here it goes:

    infixl 4 <.>
    (<.>) :: Functor f => (b -> c) -> (a -> f b) -> (a -> f c)
    f1 <.> f2 = fmap f1 . f2
    {-# INLINE (<.>) #-}

I first defined this couple of months ago and I find myself looking for this
function all the time now.

One problem with this is that the name is used by widely used `filepath`
library.
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


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

Re: Proposal: Data.Functor.<.> for `fmap f2 . f1`

Alexander Berntsen
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 20/09/15 22:08, Edward Kmett wrote:
> This operator is usually named .: or the like. It is a weaker form
> of fmap.fmap.
'(.:) = (.).(.)' is very common. But given that '(<$>) = (.)' for
functions, '(.:) = fmap . fmap' would work.

- -1 on '(<.>)'.
+1 on '(.:)'.

- --
Alexander
[hidden email]
https://secure.plaimi.net/~alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCgAGBQJV//ENAAoJENQqWdRUGk8BZmAP/1WfovtSUqj1WcpMq/2tgS3s
lasGdQ+Rzw1G340yKkfkjPmHs6OHMKBbuUFCpofmIE5zNZBcK91GZptvbfO4saSd
d66Rj/t7h7sl1Jc5JLnJj+UEls+z1ycUsrHOPQgWOqvHwClkMkD2fiV/qPgUGYYP
czTsRBLCnTGx3kbebfvBfrCk+rdCwRf/L8EC22ambp8/TCh5j1J4QpfubwNzy6Yh
IgHLq+25EzEMkZgxuf3e5wb5M/cJiNCujFcA4x2hOIR/4d6KOWtM+Gxse2T8V4Jr
AhwEdj27AQRvZ+vM5khFA7UyfB1Y4yqhWd8BmeisQGnhHvK1gPPfXBvp6K3l/ylf
XMePGOAEY7SDreb/Fk6rtlDW1uD5ukbY5RY9dp62OgLBexm/eL/Ywx/OAjRi7r7I
iQFV1dOFSCkNwEdf07A062FtaV0pRD+LjocnRodOvTDdACfpDDZFwDD/zbBip58u
mCD6vlM7wOcW8eL8Pg/BvwTuRVY+zT1L8b1TpVFRw3y8VtWE2uGPSsdI91g0wQcC
HX5g7LLeg8vl55z28TScOD/2jf0uCixwwAOe/r0nWY1+Ifv9J+lzCJQeyr9Ffbif
JUfbmBQHek/FDnPKtTcZcGms11tZZF5qMTl7y2FefKNtj+A2ipJeM3n9jzkXWci7
TBeEdz4g/0JJHdGciOug
=+oey
-----END PGP SIGNATURE-----
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries