
23 Sep
2009
23 Sep
'09
6:03 p.m.
Trying to understand Douglas Auclair's article "MonadPlus - What a super monad!" here http://www.haskell.org/sitewiki/images/6/6a/TMR-Issue11.pdf Defines splits :: Eq a => [a] -> [(a,[a])] splits list = do x <- list return (x, delete x list) choose :: Eq a => StateT [a] [] a choose = StateT (\s -> splits s) I'm trying to understand what "StateT [a] [] a" means: I wrote t1 :: StateT [Int] [] [Int] t1 = do s <- get return s That compiles. Then I tried to write t2 :: StateT [Int] [] [Int] t2 = do x <- [1,2,3] s <- get return (x:s) I thought this would be fine because [1,2,3] is an example of a list monad. But I get "Can't match expected type StateT [Int] [] t against inferred type [a]"