12 Oct
2009
12 Oct
'09
3:14 p.m.
minh thu
ghci> :t (>>=) (>>=) :: (Monad m) => m a -> (a -> m b) -> m b
This says that, you provide an a and you get a b. Nothing says the a and b have to be the same upon successive uses.
(But note that the monad 'm' has to be the same all the way. You can't switch from, say, IO to ST in the middle of the computation.)
Likewise,
Contrariwise, I'd say.
ghci> :t (+) (+) :: (Num a) => a -> a -> a
I.e. (+) requires the same type on both sides...
fromIntegral ((1 :: Int) + 2) + (3 :: Integer) 6
...but 'fromIntegral' converts it. Did I miss some subtle point here? -k -- If I haven't seen further, it is by standing in the footprints of giants