[Haskell-cafe] flipped IO sequence
Luke Palmer
lrpalmer at gmail.com
Wed Oct 1 20:01:29 EDT 2008
2008/10/1 Cetin Sert <cetin.sert at gmail.com>:
> warn :: String → IO Int
> warn = return 1 << putStrLn -- causes an error
> -- = \msg → return 1 << putStrLn msg -- works just fine
> -- = \msg → putStrLn msg >> return 1 -- works just fine
>
> (<<) :: Monad m ⇒ m b → m a → m b
> b << a = a >>= \_ → b
>
> Why do I get this compile-time error?? How can one define << ?
While this isn't directly what you're doing, you might be interested
in the Kleisli composition operators in Control.Monad:
(>=>) :: (Monad m) => (a -> m b) -> (b -> m c) -> (a -> m c)
(<=<) :: (Mnoad m) => (b -> m c) -> (a -> m b) -> (a -> m c)
Luke
More information about the Haskell-Cafe
mailing list