Safe Haskell | Safe |
---|---|

Language | Haskell98 |

- unionMaybeWith :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a
- unzipMaybe :: Maybe (a, b) -> (Maybe a, Maybe b)
- filterMaybe :: (a -> Bool) -> a -> Maybe a
- forMaybe :: [a] -> (a -> Maybe b) -> [b]
- caseMaybe :: Maybe a -> b -> (a -> b) -> b
- maybeM :: Monad m => m b -> (a -> m b) -> m (Maybe a) -> m b
- fromMaybeM :: Monad m => m a -> m (Maybe a) -> m a
- caseMaybeM :: Monad m => m (Maybe a) -> m b -> (a -> m b) -> m b
- ifJustM :: Monad m => m (Maybe a) -> (a -> m b) -> m b -> m b
- whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
- whenNothing :: Monad m => Maybe a -> m () -> m ()
- whenJustM :: Monad m => m (Maybe a) -> (a -> m ()) -> m ()
- whenNothingM :: Monad m => m (Maybe a) -> m () -> m ()
- allJustM :: Monad m => [m (Maybe a)] -> m (Maybe [a])
- allJustsOrNothings :: [Maybe a] -> Maybe (Maybe [a])
- module Data.Maybe

# Collection operations.

unionMaybeWith :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a Source #

`unionWith`

for collections of size <= 1.

filterMaybe :: (a -> Bool) -> a -> Maybe a Source #

Filtering a singleton list.

filterMaybe p a =`listToMaybe`

(`filter`

p [a])

# Conditionals and loops.

forMaybe :: [a] -> (a -> Maybe b) -> [b] Source #

Version of `mapMaybe`

with different argument ordering.

# Monads and Maybe.

caseMaybeM :: Monad m => m (Maybe a) -> m b -> (a -> m b) -> m b Source #

ifJustM :: Monad m => m (Maybe a) -> (a -> m b) -> m b -> m b Source #

`caseMaybeM`

with flipped branches.

whenJustM :: Monad m => m (Maybe a) -> (a -> m ()) -> m () Source #

`caseMaybeM`

without the `Nothing`

case.

whenNothingM :: Monad m => m (Maybe a) -> m () -> m () Source #

`caseMaybeM`

without the `Just`

case.

allJustM :: Monad m => [m (Maybe a)] -> m (Maybe [a]) Source #

Lazy version of `allJust . sequence`

.
(`allJust = mapM`

for the `Maybe`

monad.)
Only executes monadic effect while `isJust`

.

allJustsOrNothings :: [Maybe a] -> Maybe (Maybe [a]) Source #

Precondition: list not empty.
```
allJustsOrNothings [Nothing, Nothing] = Just Nothing
allJustsOrNothings [Just 0, Just 1] = Just $ Just [0,1]
allJustsOrNothings [Just 0, Nothing] = Nothing
```

module Data.Maybe