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

Safe Haskell | Safe
Language | Haskell2010

Safe.Foldable

Contents

- New functions
- Safe wrappers
- 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
- minimumDef :: (Foldable t, Ord a) => a -> t a -> a
- minimumNote :: (Partial, Foldable t, Ord a) => String -> t a -> a
- maximumMay :: (Foldable t, Ord a) => t a -> Maybe a
- maximumDef :: (Foldable t, Ord a) => a -> t a -> a
- maximumNote :: (Partial, Foldable t, Ord a) => String -> t a -> a
- minimumByMay :: Foldable t => (a -> a -> Ordering) -> t a -> Maybe a
- minimumByDef :: Foldable t => a -> (a -> a -> Ordering) -> t a -> a
- minimumByNote :: (Partial, Foldable t) => String -> (a -> a -> Ordering) -> t a -> a
- maximumByMay :: Foldable t => (a -> a -> Ordering) -> t a -> Maybe a
- maximumByDef :: Foldable t => a -> (a -> a -> Ordering) -> t a -> a
- maximumByNote :: (Partial, Foldable t) => String -> (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 Source #

    findJust op = fromJust . find op

# Safe wrappers

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

# Deprecated

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

Deprecated: Use `foldl f mempty` instead.

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

Deprecated: Use `foldr f mempty` instead.

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

Deprecated: Use `findJustDef mempty` instead.