module Distribution.Compat.DList (
DList,
runDList,
singleton,
fromList,
toList,
snoc,
) where
import Prelude ()
import Distribution.Compat.Prelude
newtype DList a = DList ([a] -> [a])
runDList :: DList a -> [a]
runDList (DList run) = run []
singleton :: a -> DList a
singleton a = DList (a:)
fromList :: [a] -> DList a
fromList as = DList (as ++)
toList :: DList a -> [a]
toList = runDList
snoc :: DList a -> a -> DList a
snoc xs x = xs <> singleton x
instance Monoid (DList a) where
mempty = DList id
mappend = (<>)
instance Semigroup (DList a) where
DList a <> DList b = DList (a . b)