Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module provides linear functions on the standard Maybe
type.
Documentation
The Maybe
type encapsulates an optional value. A value of type
either contains a value of type Maybe
aa
(represented as
),
or it is empty (represented as Just
aNothing
). Using Maybe
is a good way to
deal with errors or exceptional cases without resorting to drastic
measures such as error
.
The Maybe
type is also a monad. It is a simple kind of error
monad, where all errors are represented by Nothing
. A richer
error monad can be built using the Either
type.
Instances
MonadFail Maybe | Since: base-4.9.0.0 |
Defined in Control.Monad.Fail | |
Foldable Maybe | Since: base-2.1 |
Defined in Data.Foldable fold :: Monoid m => Maybe m -> m # foldMap :: Monoid m => (a -> m) -> Maybe a -> m # foldMap' :: Monoid m => (a -> m) -> Maybe a -> m # foldr :: (a -> b -> b) -> b -> Maybe a -> b # foldr' :: (a -> b -> b) -> b -> Maybe a -> b # foldl :: (b -> a -> b) -> b -> Maybe a -> b # foldl' :: (b -> a -> b) -> b -> Maybe a -> b # foldr1 :: (a -> a -> a) -> Maybe a -> a # foldl1 :: (a -> a -> a) -> Maybe a -> a # elem :: Eq a => a -> Maybe a -> Bool # maximum :: Ord a => Maybe a -> a # minimum :: Ord a => Maybe a -> a # | |
Eq1 Maybe | Since: base-4.9.0.0 |
Ord1 Maybe | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Read1 Maybe | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Show1 Maybe | Since: base-4.9.0.0 |
Traversable Maybe | Since: base-2.1 |
Alternative Maybe | Since: base-2.1 |
Applicative Maybe | Since: base-2.1 |
Functor Maybe | Since: base-2.1 |
Monad Maybe | Since: base-2.1 |
MonadPlus Maybe | Since: base-2.1 |
Hashable1 Maybe | |
Defined in Data.Hashable.Class | |
Functor Maybe Source # | |
Traversable Maybe Source # | |
Defined in Data.Functor.Linear.Internal.Traversable | |
Generic1 Maybe | |
Lift a => Lift (Maybe a :: Type) | |
Storable a => Storable (Maybe a) Source # | |
Semigroup a => Monoid (Maybe a) | Lift a semigroup into Since 4.11.0: constraint on inner Since: base-2.1 |
Semigroup a => Semigroup (Maybe a) | Since: base-4.9.0.0 |
Generic (Maybe a) | |
SingKind a => SingKind (Maybe a) | Since: base-4.9.0.0 |
Defined in GHC.Generics type DemoteRep (Maybe a) | |
Read a => Read (Maybe a) | Since: base-2.1 |
Show a => Show (Maybe a) | Since: base-2.1 |
Eq a => Eq (Maybe a) | Since: base-2.1 |
Ord a => Ord (Maybe a) | Since: base-2.1 |
Hashable a => Hashable (Maybe a) | |
Defined in Data.Hashable.Class | |
Semigroup a => Monoid (Maybe a) Source # | |
Defined in Data.Monoid.Linear.Internal.Monoid | |
Semigroup a => Semigroup (Maybe a) Source # | |
(Consumable a, Eq a) => Eq (Maybe a) Source # | |
(Consumable a, Ord a) => Ord (Maybe a) Source # | |
Consumable a => Consumable (Maybe a) Source # | |
Defined in Data.Unrestricted.Linear.Internal.Consumable | |
Dupable a => Dupable (Maybe a) Source # | |
Movable a => Movable (Maybe a) Source # | |
KnownRepresentable a => KnownRepresentable (Maybe a) Source # | |
Defined in Foreign.Marshal.Pure.Internal | |
Representable a => Representable (Maybe a) Source # | |
SingI ('Nothing :: Maybe a) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
SingI a2 => SingI ('Just a2 :: Maybe a1) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep1 Maybe | Since: base-4.6.0.0 |
type Rep1 Maybe | |
Defined in Generics.Linear.Instances.Base | |
type DemoteRep (Maybe a) | |
Defined in GHC.Generics | |
type Rep (Maybe a) | Since: base-4.6.0.0 |
Defined in GHC.Generics | |
data Sing (b :: Maybe a) | |
type AsKnown (Maybe a) Source # | |
Defined in Foreign.Marshal.Pure.Internal | |
type Rep (Maybe a) | |
Defined in Generics.Linear.Instances.Base |
maybe :: b -> (a %1 -> b) -> Maybe a %1 -> b Source #
maybe b f m
returns (f a)
where a
is in
m
if it exists and b
otherwise
fromMaybe :: a -> Maybe a %1 -> a Source #
fromMaybe default m
is the a
in
m
if it exists and the default
otherwise
maybeToList :: Maybe a %1 -> [a] Source #
maybeToList m
creates a singleton or an empty list
based on the Maybe a
.