
On Tue, Nov 30, 2010 at 12:08 PM, Larry Evans
so now I must "manually" figure out what the a and b in the ap declaration correspond to in the return(:) type:
m ( a -> b ) __ _ _ 1: [] Char -> [Char]->[Char] 2: [] Char->[Char] -> [Char]
A type a -> b -> c is always equivalent to the type a -> (b->c), not (a->b)
-> c. In particular, breaking down sequence (c:cs) = return (:) `ap` c `ap` sequence cs return (:) :: m (a -> [a] ->[a]) (\c -> return (:) `ap` c) :: m a -> m ([a] -> [a]) (\c cs' -> return (:) `ap` c `ap` cs') :: m a -> m [a] -> m [a] therefore sequence :: [ m a ] -> m [a] Perhaps a special tutorial interpreter would be of use, but I've had some success simply passing in anonymous functions to ghci's :t operator, since that lets me simplify a program one bit at a time, inferring the types that might confuse me.