listsafe-0.1.0.1: Safe wrappers for partial list functions, supporting MonadThrow.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.List.Safe

Description

Operations on lists. This module re-exports all safe functions of List, but wraps all partial functions which may fail. As such, this module can be imported instead of Data.List.

Partial functions are wrapped into the MonadThrow-monad from Control.Monad.Catch and as such, have appropriate failure cases for all instances. E.g.:

  • Nothing for Maybe,
  • the empty list for '[a]',
  • IOException for IO,
  • lifted exceptions for monad transformers.
Synopsis
  • group :: Eq a => [a] -> [[a]]
  • data List a
  • all :: Foldable t => (a -> Bool) -> t a -> Bool
  • and :: Foldable t => t Bool -> Bool
  • any :: Foldable t => (a -> Bool) -> t a -> Bool
  • concat :: Foldable t => t [a] -> [a]
  • concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
  • notElem :: (Foldable t, Eq a) => a -> t a -> Bool
  • or :: Foldable t => t Bool -> Bool
  • lines :: String -> [String]
  • unlines :: [String] -> String
  • unwords :: [String] -> String
  • words :: String -> [String]
  • break :: (a -> Bool) -> [a] -> ([a], [a])
  • cycle :: HasCallStack => [a] -> [a]
  • drop :: Int -> [a] -> [a]
  • dropWhile :: (a -> Bool) -> [a] -> [a]
  • iterate :: (a -> a) -> a -> [a]
  • lookup :: Eq a => a -> [(a, b)] -> Maybe b
  • repeat :: a -> [a]
  • replicate :: Int -> a -> [a]
  • reverse :: [a] -> [a]
  • scanl :: (b -> a -> b) -> b -> [a] -> [b]
  • scanl1 :: (a -> a -> a) -> [a] -> [a]
  • scanr :: (a -> b -> b) -> b -> [a] -> [b]
  • scanr1 :: (a -> a -> a) -> [a] -> [a]
  • span :: (a -> Bool) -> [a] -> ([a], [a])
  • splitAt :: Int -> [a] -> ([a], [a])
  • take :: Int -> [a] -> [a]
  • takeWhile :: (a -> Bool) -> [a] -> [a]
  • unzip :: [(a, b)] -> ([a], [b])
  • unzip3 :: [(a, b, c)] -> ([a], [b], [c])
  • zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]
  • zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
  • zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
  • elem :: (Foldable t, Eq a) => a -> t a -> Bool
  • foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b
  • foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> b
  • foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b
  • length :: Foldable t => t a -> Int
  • null :: Foldable t => t a -> Bool
  • product :: (Foldable t, Num a) => t a -> a
  • sum :: (Foldable t, Num a) => t a -> a
  • (++) :: [a] -> [a] -> [a]
  • map :: (a -> b) -> [a] -> [b]
  • zip :: [a] -> [b] -> [(a, b)]
  • filter :: (a -> Bool) -> [a] -> [a]
  • find :: Foldable t => (a -> Bool) -> t a -> Maybe a
  • isSubsequenceOf :: Eq a => [a] -> [a] -> Bool
  • (\\) :: Eq a => [a] -> [a] -> [a]
  • delete :: Eq a => a -> [a] -> [a]
  • deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]
  • deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
  • dropWhileEnd :: (a -> Bool) -> [a] -> [a]
  • elemIndex :: Eq a => a -> [a] -> Maybe Int
  • elemIndices :: Eq a => a -> [a] -> [Int]
  • findIndex :: (a -> Bool) -> [a] -> Maybe Int
  • findIndices :: (a -> Bool) -> [a] -> [Int]
  • genericDrop :: Integral i => i -> [a] -> [a]
  • genericIndex :: Integral i => [a] -> i -> a
  • genericLength :: Num i => [a] -> i
  • genericReplicate :: Integral i => i -> a -> [a]
  • genericSplitAt :: Integral i => i -> [a] -> ([a], [a])
  • genericTake :: Integral i => i -> [a] -> [a]
  • groupBy :: (a -> a -> Bool) -> [a] -> [[a]]
  • inits :: [a] -> [[a]]
  • insert :: Ord a => a -> [a] -> [a]
  • insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]
  • intercalate :: [a] -> [[a]] -> [a]
  • intersect :: Eq a => [a] -> [a] -> [a]
  • intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
  • intersperse :: a -> [a] -> [a]
  • isInfixOf :: Eq a => [a] -> [a] -> Bool
  • isPrefixOf :: Eq a => [a] -> [a] -> Bool
  • isSuffixOf :: Eq a => [a] -> [a] -> Bool
  • nub :: Eq a => [a] -> [a]
  • nubBy :: (a -> a -> Bool) -> [a] -> [a]
  • partition :: (a -> Bool) -> [a] -> ([a], [a])
  • permutations :: [a] -> [[a]]
  • singleton :: a -> [a]
  • sort :: Ord a => [a] -> [a]
  • sortBy :: (a -> a -> Ordering) -> [a] -> [a]
  • sortOn :: Ord b => (a -> b) -> [a] -> [a]
  • stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]
  • subsequences :: [a] -> [[a]]
  • tails :: [a] -> [[a]]
  • transpose :: [[a]] -> [[a]]
  • unfoldr :: (b -> Maybe (a, b)) -> b -> [a]
  • union :: Eq a => [a] -> [a] -> [a]
  • unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
  • unzip4 :: [(a, b, c, d)] -> ([a], [b], [c], [d])
  • unzip5 :: [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e])
  • unzip6 :: [(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f])
  • unzip7 :: [(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g])
  • zip4 :: [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)]
  • zip5 :: [a] -> [b] -> [c] -> [d] -> [e] -> [(a, b, c, d, e)]
  • zip6 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [(a, b, c, d, e, f)]
  • zip7 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [(a, b, c, d, e, f, g)]
  • zipWith4 :: (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]
  • zipWith5 :: (a -> b -> c -> d -> e -> f) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f]
  • zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g]
  • zipWith7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h]
  • mapAccumL :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)
  • mapAccumR :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b)
  • (!?) :: [a] -> Int -> Maybe a
  • iterate' :: (a -> a) -> a -> [a]
  • scanl' :: (b -> a -> b) -> b -> [a] -> [b]
  • uncons :: [a] -> Maybe (a, [a])
  • unsnoc :: [a] -> Maybe ([a], a)
  • head :: MonadThrow m => [a] -> m a
  • last :: MonadThrow m => [a] -> m a
  • tail :: MonadThrow m => [a] -> m [a]
  • init :: MonadThrow m => [a] -> m [a]
  • foldl1 :: MonadThrow m => (a -> a -> a) -> [a] -> m a
  • foldl1' :: MonadThrow m => (a -> a -> a) -> [a] -> m a
  • foldr1 :: MonadThrow m => (a -> a -> a) -> [a] -> m a
  • maximum :: (MonadThrow m, Ord a) => [a] -> m a
  • minimum :: (MonadThrow m, Ord a) => [a] -> m a
  • maximumBy :: MonadThrow m => (a -> a -> Ordering) -> [a] -> m a
  • minimumBy :: MonadThrow m => (a -> a -> Ordering) -> [a] -> m a
  • (!!) :: (MonadThrow m, Integral n) => [a] -> n -> m a
  • wrap :: MonadThrow m => ([a] -> b) -> [a] -> m b
  • data EmptyListException = EmptyListException
  • data NegativeIndexException = NegativeIndexException

Documentation

group :: Eq a => [a] -> [[a]] #

data List a #

Instances

Instances details
MonadZip [] 
Instance details

Defined in Control.Monad.Zip

Methods

mzip :: [a] -> [b] -> [(a, b)]

mzipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

munzip :: [(a, b)] -> ([a], [b])

Eq1 [] 
Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a -> b -> Bool) -> [a] -> [b] -> Bool

Ord1 [] 
Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a -> b -> Ordering) -> [a] -> [b] -> Ordering

Read1 [] 
Instance details

Defined in Data.Functor.Classes

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS [a]

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [[a]]

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [a]

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [[a]]

Show1 [] 
Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> [a] -> ShowS

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [[a]] -> ShowS

MonadThrow [] 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> [a]

Alternative [] 
Instance details

Defined in GHC.Internal.Base

Methods

empty :: [a]

(<|>) :: [a] -> [a] -> [a]

some :: [a] -> [[a]]

many :: [a] -> [[a]]

Applicative [] 
Instance details

Defined in GHC.Internal.Base

Methods

pure :: a -> [a]

(<*>) :: [a -> b] -> [a] -> [b]

liftA2 :: (a -> b -> c) -> [a] -> [b] -> [c]

(*>) :: [a] -> [b] -> [b]

(<*) :: [a] -> [b] -> [a]

Functor [] 
Instance details

Defined in GHC.Internal.Base

Methods

fmap :: (a -> b) -> [a] -> [b]

(<$) :: a -> [b] -> [a]

Monad [] 
Instance details

Defined in GHC.Internal.Base

Methods

(>>=) :: [a] -> (a -> [b]) -> [b]

(>>) :: [a] -> [b] -> [b]

return :: a -> [a]

MonadPlus [] 
Instance details

Defined in GHC.Internal.Base

Methods

mzero :: [a]

mplus :: [a] -> [a] -> [a]

Foldable [] 
Instance details

Defined in GHC.Internal.Data.Foldable

Methods

fold :: Monoid m => [m] -> m

foldMap :: Monoid m => (a -> m) -> [a] -> m

foldMap' :: Monoid m => (a -> m) -> [a] -> m

foldr :: (a -> b -> b) -> b -> [a] -> b #

foldr' :: (a -> b -> b) -> b -> [a] -> b

foldl :: (b -> a -> b) -> b -> [a] -> b #

foldl' :: (b -> a -> b) -> b -> [a] -> b #

foldr1 :: (a -> a -> a) -> [a] -> a

foldl1 :: (a -> a -> a) -> [a] -> a

toList :: [a] -> [a]

null :: [a] -> Bool #

length :: [a] -> Int #

elem :: Eq a => a -> [a] -> Bool #

maximum :: Ord a => [a] -> a

minimum :: Ord a => [a] -> a

sum :: Num a => [a] -> a #

product :: Num a => [a] -> a #

Traversable [] 
Instance details

Defined in GHC.Internal.Data.Traversable

Methods

traverse :: Applicative f => (a -> f b) -> [a] -> f [b]

sequenceA :: Applicative f => [f a] -> f [a]

mapM :: Monad m => (a -> m b) -> [a] -> m [b]

sequence :: Monad m => [m a] -> m [a]

IsChar c => PrintfArg [c] 
Instance details

Defined in Text.Printf

Methods

formatArg :: [c] -> FieldFormatter

parseFormat :: [c] -> ModifierParser

IsChar c => PrintfType [c] 
Instance details

Defined in Text.Printf

Methods

spr :: String -> [UPrintf] -> [c]

Monoid [a] 
Instance details

Defined in GHC.Internal.Base

Methods

mempty :: [a]

mappend :: [a] -> [a] -> [a]

mconcat :: [[a]] -> [a]

Semigroup [a] 
Instance details

Defined in GHC.Internal.Base

Methods

(<>) :: [a] -> [a] -> [a]

sconcat :: NonEmpty [a] -> [a]

stimes :: Integral b => b -> [a] -> [a]

Read a => Read [a] 
Instance details

Defined in GHC.Internal.Read

Methods

readsPrec :: Int -> ReadS [a]

readList :: ReadS [[a]]

readPrec :: ReadPrec [a]

readListPrec :: ReadPrec [[a]]

Show a => Show [a] 
Instance details

Defined in GHC.Internal.Show

Methods

showsPrec :: Int -> [a] -> ShowS

show :: [a] -> String

showList :: [[a]] -> ShowS

Eq a => Eq [a] 
Instance details

Defined in GHC.Classes

Methods

(==) :: [a] -> [a] -> Bool

(/=) :: [a] -> [a] -> Bool

Ord a => Ord [a] 
Instance details

Defined in GHC.Classes

Methods

compare :: [a] -> [a] -> Ordering

(<) :: [a] -> [a] -> Bool

(<=) :: [a] -> [a] -> Bool

(>) :: [a] -> [a] -> Bool

(>=) :: [a] -> [a] -> Bool

max :: [a] -> [a] -> [a]

min :: [a] -> [a] -> [a]

all :: Foldable t => (a -> Bool) -> t a -> Bool #

and :: Foldable t => t Bool -> Bool #

any :: Foldable t => (a -> Bool) -> t a -> Bool #

concat :: Foldable t => t [a] -> [a] #

concatMap :: Foldable t => (a -> [b]) -> t a -> [b] #

notElem :: (Foldable t, Eq a) => a -> t a -> Bool #

or :: Foldable t => t Bool -> Bool #

lines :: String -> [String] #

unlines :: [String] -> String #

unwords :: [String] -> String #

words :: String -> [String] #

break :: (a -> Bool) -> [a] -> ([a], [a]) #

cycle :: HasCallStack => [a] -> [a] #

drop :: Int -> [a] -> [a] #

dropWhile :: (a -> Bool) -> [a] -> [a] #

iterate :: (a -> a) -> a -> [a] #

lookup :: Eq a => a -> [(a, b)] -> Maybe b #

repeat :: a -> [a] #

replicate :: Int -> a -> [a] #

reverse :: [a] -> [a] #

scanl :: (b -> a -> b) -> b -> [a] -> [b] #

scanl1 :: (a -> a -> a) -> [a] -> [a] #

scanr :: (a -> b -> b) -> b -> [a] -> [b] #

scanr1 :: (a -> a -> a) -> [a] -> [a] #

span :: (a -> Bool) -> [a] -> ([a], [a]) #

splitAt :: Int -> [a] -> ([a], [a]) #

take :: Int -> [a] -> [a] #

takeWhile :: (a -> Bool) -> [a] -> [a] #

unzip :: [(a, b)] -> ([a], [b]) #

unzip3 :: [(a, b, c)] -> ([a], [b], [c]) #

zip3 :: [a] -> [b] -> [c] -> [(a, b, c)] #

zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] #

zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d] #

elem :: (Foldable t, Eq a) => a -> t a -> Bool #

foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b #

foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> b #

foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b #

length :: Foldable t => t a -> Int #

null :: Foldable t => t a -> Bool #

product :: (Foldable t, Num a) => t a -> a #

sum :: (Foldable t, Num a) => t a -> a #

(++) :: [a] -> [a] -> [a] #

map :: (a -> b) -> [a] -> [b] #

zip :: [a] -> [b] -> [(a, b)] #

filter :: (a -> Bool) -> [a] -> [a] #

find :: Foldable t => (a -> Bool) -> t a -> Maybe a #

isSubsequenceOf :: Eq a => [a] -> [a] -> Bool #

(\\) :: Eq a => [a] -> [a] -> [a] #

delete :: Eq a => a -> [a] -> [a] #

deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a] #

deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a] #

dropWhileEnd :: (a -> Bool) -> [a] -> [a] #

elemIndex :: Eq a => a -> [a] -> Maybe Int #

elemIndices :: Eq a => a -> [a] -> [Int] #

findIndex :: (a -> Bool) -> [a] -> Maybe Int #

findIndices :: (a -> Bool) -> [a] -> [Int] #

genericDrop :: Integral i => i -> [a] -> [a] #

genericIndex :: Integral i => [a] -> i -> a #

genericLength :: Num i => [a] -> i #

genericReplicate :: Integral i => i -> a -> [a] #

genericSplitAt :: Integral i => i -> [a] -> ([a], [a]) #

genericTake :: Integral i => i -> [a] -> [a] #

groupBy :: (a -> a -> Bool) -> [a] -> [[a]] #

inits :: [a] -> [[a]] #

insert :: Ord a => a -> [a] -> [a] #

insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a] #

intercalate :: [a] -> [[a]] -> [a] #

intersect :: Eq a => [a] -> [a] -> [a] #

intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a] #

intersperse :: a -> [a] -> [a] #

isInfixOf :: Eq a => [a] -> [a] -> Bool #

isPrefixOf :: Eq a => [a] -> [a] -> Bool #

isSuffixOf :: Eq a => [a] -> [a] -> Bool #

nub :: Eq a => [a] -> [a] #

nubBy :: (a -> a -> Bool) -> [a] -> [a] #

partition :: (a -> Bool) -> [a] -> ([a], [a]) #

permutations :: [a] -> [[a]] #

singleton :: a -> [a] #

sort :: Ord a => [a] -> [a] #

sortBy :: (a -> a -> Ordering) -> [a] -> [a] #

sortOn :: Ord b => (a -> b) -> [a] -> [a] #

stripPrefix :: Eq a => [a] -> [a] -> Maybe [a] #

subsequences :: [a] -> [[a]] #

tails :: [a] -> [[a]] #

transpose :: [[a]] -> [[a]] #

unfoldr :: (b -> Maybe (a, b)) -> b -> [a] #

union :: Eq a => [a] -> [a] -> [a] #

unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a] #

unzip4 :: [(a, b, c, d)] -> ([a], [b], [c], [d]) #

unzip5 :: [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e]) #

unzip6 :: [(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f]) #

unzip7 :: [(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g]) #

zip4 :: [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)] #

zip5 :: [a] -> [b] -> [c] -> [d] -> [e] -> [(a, b, c, d, e)] #

zip6 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [(a, b, c, d, e, f)] #

zip7 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [(a, b, c, d, e, f, g)] #

zipWith4 :: (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e] #

zipWith5 :: (a -> b -> c -> d -> e -> f) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] #

zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] #

zipWith7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h] #

mapAccumL :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b) #

mapAccumR :: Traversable t => (s -> a -> (s, b)) -> s -> t a -> (s, t b) #

(!?) :: [a] -> Int -> Maybe a #

iterate' :: (a -> a) -> a -> [a] #

scanl' :: (b -> a -> b) -> b -> [a] -> [b] #

uncons :: [a] -> Maybe (a, [a]) #

unsnoc :: [a] -> Maybe ([a], a) #

Safe versions of standard functions.

head :: MonadThrow m => [a] -> m a Source #

Extract the first element of a list. Empty lists throw an EmptyListException.

last :: MonadThrow m => [a] -> m a Source #

Extract the last element of a list. Empty lists throw an EmptyListException.

tail :: MonadThrow m => [a] -> m [a] Source #

Extract the elements after the head of a list. Empty lists throw an EmptyListException.

init :: MonadThrow m => [a] -> m [a] Source #

Return all the elements of a list except the last one. Empty lists throw an EmptyListException.

foldl1 :: MonadThrow m => (a -> a -> a) -> [a] -> m a Source #

foldl1 is a variant of foldl that has no starting value, and thus must be applied to non-empty lists. Empty lists throw an EmptyListException.

foldl1' :: MonadThrow m => (a -> a -> a) -> [a] -> m a Source #

A strict version of foldl1.

foldr1 :: MonadThrow m => (a -> a -> a) -> [a] -> m a Source #

foldr1 is a variant of foldr that has no starting value, and thus must be applied to non-empty lists. Empty lists throw an EmptyListException.

maximum :: (MonadThrow m, Ord a) => [a] -> m a Source #

maximum returns the maximum value from a list, which must be non-empty, finite, and of an ordered type. It is a special case of maximumBy, which allows the programmer to supply their own comparison function. Empty lists throw an EmptyListException.

minimum :: (MonadThrow m, Ord a) => [a] -> m a Source #

minimum returns the maximum value from a list, which must be non-empty, finite, and of an ordered type. It is a special case of minimumBy, which allows the programmer to supply their own comparison function. Empty lists throw an EmptyListException.

maximumBy :: MonadThrow m => (a -> a -> Ordering) -> [a] -> m a Source #

The maximumBy function takes a comparison function and a list and returns the greatest element of the list by the comparison function. The list must be finite and non-empty. Empty lists throw an EmptyListException.

minimumBy :: MonadThrow m => (a -> a -> Ordering) -> [a] -> m a Source #

The minimumBy function takes a comparison function and a list and returns the least element of the list by the comparison function. The list must be finite and non-empty. Empty lists throw an EmptyListException.

(!!) :: (MonadThrow m, Integral n) => [a] -> n -> m a Source #

List index (subscript) operator, starting from 0. Indices larger than length xs - 1 throw an EmptyListException, negative indices throw an NegativeIndexException.

Generic wrapper for partial functions.

wrap :: MonadThrow m => ([a] -> b) -> [a] -> m b Source #

Takes a function that requires a non-empty list and wraps it in an instance of MonadThrow. For empty lists, an EmptyListException is thrown.

Exceptions for empty lists and negative indices.

These are the only two exceptions that will be thrown.

data EmptyListException Source #

Signals that the list was empty or contained too few elements (in the case or access by index).

Constructors

EmptyListException 

data NegativeIndexException Source #

Singals that an element with a negative index was accessed.

Instances

Instances details
Exception NegativeIndexException Source # 
Instance details

Defined in Data.List.Safe

Read NegativeIndexException Source # 
Instance details

Defined in Data.List.Safe

Show NegativeIndexException Source # 
Instance details

Defined in Data.List.Safe

Eq NegativeIndexException Source # 
Instance details

Defined in Data.List.Safe

Ord NegativeIndexException Source # 
Instance details

Defined in Data.List.Safe