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 suffix list =
fmap reverse (stripPrefix (reverse suffix) (reverse list))
dropPrefix :: Eq a
=> [a]
-> [a]
-> [a]
dropPrefix prefix t = fromMaybe t (stripPrefix prefix t)
dropSuffix :: Eq a
=> [a]
-> [a]
-> [a]
dropSuffix suffix t = fromMaybe t (stripSuffix suffix t)
linesCR :: String -> [String]
linesCR = map (dropSuffix "\r") . lines
safeListCall :: Foldable t => (t a -> b) -> t a -> Maybe b
safeListCall f xs
| Data.List.null xs = Nothing
| otherwise = Just $ f xs
headMaybe :: [a] -> Maybe a
headMaybe = safeListCall Data.List.head
lastMaybe :: [a] -> Maybe a
lastMaybe = safeListCall Data.List.last
tailMaybe :: [a] -> Maybe [a]
tailMaybe = safeListCall Data.List.tail
initMaybe :: [a] -> Maybe [a]
initMaybe = safeListCall Data.List.init
maximumMaybe :: (Ord a, Foldable t) => t a -> Maybe a
maximumMaybe = safeListCall Data.List.maximum
minimumMaybe :: (Ord a, Foldable t) => t a -> Maybe a
minimumMaybe = safeListCall Data.List.minimum
maximumByMaybe :: (Foldable t) => (a -> a -> Ordering) -> t a -> Maybe a
maximumByMaybe f = safeListCall (Data.List.maximumBy f)
minimumByMaybe :: (Foldable t) => (a -> a -> Ordering) -> t a -> Maybe a
minimumByMaybe f = safeListCall (Data.List.minimumBy f)