Lets assume I have a type class Stack with one instance List:
class Stack a where
push :: a -> Integer -> a
pop :: a -> a
last :: a -> Integer
data List = Empty | Element Integer List
instance Stack List where
push list value = Element value list
pop Empty = error "No elements"
pop (Element _ list) = list
last Empty = error "No elements"
last (Element value _) = value
How Stack has to be defined in order for List to not be limited to Integer values?
-- class Stack (?) where ...
data List a = Empty | Element a (List a)
-- instance Show (List a) where ...