[Haskell-cafe] Proposal: new function for lifting

Marc Ziegert Coeus at gmx.de
Sun Sep 29 02:13:22 CEST 2013

this is a funny trick, and it looks saner than the more general <$> <*> combinators.
i see many situations where i could use that to lift my own combinators,
or to replace the backticks (``) to lift the infix function.

- marc

Gesendet: Freitag, 27. September 2013 um 21:51 Uhr
Von: "Thiago Negri" <evohunz at gmail.com>
An: Haskell-Cafe <haskell-cafe at haskell.org>
Betreff: [Haskell-cafe] Proposal: new function for lifting

Everybody is claiming that using lift is a bad thing.
So, I come to remedy this problem.

Stop lifting, start using shinny operators like this one:

    (^$) :: Monad m => m a -> (a -> b -> c) -> m b -> m c
    (^$) = flip liftM2
Then you can do wonderful stuff and you will never read the four-letter word in your code again:
    \> Just 42 ^$(+)$ Nothing
    \> Just 10 ^$(+)$ Just 20
    Just 30
    \> let add = (+)
    \> Just 30 ^$ add $ Just 12
    Just 42

More information about the Haskell-Cafe mailing list