5.7. Pop is more complex

You probably noticed that pop is a little more complex than the other functions. It has two implementations, one for empty lists and one for non empty lists. Haskell will know the correct version of the function to call at runtime.

pop (MakeStack (h:t)) = (h, MakeStack t)
pop (MakeStack []) = error "Attempt to pop an empty stack."

Popping something from an empty list is an error, so our Stack module yells at you if you try to do so. Better use isEmpty to check if its empty first.