Copyright | (c) The University of Glasgow 1997-2002 |
---|---|
License | see libraries/base/LICENSE |
Maintainer | ghc-devs@haskell.org |
Stability | internal |
Portability | non-portable (GHC Extensions) |
Safe Haskell | None |
Language | Haskell2010 |
The 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
MonadZip Maybe Source # | Since: base-4.8.0.0 | ||||
Eq1 Maybe Source # | Since: base-4.9.0.0 | ||||
Ord1 Maybe Source # | Since: base-4.9.0.0 | ||||
Defined in Data.Functor.Classes | |||||
Read1 Maybe Source # | Since: base-4.9.0.0 | ||||
Defined in Data.Functor.Classes liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Maybe a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Maybe a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Maybe a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Maybe a] Source # | |||||
Show1 Maybe Source # | Since: base-4.9.0.0 | ||||
Alternative Maybe | Picks the leftmost @since base-2.01 | ||||
Applicative Maybe | @since base-2.01 | ||||
Functor Maybe | @since base-2.01 | ||||
Monad Maybe | @since base-2.01 | ||||
MonadPlus Maybe | Picks the leftmost @since base-2.01 | ||||
MonadFail Maybe | @since base-4.9.0.0 | ||||
MonadFix Maybe | @since base-2.01 | ||||
Foldable Maybe | @since base-2.01 | ||||
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Maybe m -> m Source # foldMap :: Monoid m => (a -> m) -> Maybe a -> m Source # foldMap' :: Monoid m => (a -> m) -> Maybe a -> m Source # foldr :: (a -> b -> b) -> b -> Maybe a -> b Source # foldr' :: (a -> b -> b) -> b -> Maybe a -> b Source # foldl :: (b -> a -> b) -> b -> Maybe a -> b Source # foldl' :: (b -> a -> b) -> b -> Maybe a -> b Source # foldr1 :: (a -> a -> a) -> Maybe a -> a Source # foldl1 :: (a -> a -> a) -> Maybe a -> a Source # toList :: Maybe a -> [a] Source # null :: Maybe a -> Bool Source # length :: Maybe a -> Int Source # elem :: Eq a => a -> Maybe a -> Bool Source # maximum :: Ord a => Maybe a -> a Source # minimum :: Ord a => Maybe a -> a Source # | |||||
Traversable Maybe | @since base-2.01 | ||||
Defined in GHC.Internal.Data.Traversable | |||||
Generic1 Maybe | |||||
Defined in GHC.Internal.Generics
| |||||
Semigroup a => Monoid (Maybe a) | Lift a semigroup into Since 4.11.0: constraint on inner @since base-2.01 | ||||
Semigroup a => Semigroup (Maybe a) | @since base-4.9.0.0 | ||||
Data a => Data (Maybe a) | @since base-4.0.0.0 | ||||
Defined in GHC.Internal.Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Maybe a -> c (Maybe a) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Maybe a) Source # toConstr :: Maybe a -> Constr Source # dataTypeOf :: Maybe a -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Maybe a)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Maybe a)) Source # gmapT :: (forall b. Data b => b -> b) -> Maybe a -> Maybe a Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Maybe a -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Maybe a -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Maybe a -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Maybe a -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) Source # | |||||
Generic (Maybe a) | |||||
Defined in GHC.Internal.Generics
| |||||
SingKind a => SingKind (Maybe a) | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics
| |||||
Read a => Read (Maybe a) | @since base-2.01 | ||||
Show a => Show (Maybe a) | @since base-2.01 | ||||
Eq a => Eq (Maybe a) | @since base-2.01 | ||||
Ord a => Ord (Maybe a) | @since base-2.01 | ||||
SingI ('Nothing :: Maybe a) | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics | |||||
SingI a2 => SingI ('Just a2 :: Maybe a1) | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Generics | |||||
type Rep1 Maybe | @since base-4.6.0.0 | ||||
Defined in GHC.Internal.Generics | |||||
type DemoteRep (Maybe a) | |||||
Defined in GHC.Internal.Generics | |||||
type Rep (Maybe a) | @since base-4.6.0.0 | ||||
Defined in GHC.Internal.Generics | |||||
data Sing (b :: Maybe a) | |||||