Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
Utility functions to work with lists.
- module Data.List
- list :: [b] -> (a -> b) -> [a] -> [b]
- sortWith :: Ord b => (a -> b) -> [a] -> [a]
- whenNotNull :: Applicative f => [a] -> (NonEmpty a -> f ()) -> f ()
- whenNotNullM :: Monad m => m [a] -> (NonEmpty a -> m ()) -> m ()
Documentation
module Data.List
list :: [b] -> (a -> b) -> [a] -> [b] Source #
Returns default list if given list is empty. Otherwise applies given function to every element.
>>>
list [True] even []
[True]>>>
list [True] even [1..5]
[False,True,False,True,False]
sortWith :: Ord b => (a -> b) -> [a] -> [a] #
The sortWith
function sorts a list of elements using the
user supplied function to project something out of each element
whenNotNull :: Applicative f => [a] -> (NonEmpty a -> f ()) -> f () Source #
Performs given action over NonEmpty
list if given list is non empty.
whenNotNullM :: Monad m => m [a] -> (NonEmpty a -> m ()) -> m () Source #
Monadic version of whenNotNull
.