class STACK a where { type StackRepr a elem; emptyStack :: a -> StackRepr a elem; top :: a -> StackRepr a elem -> elem; pop :: a -> StackRepr a elem -> StackRepr a elem; push :: a -> elem -> StackRepr a elem -> StackRepr a elem; } data Stack = Stack; instance STACK Stack where { type StackRepr Stack elem = List elem; emptyStack _ = Nil; top _ (Cons x xs) = x; pop _ (Cons x xs) = xs; push _ x xs = Cons x xs; }