Skip to content

Instantly share code, notes, and snippets.

@jutememo
Created October 14, 2009 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jutememo/209820 to your computer and use it in GitHub Desktop.
Save jutememo/209820 to your computer and use it in GitHub Desktop.
module Stack(Stack, empty, pop, push, s) where
newtype Stack a = Stack [a] deriving Show
empty :: Stack a
empty = Stack []
pop :: Stack a -> (a, Stack a)
pop (Stack (x:xs)) = (x, Stack xs)
push :: a -> Stack a -> Stack a
push x (Stack xs) = Stack (x:xs)
s = push 5 $ push 4 $ push 3 $ push 2 $ push 1 $ empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment