1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
import Control.Monad.State type Stack = [Int] pop :: State Stack Int pop = state $ \(x:xs) -> (x,xs) push :: Int -> State Stack () push a = state $ \xs -> ((), a:xs) stackManip :: State Stack Int stackManip = do push 3 pop pop