
8 Apr
2009
8 Apr
'09
6:29 p.m.
Hello, I'm getting this error message from GHC in the following code:
type M a = Monad m => m a
class A a b where f :: Monad m => a -> m b
instance A String Char where f string = return $ head string
instance A Char Int where f int = return $ fromEnum int
I thought at first to write h like this, but it gives me the error. If I write it like the other h uncommented, there's no error. I can't see why they aren't equivalent. h :: IO () h = f "abc" >>= (f :: Char -> M Int) >>= print
h :: IO () h = (f "abc" :: M Char) >>= f >>= (print :: Int -> IO ())
Can someone clarify this to me? Greetings. -- marcot http://marcot.iaaeee.org/