[Haskell-cafe] Desugaring of infix operators is (always?) the wrong way round

Ryan Ingram ryani.spam at gmail.com
Tue Sep 25 15:58:03 EDT 2007


My comments inlined below...

On 9/25/07, Brian Hulley <brianh at metamilk.com> wrote:
>   let
>        shiftLeftByThree = shiftL' 3
>   in
>       map shiftLeftByThree  [10, 78, 99, 102]

let shiftLeftByThree = (`shiftL` 3) in ...

> Can anyone think of an example where the current desugaring of infix
> arguments gives the correct order when the function is used in a postfix
> application? (apart from commutative functions of course!)

A couple off the top of my head:

(:) :: a -> [a] -> [a]

<|> :: MonadPlus m => m a -> m a -> m a
(how do you define "correct" in this case, anyways?)

Even for "shift" I can think of several reasons to want to use it both
ways; for example, unpacking a bitfield from a Word16:

unpack v = (getM 0 255, getM 8 1, getM 9 31, getM 14 3)
    where getM = (.&.) . (shiftR v)

  -- ryan


More information about the Haskell-Cafe mailing list