Maciej Marcin Piechotka | 1 Aug 2010 15:52
Picon

#4189: Add (<.>) operator (generalizing (.) to Functor)

The proposal is to add (<.>) function to Data.Functor/Control.Applicative:
(<.>) :: (b -> c) -> (a -> f b) -> a -> f c
f <.> g = fmap f . g -- (<.>) = (.) . fmap

In intend it is related to <$> in the same way as (.) is related to $:
(a . b . c) d = a $ b $ c $ d
(a <.> b <.> c) d = a <$> b <$> c <$> d

a is not specialized to f a to allow such chaining:
const 1 <.> print <=< (read :: String -> Int) <.> readFile
  :: (Num t) => FilePath -> IO t

Discussion deadline: 31th August 2010

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Felipe Lessa | 1 Aug 2010 16:05
Picon
Gravatar

Re: #4189: Add (<.>) operator (generalizing (.) to Functor)

+1

What should be its fixity?

--

-- 
Felipe.
Maciej Marcin Piechotka | 1 Aug 2010 16:25
Picon

Re: #4189: Add (<.>) operator (generalizing (.) to Functor)

On 01/08/10 16:05, Felipe Lessa wrote:
> +1
> 
> What should be its fixity?
> 

I guess right:

\a b c -> a <.> b <.> c
  :: (Functor f) =>
     (a1 -> b) -> (a11 -> a1) -> (a -> f a11) -> a -> f b

As opposed to:

\a b c -> a <.> b <.> c
  :: (Functor f, Functor f1) =>
     (a1 -> b) -> (a11 -> f a1) -> (a -> f1 a11) -> a -> f1 (f b)

Regards

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Felipe Lessa | 1 Aug 2010 16:30
Picon
Gravatar

Re: #4189: Add (<.>) operator (generalizing (.) to Functor)

On Sun, Aug 1, 2010 at 11:25 AM, Maciej Marcin Piechotka
<uzytkownik2 <at> gmail.com> wrote:
> On 01/08/10 16:05, Felipe Lessa wrote:
>> +1
>>
>> What should be its fixity?
>>
>
> I guess right:

I mean, how tightly should it bind?  We currently have

infixr 9 .
infixr 0 $
infixr 4 <$>
infirl 4 <$
infixl 4 <*>
infixr 1 >=>

Hmmm...

--

-- 
Felipe.
Stephen Tetley | 1 Aug 2010 19:00
Picon

Re: #4189: Add (<.>) operator (generalizing (.) to Functor)

-1

Personal preference against the name - regular compose (.) has
symmetry in what composes, this combinator doesn't.
Maciej Marcin Piechotka | 1 Aug 2010 21:57
Picon

Re: #4189: Add (<.>) operator (generalizing (.) to Functor)

On 01/08/10 19:00, Stephen Tetley wrote:
> -1
> 
> Personal preference against the name - regular compose (.) has
> symmetry in what composes, this combinator doesn't.

Hmm. Do you have an idea for better name?

Regards

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Stephen Tetley | 1 Aug 2010 22:15
Picon

Re: #4189: Add (<.>) operator (generalizing (.) to Functor)

On 1 August 2010 20:57, Maciej Marcin Piechotka <uzytkownik2 <at> gmail.com> wrote:

> Hmm. Do you have an idea for better name?

blackbirdA ?

For the function instance of Applicative its the blackbird combinator,
unless I made a miscalculation when rewriting the signature.
John Meacham | 1 Aug 2010 22:49
Favicon

Re: #4189: Add (<.>) operator (generalizing (.) to Functor)

On Sun, Aug 01, 2010 at 09:15:33PM +0100, Stephen Tetley wrote:
> blackbirdA ?
>
> For the function instance of Applicative its the blackbird combinator,
> unless I made a miscalculation when rewriting the signature.

Then clearly we should use this as the operator.

>                     .--.
>                    ."  o \__
>                 _.-"    ,(  `
>             _.-"      ,;;|
>        _.-=" _,"    ,,;;;'
>    .-"`_.-"``-..,,;;;;:'
>    `"'`          `\`\
>                   /^\\\

We will just have to tweak the layout rule a little to accept it..

        John

--

-- 
John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/
Stephen Tetley | 1 Aug 2010 22:51
Picon

Re: #4189: Add (<.>) operator (generalizing (.) to Functor)

Nice one, John...

Definitely +1 for that!
Henning Thielemann | 1 Aug 2010 23:15
Picon

Re: #4189: Add (<.>) operator (generalizing (.) to Functor)


On Sun, 1 Aug 2010, John Meacham wrote:

> Then clearly we should use this as the operator.
>
>>                     .--.
>>                    ."  o \__
>>                 _.-"    ,(  `
>>             _.-"      ,;;|
>>        _.-=" _,"    ,,;;;'
>>    .-"`_.-"``-..,,;;;;:'
>>    `"'`          `\`\
>>                   /^\\\
>
> We will just have to tweak the layout rule a little to accept it..

That's the best proposal for an infix operator I have ever seen! However, 
I'm afraid that GHC will reject it since the bird's eye is a letter.

Gmane