Safe Haskell  SafeInferred 

A module wrapping Prelude
/Data.List
functions that can throw exceptions, such as head
and !!
.
Each unsafe function has up to four variants, e.g. with tail
:

, raises an error ontail
:: [a] > [a]tail []
. 
, turns errors intotailMay
:: [a] > Maybe [a]Nothing
. 
, takes a default to return on errors.tailDef
:: [a] > [a] > [a] 
, takes an extra argument which supplements the error message.tailNote
:: String > [a] > [a] 
, returns some sensible default if possible,tailSafe
:: [a] > [a][]
in the case oftail
.
This module also introduces some new functions, documented at the top of the module.
 abort :: String > a
 at :: [a] > Int > a
 lookupJust :: Eq a => a > [(a, b)] > b
 findJust :: (a > Bool) > [a] > a
 elemIndexJust :: Eq a => a > [a] > Int
 findIndexJust :: (a > Bool) > [a] > Int
 tailMay :: [a] > Maybe [a]
 tailDef :: [a] > [a] > [a]
 tailNote :: String > [a] > [a]
 tailSafe :: [a] > [a]
 initMay :: [a] > Maybe [a]
 initDef :: [a] > [a] > [a]
 initNote :: String > [a] > [a]
 initSafe :: [a] > [a]
 headMay :: [a] > Maybe a
 headDef :: a > [a] > a
 headNote :: String > [a] > a
 lastMay :: [a] > Maybe a
 lastDef :: a > [a] > a
 lastNote :: String > [a] > a
 minimumMay :: Ord a => [a] > Maybe a
 minimumDef :: Ord a => a > [a] > a
 minimumNote :: Ord a => String > [a] > a
 maximumMay :: Ord a => [a] > Maybe a
 maximumDef :: Ord a => a > [a] > a
 maximumNote :: Ord a => String > [a] > a
 minimumByMay :: (a > a > Ordering) > [a] > Maybe a
 minimumByDef :: a > (a > a > Ordering) > [a] > a
 minimumByNote :: String > (a > a > Ordering) > [a] > a
 maximumByMay :: (a > a > Ordering) > [a] > Maybe a
 maximumByDef :: a > (a > a > Ordering) > [a] > a
 maximumByNote :: String > (a > a > Ordering) > [a] > a
 foldr1May :: (a > a > a) > [a] > Maybe a
 foldr1Def :: a > (a > a > a) > [a] > a
 foldr1Note :: String > (a > a > a) > [a] > a
 foldl1May :: (a > a > a) > [a] > Maybe a
 foldl1Def :: a > (a > a > a) > [a] > a
 foldl1Note :: String > (a > a > a) > [a] > a
 foldl1May' :: (a > a > a) > [a] > Maybe a
 foldl1Def' :: a > (a > a > a) > [a] > a
 foldl1Note' :: String > (a > a > a) > [a] > a
 scanl1May :: (a > a > a) > [a] > Maybe [a]
 scanl1Def :: [a] > (a > a > a) > [a] > [a]
 scanl1Note :: String > (a > a > a) > [a] > [a]
 scanr1May :: (a > a > a) > [a] > Maybe [a]
 scanr1Def :: [a] > (a > a > a) > [a] > [a]
 scanr1Note :: String > (a > a > a) > [a] > [a]
 fromJustDef :: a > Maybe a > a
 fromJustNote :: String > Maybe a > a
 assertNote :: String > Bool > a > a
 atMay :: [a] > Int > Maybe a
 atDef :: a > [a] > Int > a
 atNote :: String > [a] > Int > a
 readMay :: Read a => String > Maybe a
 readDef :: Read a => a > String > a
 readNote :: Read a => String > String > a
 lookupJustDef :: Eq a => b > a > [(a, b)] > b
 lookupJustNote :: Eq a => String > a > [(a, b)] > b
 findJustDef :: a > (a > Bool) > [a] > a
 findJustNote :: String > (a > Bool) > [a] > a
 elemIndexJustDef :: Eq a => Int > a > [a] > Int
 elemIndexJustNote :: Eq a => String > a > [a] > Int
 findIndexJustDef :: Int > (a > Bool) > [a] > Int
 findIndexJustNote :: String > (a > Bool) > [a] > Int
New functions
lookupJust :: Eq a => a > [(a, b)] > bSource
lookupJust key = fromJust . lookup key
elemIndexJust :: Eq a => a > [a] > IntSource
elemIndexJust op = fromJust . elemIndex op
findIndexJust :: (a > Bool) > [a] > IntSource
findIndexJust op = fromJust . findIndex op
Safe wrappers
tailNote :: String > [a] > [a]Source
tailNote "help me" [] = error "Safe.tailNote [], help me" tailNote "help me" [1,3,4] = [3,4]
minimumMay :: Ord a => [a] > Maybe aSource
minimumDef :: Ord a => a > [a] > aSource
minimumNote :: Ord a => String > [a] > aSource
maximumMay :: Ord a => [a] > Maybe aSource
maximumDef :: Ord a => a > [a] > aSource
maximumNote :: Ord a => String > [a] > aSource
minimumByMay :: (a > a > Ordering) > [a] > Maybe aSource
minimumByDef :: a > (a > a > Ordering) > [a] > aSource
minimumByNote :: String > (a > a > Ordering) > [a] > aSource
maximumByMay :: (a > a > Ordering) > [a] > Maybe aSource
maximumByDef :: a > (a > a > Ordering) > [a] > aSource
maximumByNote :: String > (a > a > Ordering) > [a] > aSource
foldr1Note :: String > (a > a > a) > [a] > aSource
foldl1Note :: String > (a > a > a) > [a] > aSource
foldl1May' :: (a > a > a) > [a] > Maybe aSource
foldl1Def' :: a > (a > a > a) > [a] > aSource
foldl1Note' :: String > (a > a > a) > [a] > aSource
scanl1Note :: String > (a > a > a) > [a] > [a]Source
scanr1Note :: String > (a > a > a) > [a] > [a]Source
fromJustDef :: a > Maybe a > aSource
fromJustNote :: String > Maybe a > aSource
assertNote :: String > Bool > a > aSource
lookupJustDef :: Eq a => b > a > [(a, b)] > bSource
lookupJustNote :: Eq a => String > a > [(a, b)] > bSource
findJustDef :: a > (a > Bool) > [a] > aSource
findJustNote :: String > (a > Bool) > [a] > aSource
elemIndexJustDef :: Eq a => Int > a > [a] > IntSource
elemIndexJustNote :: Eq a => String > a > [a] > IntSource
findIndexJustDef :: Int > (a > Bool) > [a] > IntSource
findIndexJustNote :: String > (a > Bool) > [a] > IntSource