Implement new `-fwarn-noncanonical-monad-instances`
[ghc.git] / utils / mkUserGuidePart / DList.hs
1 module DList where
2
3 newtype DList a = DList ([a] -> [a])
4
5 snoc :: DList a -> a -> DList a
6 DList f `snoc` x = DList (f . (x:))
7
8 toList :: DList a -> [a]
9 toList (DList f) = f []
10
11 instance Monoid (DList a) where
12 mempty = DList id
13 DList a `mappend` DList b = DList (a . b)