Module Prelude.Maybe

Provides functions and instances for the Maybe type.

Compatible with the Haskell 2010 Data.Maybe module.

Imports

Table of Content

Definitions

isJustMaybe αBool

true if and only if the argument is a Maybe.Just value

isNothingMaybe αBool

true if and only if the argument is Maybe.Nothing

This function is preferable over v == Nothing because no Eq constraint is needed.

fromMaybe ∷ α → Maybe α → α

fromMaybe d (Just a) returns a and fromMaybe d Nothing returns d

unJustMaybe α → α

unJust Nothing is undefined whereas unJust (Just a) is a

catMaybesListSource β ⇒ β (Maybe α) → [α]

The catMaybes function takes a list of Maybes and returns a list of all the Maybe.Just values.

mapMaybe ∷ (β→Maybe α) → [β] → [α]

The mapMaybe function is a version of map which can throw out elements. In particular, the functional argument returns something of type Maybe b. If this is Maybe.Nothing, no element is added on to the result list. If it just Maybe.Just b, then b is included in the result list.

listToMaybeListSource α ⇒ α β → Maybe β

give the first element of a list or Maybe.Nothing

maybeToListMaybe a → [a]

convert a Maybe to a single element list or an empty list

Instances

instance Applicative Maybe

Member Functions

*>Maybe β → Maybe α → Maybe α
infixl  4

inherited from Applicative.*>

<*Maybe β → Maybe α → Maybe β
infixl  4

inherited from Applicative.<*

<*>Maybe (β→α)Maybe β → Maybe α
infixl  4
pure ∷ α → Maybe α
instance Eq a ⇒ Eq (Maybe a)

Member Functions

!=Eq α ⇒ Maybe αMaybe αBool
infix  7

inherited from Eq.!=

==Eq α ⇒ Maybe αMaybe αBool
infix  7

Function generated for derived instance.

hashCodeEq α ⇒ Maybe αInt

Function generated for derived instance.

instance Functor Maybe

Member Functions

fmap ∷ (α → β) → Maybe αMaybe β
infixl  4
instance ListEmpty Maybe

Member Functions

emptyMaybe α
nullMaybe αBool
instance MonadFail Maybe

Member Functions

failStringMaybe α
instance MonadPlus Maybe

Member Functions

mplusMaybe αMaybe α → Maybe α
infixr  13
mzeroMaybe α
instance Monad Maybe

Member Functions

>>Maybe βMaybe α → Maybe α
infixl  3
>>=Maybe β → (β → Maybe α) → Maybe α
infixl  3
 Nothing >>= _ = Nothing
 Just a  >>= k = k a   
joinMaybe (Maybe α)Maybe α

inherited from Monad.join

pure ∷ α → Maybe α
instance Ord a ⇒ Ord (Maybe a)

Member Functions

<Ord α ⇒ Maybe αMaybe αBool
infix  9

inherited from Ord.<

<=Ord α ⇒ Maybe αMaybe αBool
infix  9

inherited from Ord.<=

<=>Ord α ⇒ Maybe αMaybe αOrdering
infix  8

Function generated for derived instance.

>Ord α ⇒ Maybe αMaybe αBool
infix  9

inherited from Ord.>

>=Ord α ⇒ Maybe αMaybe αBool
infix  9

inherited from Ord.>=

compareOrd α ⇒ Maybe αMaybe αOrdering
infix  8

inherited from Ord.compare

maxOrd α ⇒ Maybe αMaybe αMaybe α

inherited from Ord.max

minOrd α ⇒ Maybe αMaybe αMaybe α

inherited from Ord.min

Functions and Values by Type

Maybe (Maybe α) → Maybe α

Monad_Maybe.join

Maybe a → [a]

maybeToList

Maybe α → Maybe α → Maybe α

MonadPlus_Maybe.mplus

Maybe α → Bool

isJust, isNothing, ListEmpty_Maybe.null

Maybe α → α

unJust

StringMaybe α

MonadFail_Maybe.fail

α → Maybe α → α

fromMaybe

α → Maybe α

Applicative_Maybe.pure, Monad_Maybe.pure

Eq α ⇒ Maybe α → Maybe α → Bool

Eq_Maybe.!=, Eq_Maybe.==

Eq α ⇒ Maybe α → Int

Eq_Maybe.hashCode

Ord α ⇒ Maybe α → Maybe α → Maybe α

Ord_Maybe.min, Ord_Maybe.max

Ord α ⇒ Maybe α → Maybe α → Bool

Ord_Maybe.>=, Ord_Maybe.<, Ord_Maybe.<=, Ord_Maybe.>

Ord α ⇒ Maybe α → Maybe α → Ordering

Ord_Maybe.compare, Ord_Maybe.<=>

Maybe α

ListEmpty_Maybe.empty, MonadPlus_Maybe.mzero

(α → β) → Maybe α → Maybe β

Functor_Maybe.fmap

(β→Maybe α) → [β] → [α]

mapMaybe

Maybe (β→α) → Maybe β → Maybe α

Applicative_Maybe.<*>

Maybe β → (β → Maybe α) → Maybe α

Monad_Maybe.>>=

Maybe β → Maybe α → Maybe α

Applicative_Maybe.*>, Monad_Maybe.>>

Maybe β → Maybe α → Maybe β

Applicative_Maybe.<*

ListSource α ⇒ α β → Maybe β

listToMaybe

ListSource β ⇒ β (Maybe α) → [α]

catMaybes

Valid HTML 4.01 Strict