8
data Stack a = Empty | Stack a :< a
11
instance Monoid (Stack a) where
14
mappend xs (ys :< y) = mappend xs ys :< y
16
(+<) :: Stack a -> Stack a -> Stack a
19
toList :: Stack a -> [a]
20
toList = reverse . list where
21
list (xs :< x) = x : list xs
24
fromList :: [a] -> Stack a
25
fromList = foldl (:<) Empty
27
instance Show a => Show (Stack a) where