{-# LANGUAGE NoImplicitPrelude, MultiParamTypeClasses, FlexibleInstances #-}
{-# OPTIONS -fno-warn-orphans #-}
{-# LANGUAGE CPP #-}
module Data.ListLike.DList () where
import Data.ListLike.Base
import Data.ListLike.FoldableLL
import Data.ListLike.String
import Data.DList (DList)
import qualified Data.DList as D
import qualified Data.Foldable as F
import qualified Data.String as S
import Control.Category
import Data.Char (Char)
instance FoldableLL (DList a) a where
foldl :: (a -> a -> a) -> a -> DList a -> a
foldl = (a -> a -> a) -> a -> DList a -> a
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl
foldr :: (a -> b -> b) -> b -> DList a -> b
foldr = (a -> b -> b) -> b -> DList a -> b
forall a b. (a -> b -> b) -> b -> DList a -> b
D.foldr
foldl1 :: (a -> a -> a) -> DList a -> a
foldl1 = (a -> a -> a) -> DList a -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
F.foldl1
foldr1 :: (a -> a -> a) -> DList a -> a
foldr1 = (a -> a -> a) -> DList a -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
F.foldr1
foldl' :: (a -> a -> a) -> a -> DList a -> a
foldl' = (a -> a -> a) -> a -> DList a -> a
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
F.foldl'
foldr' :: (a -> b -> b) -> b -> DList a -> b
foldr' = (a -> b -> b) -> b -> DList a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
F.foldr'
instance ListLike (DList a) a where
empty :: DList a
empty = DList a
forall a. DList a
D.empty
singleton :: a -> DList a
singleton = a -> DList a
forall a. a -> DList a
D.singleton
cons :: a -> DList a -> DList a
cons = a -> DList a -> DList a
forall a. a -> DList a -> DList a
D.cons
snoc :: DList a -> a -> DList a
snoc = DList a -> a -> DList a
forall a. DList a -> a -> DList a
D.snoc
append :: DList a -> DList a -> DList a
append = DList a -> DList a -> DList a
forall a. DList a -> DList a -> DList a
D.append
head :: DList a -> a
head = DList a -> a
forall a. DList a -> a
D.head
#if MIN_VERSION_dlist(1,0,0)
tail :: DList a -> DList a
tail = [a] -> DList a
forall a. [a] -> DList a
D.fromList ([a] -> DList a) -> (DList a -> [a]) -> DList a -> DList a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. DList a -> [a]
forall a. DList a -> [a]
D.tail
#else
tail = D.tail
#endif
rigidMap :: (a -> a) -> DList a -> DList a
rigidMap = (a -> a) -> DList a -> DList a
forall a b. (a -> b) -> DList a -> DList b
D.map
null :: DList a -> Bool
null = [a] -> Bool
forall full item. ListLike full item => full -> Bool
null ([a] -> Bool) -> (DList a -> [a]) -> DList a -> Bool
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. DList a -> [a]
forall a. DList a -> [a]
D.toList
replicate :: Int -> a -> DList a
replicate = Int -> a -> DList a
forall a. Int -> a -> DList a
D.replicate
instance StringLike (DList Char) where
toString :: DList Char -> String
toString = DList Char -> String
forall a. DList a -> [a]
D.toList
lines :: DList Char -> full
lines = (String -> DList Char) -> [String] -> full
forall full item full' item'.
(ListLike full item, ListLike full' item') =>
(item -> item') -> full -> full'
map String -> DList Char
forall a. [a] -> DList a
D.fromList ([String] -> full)
-> (DList Char -> [String]) -> DList Char -> full
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> [String]
S.lines (String -> [String])
-> (DList Char -> String) -> DList Char -> [String]
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. DList Char -> String
forall a. DList a -> [a]
D.toList
words :: DList Char -> full
words = (String -> DList Char) -> [String] -> full
forall full item full' item'.
(ListLike full item, ListLike full' item') =>
(item -> item') -> full -> full'
map String -> DList Char
forall a. [a] -> DList a
D.fromList ([String] -> full)
-> (DList Char -> [String]) -> DList Char -> full
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> [String]
S.words (String -> [String])
-> (DList Char -> String) -> DList Char -> [String]
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. DList Char -> String
forall a. DList a -> [a]
D.toList
unlines :: full -> DList Char
unlines = String -> DList Char
forall a. [a] -> DList a
D.fromList (String -> DList Char) -> (full -> String) -> full -> DList Char
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [String] -> String
S.unlines ([String] -> String) -> (full -> [String]) -> full -> String
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (DList Char -> String) -> full -> [String]
forall full item full' item'.
(ListLike full item, ListLike full' item') =>
(item -> item') -> full -> full'
map DList Char -> String
forall a. DList a -> [a]
D.toList
unwords :: full -> DList Char
unwords = String -> DList Char
forall a. [a] -> DList a
D.fromList (String -> DList Char) -> (full -> String) -> full -> DList Char
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [String] -> String
S.unwords ([String] -> String) -> (full -> [String]) -> full -> String
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (DList Char -> String) -> full -> [String]
forall full item full' item'.
(ListLike full item, ListLike full' item') =>
(item -> item') -> full -> full'
map DList Char -> String
forall a. DList a -> [a]
D.toList