
1 Oct
2008
1 Oct
'08
8:01 p.m.
2008/10/1 Cetin Sert
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