Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
Monad Maybe # | Since: base-2.1 |
Functor Maybe # | Since: base-2.1 |
MonadFix Maybe # | Since: base-2.1 |
Defined in Control.Monad.Fix | |
MonadFail Maybe # | Since: base-4.9.0.0 |
Defined in Control.Monad.Fail | |
Applicative Maybe # | Since: base-2.1 |
Foldable Maybe # | Since: base-2.1 |
Defined in Data.Foldable fold :: Monoid m => Maybe m -> 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 # | |
Traversable Maybe # | Since: base-2.1 |
MonadPlus Maybe # | Since: base-2.1 |
Alternative Maybe # | Since: base-2.1 |
MonadZip Maybe # | Since: base-4.8.0.0 |
Show1 Maybe # | Since: base-4.9.0.0 |
Read1 Maybe # | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Ord1 Maybe # | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
Eq1 Maybe # | Since: base-4.9.0.0 |
Eq a => Eq (Maybe a) # | Since: base-2.1 |
Data a => Data (Maybe a) # | Since: base-4.0.0.0 |
Defined in Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Maybe a -> c (Maybe a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Maybe a) # toConstr :: Maybe a -> Constr # dataTypeOf :: Maybe a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Maybe a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Maybe a)) # gmapT :: (forall b. Data b => b -> b) -> Maybe a -> Maybe a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Maybe a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Maybe a -> r # gmapQ :: (forall d. Data d => d -> u) -> Maybe a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Maybe a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) # | |
Ord a => Ord (Maybe a) # | Since: base-2.1 |
Read a => Read (Maybe a) # | Since: base-2.1 |
Show a => Show (Maybe a) # | Since: base-2.1 |
Generic (Maybe a) # | |
Semigroup a => Semigroup (Maybe a) # | Since: base-4.9.0.0 |
Semigroup a => Monoid (Maybe a) # | Lift a semigroup into Since 4.11.0: constraint on inner Since: base-2.1 |
Generic1 Maybe # | |
type Rep (Maybe a) # | Since: base-4.6.0.0 |
type Rep1 Maybe # | Since: base-4.6.0.0 |