Missing `$` like operators in Haskell

Below are the `$` like operators in Haskell (view in fixed width): --------------------------------------------------------------------- | Function first | Op | Function second | Op | ------------------------------------------------------------------------------- | Plain | (a -> b) -> a -> b | $ | a -> (a -> b) -> b | | | Functor | (a -> b) -> f a -> f b | <$> | f a -> (a -> b) -> f b | | | Applicat| f (a -> b) -> f a -> f b | <*> | f a -> f (a -> b) -> f b | <**> | | Monad | (a -> m b) -> m a -> m b | =<< | m a -> (a -> m b) -> m b |
= |
The "function second" forms I couldn't find for "plain" and "functor". What are the most common operators to used in these places?

I obviously had my table too wide in the last message, here it is again: ------------------------------------------------------------------- | Function first | Op | Function second | Op ------------------------------------------------------------------------- Plain | (a -> b) -> a -> b | $ | a -> (a -> b) -> b | Fnctr | (a -> b) -> f a -> f b | <$> | f a -> (a -> b) -> f b | Applc | f (a -> b) -> f a -> f b | <*> | f a -> f (a -> b) -> f b | <**> Monad | (a -> m b) -> m a -> m b | =<< | m a -> (a -> m b) -> m b | >>= -------------------------------------------------------------------------

Comonad :: (f a -> b) -> f a -> f b Contravariant :: (b -> a) -> f a -> f b Exponential :: (a -> b, b -> a) -> f a -> f b On 12/12/14 12:47, Clinton Mead wrote:
Below are the `$` like operators in Haskell (view in fixed width):
--------------------------------------------------------------------- | Function first | Op | Function second | Op | ------------------------------------------------------------------------------- | Plain | (a -> b) -> a -> b | $ | a -> (a -> b) -> b | | | Functor | (a -> b) -> f a -> f b | <$> | f a -> (a -> b) -> f b | | | Applicat| f (a -> b) -> f a -> f b | <*> | f a -> f (a -> b) -> f b | <**> | | Monad | (a -> m b) -> m a -> m b | =<< | m a -> (a -> m b) -> m b | >>= | -------------------------------------------------------------------------------
The "function second" forms I couldn't find for "plain" and "functor". What are the most common operators to used in these places?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

The lens package defines (&) and (<&>) as flipped ($) and (<$>),
respectively. There is nothing in the base package that defines those. <&>
is quite uncommon. Flipped ($) is something that crops up here and there.
Sometimes called (|>), or (#).
-- Dan Burton
On Thu, Dec 11, 2014 at 6:47 PM, Clinton Mead
Below are the `$` like operators in Haskell (view in fixed width):
--------------------------------------------------------------------- | Function first | Op | Function second | Op |
------------------------------------------------------------------------------- | Plain | (a -> b) -> a -> b | $ | a -> (a -> b) -> b | | | Functor | (a -> b) -> f a -> f b | <$> | f a -> (a -> b) -> f b | | | Applicat| f (a -> b) -> f a -> f b | <*> | f a -> f (a -> b) -> f b | <**> | | Monad | (a -> m b) -> m a -> m b | =<< | m a -> (a -> m b) -> m b |
= |
-------------------------------------------------------------------------------
The "function second" forms I couldn't find for "plain" and "functor". What are the most common operators to used in these places?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 12.12.2014 03:58, Dan Burton wrote:
The lens package defines (&) and (<&>) as flipped ($) and (<$>), respectively. There is nothing in the base package that defines those. <&> is quite uncommon. Flipped ($) is something that crops up here and there. Sometimes called (|>), or (#).
https://github.com/ghc/ghc/blob/master/libraries/base/Data/Function.hs A the bottom. -- /Since: 4.8.0.0/ (&) :: a -> (a -> b) -> b x & f = f x I learned about it from #haskell channel. -- Wojtek

Everything doesn't have to have an operator! We use operators a bit too
much. It hurts readability of code when lines start looking like APL.
On Fri, Dec 12, 2014 at 2:15 PM, Wojtek Narczyński
On 12.12.2014 03:58, Dan Burton wrote:
The lens package defines (&) and (<&>) as flipped ($) and (<$>), respectively. There is nothing in the base package that defines those. <&> is quite uncommon. Flipped ($) is something that crops up here and there. Sometimes called (|>), or (#).
https://github.com/ghc/ghc/blob/master/libraries/base/Data/Function.hs
A the bottom.
-- /Since: 4.8.0.0/ (&) :: a -> (a -> b) -> b x & f = f x
I learned about it from #haskell channel.
-- Wojtek
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

W dniu 2014-12-12 o 14:22, Johan Tibell pisze:
Everything doesn't have to have an operator! We use operators a bit too much. It hurts readability of code when lines start looking like APL.
Don't blame me, I'm responsible for exactly 0 operators. I just informed Clinton where (&) can be found.

Everything doesn't have to have an operator! We use operators a bit too much. It hurts readability of code when lines start looking like APL. I agree. Furthermore I think '$' (and by extension '&') is dreadful. We should have gone with '<|' and '|>' like e.g. F#. It is a shame
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 12/12/14 14:22, Johan Tibell wrote: that we do not have mnemonic operators for something so common. - -- Alexander alexander@plaimi.net https://secure.plaimi.net/~alexander -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iF4EAREIAAYFAlSMN6UACgkQRtClrXBQc7XPNQD/fQTogXC9exfzaLkcknS9yycU GLSNTs6K1l8GpHrFiqoA/0hrXO3D/9RrsYQtJjmZTZc9Ki8gDnOBBGuMEV8lWGsq =in8B -----END PGP SIGNATURE-----

W dniu 2014-12-13 o 13:57, Alexander Berntsen pisze:
Everything doesn't have to have an operator! We use operators a bit too much. It hurts readability of code when lines start looking like APL. I agree. Furthermore I think '$' (and by extension '&') is dreadful. We should have gone with '<|' and '|>' like e.g. F#. It is a shame
On 12/12/14 14:22, Johan Tibell wrote: that we do not have mnemonic operators for something so common.
Oh, I also agree. I find the F# code laid out like: theThing |> op1 |> op2 |> op2 visually pleasing and self understandable. It's not too late, these two operators are not taken.

It's not too late, these two operators are not taken. This has been discussed previously, but rejected for fear of namespace
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 13/12/14 17:08, Wojciech Narczy?ski wrote: pollution. - -- Alexander alexander@plaimi.net https://secure.plaimi.net/~alexander -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iF4EAREIAAYFAlSMZQcACgkQRtClrXBQc7UbtAEAnVF0vLURDoZvM28c60QJwgPC TOjeZEEkMm6Rb5cEpocBAKsbwUq4/CFkNnNg5UXXp9AIUyPs9SqP9S/QCpA7ZECn =l1VB -----END PGP SIGNATURE-----

It all depends what "taken" means. Data.Sequence uses <| for cons and
|> for snoc. That may not have been the best decision, but it was made
a long time ago.
On Sat, Dec 13, 2014 at 11:08 AM, Wojciech Narczyński
W dniu 2014-12-13 o 13:57, Alexander Berntsen pisze:
On 12/12/14 14:22, Johan Tibell wrote:
Everything doesn't have to have an operator! We use operators a bit too much. It hurts readability of code when lines start looking like APL.
I agree. Furthermore I think '$' (and by extension '&') is dreadful. We should have gone with '<|' and '|>' like e.g. F#. It is a shame that we do not have mnemonic operators for something so common.
Oh, I also agree. I find the F# code laid out like:
theThing |> op1 |> op2 |> op2
visually pleasing and self understandable.
It's not too late, these two operators are not taken.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

There is (>>>) in Control.Arrow. It can be used for `flip ($)`.
2014-12-13 22:38 GMT+01:00 Wojtek Narczyński
On 13.12.2014 18:16, David Feuer wrote:
It all depends what "taken" means. Data.Sequence uses <| for cons and |> for snoc. That may not have been the best decision, but it was made a long time ago.
Oops, I certainly didn't mean that for "not taken"...
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

There is (>>>) in Control.Arrow. It can be used for `flip ($)`.
No, sorry. I was confusing it with flipped function composition.
2014-12-18 17:48 GMT+01:00 Johan Holmquist
There is (>>>) in Control.Arrow. It can be used for `flip ($)`.
2014-12-13 22:38 GMT+01:00 Wojtek Narczyński
: On 13.12.2014 18:16, David Feuer wrote:
It all depends what "taken" means. Data.Sequence uses <| for cons and |> for snoc. That may not have been the best decision, but it was made a long time ago.
Oops, I certainly didn't mean that for "not taken"...
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (9)
-
Alexander Berntsen
-
Clinton Mead
-
Dan Burton
-
David Feuer
-
Johan Holmquist
-
Johan Tibell
-
Tony Morris
-
Wojciech Narczyński
-
Wojtek Narczyński