Safe.Foldable

safe-0.3.21: Library of safe (exception free) functions

Safe Haskell | Safe-Inferred
Language | Haskell2010

Safe.Foldable

Contents

- New functions
- Safe wrappers
- Discouraged
- Deprecated

Description

`Foldable` functions, with wrappers like the Safe module.

Synopsis

- findJust :: (Partial, Foldable t) => (a -> Bool) -> t a -> a
- foldl1May :: Foldable t => (a -> a -> a) -> t a -> Maybe a
- foldl1Def :: Foldable t => a -> (a -> a -> a) -> t a -> a
- foldl1Note :: (Partial, Foldable t) => String -> (a -> a -> a) -> t a -> a
- foldr1May :: Foldable t => (a -> a -> a) -> t a -> Maybe a
- foldr1Def :: Foldable t => a -> (a -> a -> a) -> t a -> a
- foldr1Note :: (Partial, Foldable t) => String -> (a -> a -> a) -> t a -> a
- findJustDef :: Foldable t => a -> (a -> Bool) -> t a -> a
- findJustNote :: (Partial, Foldable t) => String -> (a -> Bool) -> t a -> a
- minimumMay :: (Foldable t, Ord a) => t a -> Maybe a
- minimumNote :: (Partial, Foldable t, Ord a) => String -> t a -> a
- maximumMay :: (Foldable t, Ord a) => t a -> Maybe a
- maximumNote :: (Partial, Foldable t, Ord a) => String -> t a -> a
- minimumByMay :: Foldable t => (a -> a -> Ordering) -> t a -> Maybe a
- minimumByNote :: (Partial, Foldable t) => String -> (a -> a -> Ordering) -> t a -> a
- maximumByMay :: Foldable t => (a -> a -> Ordering) -> t a -> Maybe a
- maximumByNote :: (Partial, Foldable t) => String -> (a -> a -> Ordering) -> t a -> a
- maximumBoundBy :: Foldable f => a -> (a -> a -> Ordering) -> f a -> a
- minimumBoundBy :: Foldable f => a -> (a -> a -> Ordering) -> f a -> a
- maximumBounded :: (Foldable f, Ord a, Bounded a) => f a -> a
- maximumBound :: (Foldable f, Ord a) => a -> f a -> a
- minimumBounded :: (Foldable f, Ord a, Bounded a) => f a -> a
- minimumBound :: (Foldable f, Ord a) => a -> f a -> a
- minimumDef :: (Foldable t, Ord a) => a -> t a -> a
- maximumDef :: (Foldable t, Ord a) => a -> t a -> a
- minimumByDef :: Foldable t => a -> (a -> a -> Ordering) -> t a -> a
- maximumByDef :: Foldable t => a -> (a -> a -> Ordering) -> t a -> a
- foldl1Safe :: (Monoid m, Foldable t) => (m -> m -> m) -> t m -> m
- foldr1Safe :: (Monoid m, Foldable t) => (m -> m -> m) -> t m -> m
- findJustSafe :: (Monoid m, Foldable t) => (m -> Bool) -> t m -> m

# New functions

findJust :: (Partial, Foldable t) => (a -> Bool) -> t a -> a #

    findJust op = fromJust . find op

# Safe wrappers

foldl1May :: Foldable t => (a -> a -> a) -> t a -> Maybe a #

foldl1Def :: Foldable t => a -> (a -> a -> a) -> t a -> a #

New users are recommended to use `foldr1May` or `foldl1May` instead.

foldl1Note :: (Partial, Foldable t) => String -> (a -> a -> a) -> t a -> a #

foldr1May :: Foldable t => (a -> a -> a) -> t a -> Maybe a #

foldr1Def :: Foldable t => a -> (a -> a -> a) -> t a -> a #

New users are recommended to use `foldr1May` or `foldl1May` instead.

foldr1Note :: (Partial, Foldable t) => String -> (a -> a -> a) -> t a -> a #

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

findJustNote :: (Partial, Foldable t) => String -> (a -> Bool) -> t a -> a #

minimumMay :: (Foldable t, Ord a) => t a -> Maybe a #

minimumNote :: (Partial, Foldable t, Ord a) => String -> t a -> a #

maximumMay :: (Foldable t, Ord a) => t a -> Maybe a #

maximumNote :: (Partial, Foldable t, Ord a) => String -> t a -> a #

minimumByMay :: Foldable t => (a -> a -> Ordering) -> t a -> Maybe a #

minimumByNote :: (Partial, Foldable t) => String -> (a -> a -> Ordering) -> t a -> a #

maximumByMay :: Foldable t => (a -> a -> Ordering) -> t a -> Maybe a #

maximumByNote :: (Partial, Foldable t) => String -> (a -> a -> Ordering) -> t a -> a #

maximumBoundBy :: Foldable f => a -> (a -> a -> Ordering) -> f a -> a #

The largest element of a foldable structure with respect to the given comparison function. The result is bounded by the value given as the first argument.

minimumBoundBy :: Foldable f => a -> (a -> a -> Ordering) -> f a -> a #

The smallest element of a foldable structure with respect to the given comparison function. The result is bounded by the value given as the first argument.

maximumBounded :: (Foldable f, Ord a, Bounded a) => f a -> a #

The largest element of a foldable structure. The result is bounded by `minBound`.

maximumBound :: (Foldable f, Ord a) => a -> f a -> a #

The largest element of a foldable structure. The result is bounded by the value given as the first argument.

minimumBounded :: (Foldable f, Ord a, Bounded a) => f a -> a #

The largest element of a foldable structure. The result is bounded by `maxBound`.

minimumBound :: (Foldable f, Ord a) => a -> f a -> a #

The smallest element of a foldable structure. The result is bounded by the value given as the first argument.

# Discouraged

minimumDef :: (Foldable t, Ord a) => a -> t a -> a #

New users are recommended to use `minimumBound` or `maximumBound` instead.

maximumDef :: (Foldable t, Ord a) => a -> t a -> a #

New users are recommended to use `minimumBound` or `maximumBound` instead.

minimumByDef :: Foldable t => a -> (a -> a -> Ordering) -> t a -> a #

New users are recommended to use `minimumBoundBy` or `maximumBoundBy` instead.

maximumByDef :: Foldable t => a -> (a -> a -> Ordering) -> t a -> a #

New users are recommended to use `minimumBoundBy` or `maximumBoundBy` instead.

# Deprecated

foldl1Safe :: (Monoid m, Foldable t) => (m -> m -> m) -> t m -> m #

Deprecated: Use `foldl f mempty` instead.

foldr1Safe :: (Monoid m, Foldable t) => (m -> m -> m) -> t m -> m #

Deprecated: Use `foldr f mempty` instead.

findJustSafe :: (Monoid m, Foldable t) => (m -> Bool) -> t m -> m #

Deprecated: Use `findJustDef mempty` instead.