errors-1.2.1: Simplified error-handling

Safe HaskellSafe-Infered

Control.Error.Safe

Contents

Description

This module extends the safe library's functions with corresponding versions compatible with Either and EitherT.

All functions take an exceptional value to return should they fail.

I suffix the Either-compatible functions with Err and prefix the EitherT-compatible functions with try.

Note that this library re-exports the Maybe compatible functions from safe in the Control.Error module, so they are not provided here.

Synopsis

Either-compatible functions

tailErr :: e -> [a] -> Either e [a]Source

A tail that fails in the Either monad

initErr :: e -> [a] -> Either e [a]Source

An init that fails in the Either monad

headErr :: e -> [a] -> Either e aSource

A head that fails in the Either monad

lastErr :: e -> [a] -> Either e aSource

A last that fails in the Either monad

minimumErr :: Ord a => e -> [a] -> Either e aSource

A minimum that fails in the Either monad

maximumErr :: Ord a => e -> [a] -> Either e aSource

A maximum that fails in the Either monad

foldr1Err :: e -> (a -> a -> a) -> [a] -> Either e aSource

A foldr1 that fails in the Either monad

foldl1Err :: e -> (a -> a -> a) -> [a] -> Either e aSource

A foldl1 that fails in the Either monad

foldl1Err' :: e -> (a -> a -> a) -> [a] -> Either e aSource

A foldl1' that fails in the Either monad

atErr :: e -> [a] -> Int -> Either e aSource

A (!!) that fails in the Either monad

readErr :: Read a => e -> String -> Either e aSource

A read that fails in the Either monad

assertErr :: e -> Bool -> a -> Either e aSource

An assertion that fails in the Either monad

EitherT-compatible functions

tryTail :: Monad m => e -> [a] -> EitherT e m [a]Source

A tail that fails in the EitherT monad

tryInit :: Monad m => e -> [a] -> EitherT e m [a]Source

An init that fails in the EitherT monad

tryHead :: Monad m => e -> [a] -> EitherT e m aSource

A head that fails in the EitherT monad

tryLast :: Monad m => e -> [a] -> EitherT e m aSource

A last that fails in the EitherT monad

tryMinimum :: (Monad m, Ord a) => e -> [a] -> EitherT e m aSource

A minimum that fails in the EitherT monad

tryMaximum :: (Monad m, Ord a) => e -> [a] -> EitherT e m aSource

A maximum that fails in the EitherT monad

tryFoldr1 :: Monad m => e -> (a -> a -> a) -> [a] -> EitherT e m aSource

A foldr1 that fails in the EitherT monad

tryFoldl1 :: Monad m => e -> (a -> a -> a) -> [a] -> EitherT e m aSource

A foldl1 that fails in the EitherT monad

tryFoldl1' :: Monad m => e -> (a -> a -> a) -> [a] -> EitherT e m aSource

A foldl1' that fails in the EitherT monad

tryAt :: Monad m => e -> [a] -> Int -> EitherT e m aSource

A (!!) that fails in the EitherT monad

tryRead :: (Monad m, Read a) => e -> String -> EitherT e m aSource

A read that fails in the EitherT monad

tryAssert :: Monad m => e -> Bool -> a -> EitherT e m aSource

An assertion that fails in the EitherT monad