module Data.DoList
( DoList (DoList)
, item
, unDoList
, fromList
, toList
) where
import qualified Data.DList as D
newtype DoList a r = DoList (D.DList a)
deriving (Eq, Ord, Read, Show)
unDoList :: DoList a r -> D.DList a
unDoList (DoList x) = x
instance Functor (DoList a) where
fmap = notSupported "fmap"
instance Applicative (DoList a) where
pure = notSupported "pure"
(<*>) = notSupported "(<*>)"
instance Monad (DoList a) where
(>>=) = notSupported "(>>=)"
(>>) (DoList x) = DoList . D.append x . unDoList
item :: a -> DoList a r
item = DoList . D.singleton
fromList :: [a] -> DoList a r
fromList = DoList . D.fromList
toList :: DoList a r -> [a]
toList = D.toList . unDoList
notSupported :: String -> a
notSupported func = error $ "DoList " ++ func ++ " is not supported!"