module RIO.List
(
(Data.List.++)
, Data.List.uncons
, Data.List.null
, Data.List.length
, headMaybe
, lastMaybe
, tailMaybe
, initMaybe
, Data.List.map
, Data.List.reverse
, Data.List.intersperse
, Data.List.intercalate
, Data.List.transpose
, Data.List.subsequences
, Data.List.permutations
, Data.List.foldl
, Data.List.foldl'
, Data.List.foldr
, Data.List.concat
, Data.List.concatMap
, Data.List.and
, Data.List.or
, Data.List.any
, Data.List.all
, Data.List.sum
, Data.List.product
, maximumMaybe
, minimumMaybe
, maximumByMaybe
, minimumByMaybe
, Data.List.scanl
, Data.List.scanl'
, Data.List.scanr
, Data.List.scanl1
, Data.List.scanr1
, Data.List.mapAccumL
, Data.List.mapAccumR
, Data.List.iterate
, Data.List.repeat
, Data.List.replicate
, Data.List.cycle
, Data.List.unfoldr
, Data.List.take
, Data.List.drop
, Data.List.splitAt
, Data.List.takeWhile
, Data.List.dropWhile
, Data.List.dropWhileEnd
, Data.List.span
, Data.List.break
, Data.List.stripPrefix
, stripSuffix
, dropPrefix
, dropSuffix
, Data.List.group
, Data.List.inits
, Data.List.tails
, Data.List.isPrefixOf
, Data.List.isSuffixOf
, Data.List.isInfixOf
, Data.List.isSubsequenceOf
, Data.List.elem
, Data.List.notElem
, Data.List.lookup
, Data.List.find
, Data.List.filter
, Data.List.partition
, Data.List.elemIndex
, Data.List.elemIndices
, Data.List.findIndex
, Data.List.findIndices
, Data.List.zip
, Data.List.zip3
, Data.List.zip4
, Data.List.zip5
, Data.List.zip6
, Data.List.zip7
, Data.List.zipWith
, Data.List.zipWith3
, Data.List.zipWith4
, Data.List.zipWith5
, Data.List.zipWith6
, Data.List.zipWith7
, Data.List.unzip
, Data.List.unzip3
, Data.List.unzip4
, Data.List.unzip5
, Data.List.unzip6
, Data.List.unzip7
, Data.List.lines
, linesCR
, Data.List.words
, Data.List.unlines
, Data.List.unwords
, Data.List.nub
, Data.List.delete
, (Data.List.\\)
, Data.List.union
, Data.List.intersect
, Data.List.sort
, Data.List.sortOn
, Data.List.insert
, Data.List.nubBy
, Data.List.deleteBy
, Data.List.deleteFirstsBy
, Data.List.unionBy
, Data.List.intersectBy
, Data.List.groupBy
, Data.List.sortBy
, Data.List.insertBy
, Data.List.genericLength
, Data.List.genericTake
, Data.List.genericDrop
, Data.List.genericSplitAt
, Data.List.genericIndex
, Data.List.genericReplicate
) where
import qualified Data.List
import Data.List(stripPrefix)
import Data.Maybe (fromMaybe)
stripSuffix :: Eq a
=> [a]
-> [a]
-> Maybe [a]
stripSuffix :: [a] -> [a] -> Maybe [a]
stripSuffix [a]
suffix [a]
list =
([a] -> [a]) -> Maybe [a] -> Maybe [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [a] -> [a]
forall a. [a] -> [a]
reverse ([a] -> [a] -> Maybe [a]
forall a. Eq a => [a] -> [a] -> Maybe [a]
stripPrefix ([a] -> [a]
forall a. [a] -> [a]
reverse [a]
suffix) ([a] -> [a]
forall a. [a] -> [a]
reverse [a]
list))
dropPrefix :: Eq a
=> [a]
-> [a]
-> [a]
dropPrefix :: [a] -> [a] -> [a]
dropPrefix [a]
prefix [a]
t = [a] -> Maybe [a] -> [a]
forall a. a -> Maybe a -> a
fromMaybe [a]
t ([a] -> [a] -> Maybe [a]
forall a. Eq a => [a] -> [a] -> Maybe [a]
stripPrefix [a]
prefix [a]
t)
dropSuffix :: Eq a
=> [a]
-> [a]
-> [a]
dropSuffix :: [a] -> [a] -> [a]
dropSuffix [a]
suffix [a]
t = [a] -> Maybe [a] -> [a]
forall a. a -> Maybe a -> a
fromMaybe [a]
t ([a] -> [a] -> Maybe [a]
forall a. Eq a => [a] -> [a] -> Maybe [a]
stripSuffix [a]
suffix [a]
t)
linesCR :: String -> [String]
linesCR :: String -> [String]
linesCR = (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String -> String -> String
forall a. Eq a => [a] -> [a] -> [a]
dropSuffix String
"\r") ([String] -> [String])
-> (String -> [String]) -> String -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String]
lines
safeListCall :: Foldable t => (t a -> b) -> t a -> Maybe b
safeListCall :: (t a -> b) -> t a -> Maybe b
safeListCall t a -> b
f t a
xs
| t a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
Data.List.null t a
xs = Maybe b
forall a. Maybe a
Nothing
| Bool
otherwise = b -> Maybe b
forall a. a -> Maybe a
Just (b -> Maybe b) -> b -> Maybe b
forall a b. (a -> b) -> a -> b
$ t a -> b
f t a
xs
headMaybe :: [a] -> Maybe a
headMaybe :: [a] -> Maybe a
headMaybe = ([a] -> a) -> [a] -> Maybe a
forall (t :: * -> *) a b.
Foldable t =>
(t a -> b) -> t a -> Maybe b
safeListCall [a] -> a
forall a. [a] -> a
Data.List.head
lastMaybe :: [a] -> Maybe a
lastMaybe :: [a] -> Maybe a
lastMaybe = ([a] -> a) -> [a] -> Maybe a
forall (t :: * -> *) a b.
Foldable t =>
(t a -> b) -> t a -> Maybe b
safeListCall [a] -> a
forall a. [a] -> a
Data.List.last
tailMaybe :: [a] -> Maybe [a]
tailMaybe :: [a] -> Maybe [a]
tailMaybe = ([a] -> [a]) -> [a] -> Maybe [a]
forall (t :: * -> *) a b.
Foldable t =>
(t a -> b) -> t a -> Maybe b
safeListCall [a] -> [a]
forall a. [a] -> [a]
Data.List.tail
initMaybe :: [a] -> Maybe [a]
initMaybe :: [a] -> Maybe [a]
initMaybe = ([a] -> [a]) -> [a] -> Maybe [a]
forall (t :: * -> *) a b.
Foldable t =>
(t a -> b) -> t a -> Maybe b
safeListCall [a] -> [a]
forall a. [a] -> [a]
Data.List.init
maximumMaybe :: (Ord a, Foldable t) => t a -> Maybe a
maximumMaybe :: t a -> Maybe a
maximumMaybe = (t a -> a) -> t a -> Maybe a
forall (t :: * -> *) a b.
Foldable t =>
(t a -> b) -> t a -> Maybe b
safeListCall t a -> a
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
Data.List.maximum
minimumMaybe :: (Ord a, Foldable t) => t a -> Maybe a
minimumMaybe :: t a -> Maybe a
minimumMaybe = (t a -> a) -> t a -> Maybe a
forall (t :: * -> *) a b.
Foldable t =>
(t a -> b) -> t a -> Maybe b
safeListCall t a -> a
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
Data.List.minimum
maximumByMaybe :: (Foldable t) => (a -> a -> Ordering) -> t a -> Maybe a
maximumByMaybe :: (a -> a -> Ordering) -> t a -> Maybe a
maximumByMaybe a -> a -> Ordering
f = (t a -> a) -> t a -> Maybe a
forall (t :: * -> *) a b.
Foldable t =>
(t a -> b) -> t a -> Maybe b
safeListCall ((a -> a -> Ordering) -> t a -> a
forall (t :: * -> *) a.
Foldable t =>
(a -> a -> Ordering) -> t a -> a
Data.List.maximumBy a -> a -> Ordering
f)
minimumByMaybe :: (Foldable t) => (a -> a -> Ordering) -> t a -> Maybe a
minimumByMaybe :: (a -> a -> Ordering) -> t a -> Maybe a
minimumByMaybe a -> a -> Ordering
f = (t a -> a) -> t a -> Maybe a
forall (t :: * -> *) a b.
Foldable t =>
(t a -> b) -> t a -> Maybe b
safeListCall ((a -> a -> Ordering) -> t a -> a
forall (t :: * -> *) a.
Foldable t =>
(a -> a -> Ordering) -> t a -> a
Data.List.minimumBy a -> a -> Ordering
f)