
24 Nov
2012
24 Nov
'12
8:52 a.m.
Hey, I have an example function in the list monad. twoSucc :: Int -> [Int] twoSucc i = [i+1, i+2] Now I want write something similar with the StateT monad transformer. twoSucc :: StateT Int [] () twoSucc = do i <- get put (i+1) -- how do I put [i+1,i+2] here? As mentioned in the comment, when doing runStateT twoSucc n it outputs [((),n+1)] (which makes sense). How do I write it that it behaves similar to the original twoSucc and outputs [((),n+1),((),n+2)]? Thanks! Nathan