Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
FromJSON1 Maybe | |
Defined in Data.Aeson.Types.FromJSON liftParseJSON :: Maybe a -> (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Maybe a) liftParseJSONList :: Maybe a -> (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Maybe a] liftOmittedField :: Maybe a -> Maybe (Maybe a) | |
ToJSON1 Maybe | |
Defined in Data.Aeson.Types.ToJSON liftToJSON :: (a -> Bool) -> (a -> Value) -> ([a] -> Value) -> Maybe a -> Value liftToJSONList :: (a -> Bool) -> (a -> Value) -> ([a] -> Value) -> [Maybe a] -> Value liftToEncoding :: (a -> Bool) -> (a -> Encoding) -> ([a] -> Encoding) -> Maybe a -> Encoding liftToEncodingList :: (a -> Bool) -> (a -> Encoding) -> ([a] -> Encoding) -> [Maybe a] -> Encoding liftOmitField :: (a -> Bool) -> Maybe a -> Bool | |
MonadFail Maybe | Since: base-4.9.0.0 |
Foldable Maybe | Since: base-2.1 |
Defined in 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.1 |
Alternative Maybe | Picks the leftmost Since: base-2.1 |
Applicative Maybe | Since: base-2.1 |
Functor Maybe | Since: base-2.1 |
Monad Maybe | Since: base-2.1 |
MonadPlus Maybe | Picks the leftmost Since: base-2.1 |
MonadFailure Maybe | |
NFData1 Maybe | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Hashable1 Maybe | |
Defined in Data.Hashable.Class | |
Applicative Maybe Source # | |
Foldable Maybe Source # | |
Defined in PlutusTx.Foldable | |
Functor Maybe Source # | |
Traversable Maybe Source # | |
Defined in PlutusTx.Traversable | |
Generic1 Maybe | |
FoldableWithIndex () Maybe | |
FunctorWithIndex () Maybe | |
TraversableWithIndex () Maybe | |
Defined in WithIndex itraverse :: Applicative f => (() -> a -> f b) -> Maybe a -> f (Maybe b) | |
MonadBaseControl Maybe Maybe | |
Defined in Control.Monad.Trans.Control type StM Maybe a | |
MonadError () Maybe | Since: mtl-2.2.2 |
Defined in Control.Monad.Error.Class throwError :: () -> Maybe a Source # catchError :: Maybe a -> (() -> Maybe a) -> Maybe a Source # | |
(Typeable DefaultUni a, Lift DefaultUni a) => Lift DefaultUni (Maybe a) Source # | |
PrettyBy config a => DefaultPrettyBy config (Maybe a) | |
Defined in Text.PrettyBy.Internal defaultPrettyBy :: config -> Maybe a -> Doc ann defaultPrettyListBy :: config -> [Maybe a] -> Doc ann | |
PrettyDefaultBy config (Maybe a) => PrettyBy config (Maybe a) | |
Defined in Text.PrettyBy.Internal prettyBy :: config -> Maybe a -> Doc ann prettyListBy :: config -> [Maybe a] -> Doc ann | |
Lift a => Lift (Maybe a :: Type) | |
FromJSON a => FromJSON (Maybe a) | |
Defined in Data.Aeson.Types.FromJSON parseJSON :: Value -> Parser (Maybe a) parseJSONList :: Value -> Parser [Maybe a] omittedField :: Maybe (Maybe a) | |
ToJSON a => ToJSON (Maybe a) | |
Defined in Data.Aeson.Types.ToJSON toEncoding :: Maybe a -> Encoding toJSONList :: [Maybe a] -> Value toEncodingList :: [Maybe a] -> Encoding | |
Graph g => Graph (Maybe g) | |
Preorder g => Preorder (Maybe g) | |
Defined in Algebra.Graph.Class | |
Reflexive g => Reflexive (Maybe g) | |
Defined in Algebra.Graph.Class | |
Transitive g => Transitive (Maybe g) | |
Defined in Algebra.Graph.Class | |
Undirected g => Undirected (Maybe g) | |
Defined in Algebra.Graph.Class | |
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) 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 # | |
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 |
Default (Maybe a) | |
Defined in Data.Default.Class | |
NFData a => NFData (Maybe a) | |
Defined in Control.DeepSeq | |
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 | |
At (Maybe a) | |
Ixed (Maybe a) | |
Defined in Control.Lens.At | |
AsEmpty (Maybe a) | |
Defined in Control.Lens.Empty | |
MonoFoldable (Maybe a) | |
Defined in Data.MonoTraversable ofoldMap :: Monoid m => (Element (Maybe a) -> m) -> Maybe a -> m ofoldr :: (Element (Maybe a) -> b -> b) -> b -> Maybe a -> b ofoldl' :: (a0 -> Element (Maybe a) -> a0) -> a0 -> Maybe a -> a0 otoList :: Maybe a -> [Element (Maybe a)] oall :: (Element (Maybe a) -> Bool) -> Maybe a -> Bool oany :: (Element (Maybe a) -> Bool) -> Maybe a -> Bool ocompareLength :: Integral i => Maybe a -> i -> Ordering otraverse_ :: Applicative f => (Element (Maybe a) -> f b) -> Maybe a -> f () ofor_ :: Applicative f => Maybe a -> (Element (Maybe a) -> f b) -> f () omapM_ :: Applicative m => (Element (Maybe a) -> m ()) -> Maybe a -> m () oforM_ :: Applicative m => Maybe a -> (Element (Maybe a) -> m ()) -> m () ofoldlM :: Monad m => (a0 -> Element (Maybe a) -> m a0) -> a0 -> Maybe a -> m a0 ofoldMap1Ex :: Semigroup m => (Element (Maybe a) -> m) -> Maybe a -> m ofoldr1Ex :: (Element (Maybe a) -> Element (Maybe a) -> Element (Maybe a)) -> Maybe a -> Element (Maybe a) ofoldl1Ex' :: (Element (Maybe a) -> Element (Maybe a) -> Element (Maybe a)) -> Maybe a -> Element (Maybe a) headEx :: Maybe a -> Element (Maybe a) lastEx :: Maybe a -> Element (Maybe a) unsafeHead :: Maybe a -> Element (Maybe a) unsafeLast :: Maybe a -> Element (Maybe a) maximumByEx :: (Element (Maybe a) -> Element (Maybe a) -> Ordering) -> Maybe a -> Element (Maybe a) minimumByEx :: (Element (Maybe a) -> Element (Maybe a) -> Ordering) -> Maybe a -> Element (Maybe a) | |
MonoFunctor (Maybe a) | |
MonoPointed (Maybe a) | |
Defined in Data.MonoTraversable | |
MonoTraversable (Maybe a) | |
Defined in Data.MonoTraversable | |
HasBlueprintDefinition a => HasBlueprintDefinition (Maybe a) Source # | |
Defined in PlutusTx.Blueprint.Definition.Unroll | |
Eq a => Eq (Maybe a) Source # | |
FromData a => FromData (Maybe a) Source # | |
Defined in PlutusTx.IsData.Instances fromBuiltinData :: BuiltinData -> Maybe (Maybe a) Source # | |
ToData a => ToData (Maybe a) Source # | |
Defined in PlutusTx.IsData.Instances toBuiltinData :: Maybe a -> BuiltinData Source # | |
UnsafeFromData a => UnsafeFromData (Maybe a) Source # | |
Defined in PlutusTx.IsData.Instances unsafeFromBuiltinData :: BuiltinData -> Maybe a Source # | |
Semigroup a => Monoid (Maybe a) Source # | |
Defined in PlutusTx.Monoid | |
Ord a => Ord (Maybe a) Source # | |
Semigroup a => Semigroup (Maybe a) Source # | |
Show a => Show (Maybe a) Source # | |
Pretty a => Pretty (Maybe a) | |
Defined in Prettyprinter.Internal prettyList :: [Maybe a] -> Doc ann | |
Corecursive (Maybe a) | |
Defined in Data.Functor.Foldable embed :: Base (Maybe a) (Maybe a) -> Maybe a ana :: (a0 -> Base (Maybe a) a0) -> a0 -> Maybe a apo :: (a0 -> Base (Maybe a) (Either (Maybe a) a0)) -> a0 -> Maybe a postpro :: Recursive (Maybe a) => (forall b. Base (Maybe a) b -> Base (Maybe a) b) -> (a0 -> Base (Maybe a) a0) -> a0 -> Maybe a gpostpro :: (Recursive (Maybe a), Monad m) => (forall b. m (Base (Maybe a) b) -> Base (Maybe a) (m b)) -> (forall c. Base (Maybe a) c -> Base (Maybe a) c) -> (a0 -> Base (Maybe a) (m a0)) -> a0 -> Maybe a | |
Recursive (Maybe a) | |
Defined in Data.Functor.Foldable project :: Maybe a -> Base (Maybe a) (Maybe a) cata :: (Base (Maybe a) a0 -> a0) -> Maybe a -> a0 para :: (Base (Maybe a) (Maybe a, a0) -> a0) -> Maybe a -> a0 gpara :: (Corecursive (Maybe a), Comonad w) => (forall b. Base (Maybe a) (w b) -> w (Base (Maybe a) b)) -> (Base (Maybe a) (EnvT (Maybe a) w a0) -> a0) -> Maybe a -> a0 prepro :: Corecursive (Maybe a) => (forall b. Base (Maybe a) b -> Base (Maybe a) b) -> (Base (Maybe a) a0 -> a0) -> Maybe a -> a0 gprepro :: (Corecursive (Maybe a), Comonad w) => (forall b. Base (Maybe a) (w b) -> w (Base (Maybe a) b)) -> (forall c. Base (Maybe a) c -> Base (Maybe a) c) -> (Base (Maybe a) (w a0) -> a0) -> Maybe a -> a0 | |
Serialise a => Serialise (Maybe a) | |
Defined in Codec.Serialise.Class encodeList :: [Maybe a] -> Encoding decodeList :: Decoder s [Maybe a] | |
Pretty a => Pretty (Maybe a) | |
Defined in Text.PrettyPrint.Annotated.WL prettyList :: [Maybe a] -> Doc b | |
(HasBlueprintDefinition a, HasSchemaDefinition a referencedTypes) => HasBlueprintSchema (Maybe a) referencedTypes Source # | |
Defined in PlutusTx.IsData.Instances | |
SingI ('Nothing :: Maybe a) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Each (Maybe a) (Maybe b) a b | |
Defined in Control.Lens.Each | |
Each (Maybe a) (Maybe b) a b | |
Defined in Lens.Micro.Internal | |
SingI a2 => SingI ('Just a2 :: Maybe a1) | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Typeable DefaultUni Maybe Source # | |
type Failure Maybe | |
Defined in Basement.Monad type Failure Maybe = () | |
type Rep1 Maybe | Since: base-4.6.0.0 |
type StM Maybe a | |
Defined in Control.Monad.Trans.Control type StM Maybe a = a | |
type Vertex (Maybe g) | |
Defined in Algebra.Graph.Class type Vertex (Maybe g) = Vertex g | |
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 Index (Maybe a) | |
Defined in Control.Lens.At type Index (Maybe a) = () | |
type IxValue (Maybe a) | |
Defined in Control.Lens.At type IxValue (Maybe a) = a | |
type Element (Maybe a) | |
Defined in Data.MonoTraversable type Element (Maybe a) = a | |
type Unroll (Maybe a) Source # | |
type Base (Maybe a) | |
isJust :: Maybe a -> Bool Source #
Check if a Maybe
a
is Just a
>>>
isJust Nothing
False>>>
isJust (Just "plutus")
True
isNothing :: Maybe a -> Bool Source #
Check if a Maybe
a
is Nothing
>>>
isNothing Nothing
True>>>
isNothing (Just "plutus")
False