
27 May
2009
27 May
'09
11:22 p.m.
On Thu, May 28, 2009 at 10:33 AM, michael rice
Still exploring monads. I don't understand why the type signature for double is OK, but not the one for iota.
Michael
=================
--double :: (Int a) => a -> Maybe b --double x = Just (x + x)
Prelude> let double x = Just $ x + x Prelude> Just 2 >>= double Just 4 You can define double as double x = return $ x + x Prelude> let double x = return $ x + x Prelude> Just 2 >>= double Just 4
iota :: (Int a) => a -> [b] iota n = [1..n]
--usage: [3,4,5] >>= iota --should produce [1,2,3,1,2,3,4,1,2,3,4,5]
I did. Prelude> let iota n = [1..n] Prelude> [3,4,5] >>= iota [1,2,3,1,2,3,4,1,2,3,4,5] lee