Last active
August 29, 2015 13:57
-
-
Save echaozh/9349531 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE PackageImports, UnicodeSyntax #-} | |
import "mtl" Control.Monad.State | |
type Stack a b = State [a] b | |
push ∷ a → Stack a () | |
push a = modify (a:) | |
pop ∷ Stack a a | |
pop = do | |
a : as ← get | |
put as | |
return a | |
testStack ∷ Stack Int String | |
testStack = do | |
push 1 | |
push 2 | |
push 3 | |
pop | |
return "I am not a stack builder!" | |
main = print $ execState testStack [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment