universum-0.7.1.1: Custom prelude used in Serokell

Safe HaskellTrustworthy
LanguageHaskell2010

List

Description

Utility functions to work with lists.

Synopsis

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.