Safe Haskell | Safe-Infered |
---|

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.

- tailErr :: e -> [a] -> Either e [a]
- initErr :: e -> [a] -> Either e [a]
- headErr :: e -> [a] -> Either e a
- lastErr :: e -> [a] -> Either e a
- minimumErr :: Ord a => e -> [a] -> Either e a
- maximumErr :: Ord a => e -> [a] -> Either e a
- foldr1Err :: e -> (a -> a -> a) -> [a] -> Either e a
- foldl1Err :: e -> (a -> a -> a) -> [a] -> Either e a
- foldl1Err' :: e -> (a -> a -> a) -> [a] -> Either e a
- atErr :: e -> [a] -> Int -> Either e a
- readErr :: Read a => e -> String -> Either e a
- assertErr :: e -> Bool -> a -> Either e a
- tryTail :: Monad m => e -> [a] -> EitherT e m [a]
- tryInit :: Monad m => e -> [a] -> EitherT e m [a]
- tryHead :: Monad m => e -> [a] -> EitherT e m a
- tryLast :: Monad m => e -> [a] -> EitherT e m a
- tryMinimum :: (Monad m, Ord a) => e -> [a] -> EitherT e m a
- tryMaximum :: (Monad m, Ord a) => e -> [a] -> EitherT e m a
- tryFoldr1 :: Monad m => e -> (a -> a -> a) -> [a] -> EitherT e m a
- tryFoldl1 :: Monad m => e -> (a -> a -> a) -> [a] -> EitherT e m a
- tryFoldl1' :: Monad m => e -> (a -> a -> a) -> [a] -> EitherT e m a
- tryAt :: Monad m => e -> [a] -> Int -> EitherT e m a
- tryRead :: (Monad m, Read a) => e -> String -> EitherT e m a
- tryAssert :: Monad m => e -> Bool -> a -> EitherT e m a

# Either-compatible functions

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

A `foldl1'`

that fails in the `Either`

monad

# EitherT-compatible functions

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

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

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

A `foldl1'`

that fails in the `EitherT`

monad