module Stack(Stack,push,pop,isEmpty,empty,size) where

newtype Stack a = Stack [a] deriving (Eq, Show)

empty :: Stack a
empty = Stack []

push :: a -> Stack a -> Stack a
push x (Stack xs) = Stack (x : xs)

pop :: Stack a -> (a, Stack a)
pop (Stack (x : xs)) = (x, Stack xs)

isEmpty :: Stack a -> Bool
isEmpty (Stack xs) = null xs

size :: Stack a -> Int
size (Stack xs) = length xs