Safe Haskell | None |
---|---|
Language | Haskell2010 |
PlutusTx.Maybe
Documentation
The
Maybe
type encapsulates an optional value. A value of type
either contains a value of type
Maybe
a
a
(represented as
),
or it is empty (represented as
Just
a
Nothing
). 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 |
MonadFail Maybe |
Since: base-4.9.0.0 |
Applicative Maybe |
Since: base-2.1 |
Foldable Maybe |
Since: base-2.1 |
Defined in Data.Foldable Methods 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 |
Defined in Data.Traversable |
|
ToJSON1 Maybe | |
Defined in Data.Aeson.Types.ToJSON Methods liftToJSON :: (a -> Value ) -> ([a] -> Value ) -> Maybe a -> Value Source # liftToJSONList :: (a -> Value ) -> ([a] -> Value ) -> [ Maybe a] -> Value Source # liftToEncoding :: (a -> Encoding ) -> ([a] -> Encoding ) -> Maybe a -> Encoding Source # liftToEncodingList :: (a -> Encoding ) -> ([a] -> Encoding ) -> [ Maybe a] -> Encoding Source # |
|
FromJSON1 Maybe | |
Alternative Maybe |
Since: base-2.1 |
MonadPlus Maybe |
Since: base-2.1 |
Eq1 Maybe |
Since: base-4.9.0.0 |
Ord1 Maybe |
Since: base-4.9.0.0 |
Defined in Data.Functor.Classes |
|
Show1 Maybe |
Since: base-4.9.0.0 |
Read1 Maybe |
Since: base-4.9.0.0 |
Defined in Data.Functor.Classes Methods 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 # |
|
MonadFailure Maybe | |
NFData1 Maybe |
Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq |
|
Hashable1 Maybe | |
Defined in Data.Hashable.Class |
|
Functor Maybe Source # | |
Applicative Maybe Source # | |
Foldable Maybe Source # | |
Traversable Maybe Source # | |
Defined in PlutusTx.Traversable |
|
MonadError () Maybe |
Since: mtl-2.2.2 |
Defined in Control.Monad.Error.Class Methods throwError :: () -> Maybe a Source # catchError :: Maybe a -> (() -> Maybe a) -> Maybe a Source # |
|
MonadBaseControl Maybe Maybe | |
FunctorWithIndex () Maybe | |
FoldableWithIndex () Maybe | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (() -> a -> m) -> Maybe a -> m Source # ifoldMap' :: Monoid m => (() -> a -> m) -> Maybe a -> m Source # ifoldr :: (() -> a -> b -> b) -> b -> Maybe a -> b Source # ifoldl :: (() -> b -> a -> b) -> b -> Maybe a -> b Source # ifoldr' :: (() -> a -> b -> b) -> b -> Maybe a -> b Source # ifoldl' :: (() -> b -> a -> b) -> b -> Maybe a -> b Source # |
|
TraversableWithIndex () Maybe | |
( Selector s, GToJSON' enc arity ( K1 i ( Maybe a) :: Type -> Type ), KeyValuePair enc pairs, Monoid pairs) => RecordToPairs enc pairs arity ( S1 s ( K1 i ( Maybe a) :: Type -> Type )) | |
Defined in Data.Aeson.Types.ToJSON |
|
Lift a => Lift ( Maybe a :: Type ) | |
PrettyDefaultBy config ( Maybe a) => PrettyBy config ( Maybe a) |
By default a
|
PrettyBy config a => DefaultPrettyBy config ( Maybe a) | |
Defined in Text.PrettyBy.Internal Methods defaultPrettyBy :: config -> Maybe a -> Doc ann Source # defaultPrettyListBy :: config -> [ Maybe a] -> Doc ann Source # |
|
( Typeable DefaultUni a, Lift DefaultUni a) => Lift DefaultUni ( Maybe a) Source # | |
Defined in PlutusTx.Lift.Instances Methods lift :: Maybe a -> RTCompile DefaultUni fun ( Term TyName Name DefaultUni fun ()) Source # |
|
( Selector s, FromJSON a) => RecordFromJSON' arity ( S1 s ( K1 i ( Maybe a) :: Type -> Type )) | |
Defined in Data.Aeson.Types.FromJSON |
|
Eq a => Eq ( Maybe a) |
Since: base-2.1 |
Data a => Data ( Maybe a) |
Since: base-4.0.0.0 |
Defined in Data.Data Methods 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 # |
|
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) |
Since: base-4.6.0.0 |
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 |
Hashable a => Hashable ( Maybe a) | |
ToJSON a => ToJSON ( Maybe a) | |
FromJSON a => FromJSON ( Maybe a) | |
Graph g => Graph ( Maybe g) | |
Undirected g => Undirected ( 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 |
|
Preorder g => Preorder ( Maybe g) | |
Defined in Algebra.Graph.Class |
|
NFData a => NFData ( Maybe a) | |
Defined in Control.DeepSeq |
|
Ixed ( Maybe a) | |
Defined in Control.Lens.At |
|
At ( Maybe a) | |
AsEmpty ( Maybe a) | |
MonoFunctor ( Maybe a) | |
MonoFoldable ( Maybe a) | |
Defined in Data.MonoTraversable Methods ofoldMap :: Monoid m => ( Element ( Maybe a) -> m) -> Maybe a -> m Source # ofoldr :: ( Element ( Maybe a) -> b -> b) -> b -> Maybe a -> b Source # ofoldl' :: (a0 -> Element ( Maybe a) -> a0) -> a0 -> Maybe a -> a0 Source # otoList :: Maybe a -> [ Element ( Maybe a)] Source # oall :: ( Element ( Maybe a) -> Bool ) -> Maybe a -> Bool Source # oany :: ( Element ( Maybe a) -> Bool ) -> Maybe a -> Bool Source # onull :: Maybe a -> Bool Source # olength :: Maybe a -> Int Source # olength64 :: Maybe a -> Int64 Source # ocompareLength :: Integral i => Maybe a -> i -> Ordering Source # otraverse_ :: Applicative f => ( Element ( Maybe a) -> f b) -> Maybe a -> f () Source # ofor_ :: Applicative f => Maybe a -> ( Element ( Maybe a) -> f b) -> f () Source # omapM_ :: Applicative m => ( Element ( Maybe a) -> m ()) -> Maybe a -> m () Source # oforM_ :: Applicative m => Maybe a -> ( Element ( Maybe a) -> m ()) -> m () Source # ofoldlM :: Monad m => (a0 -> Element ( Maybe a) -> m a0) -> a0 -> Maybe a -> m a0 Source # ofoldMap1Ex :: Semigroup m => ( Element ( Maybe a) -> m) -> Maybe a -> m Source # ofoldr1Ex :: ( Element ( Maybe a) -> Element ( Maybe a) -> Element ( Maybe a)) -> Maybe a -> Element ( Maybe a) Source # ofoldl1Ex' :: ( Element ( Maybe a) -> Element ( Maybe a) -> Element ( Maybe a)) -> Maybe a -> Element ( Maybe a) Source # headEx :: Maybe a -> Element ( Maybe a) Source # lastEx :: Maybe a -> Element ( Maybe a) Source # unsafeHead :: Maybe a -> Element ( Maybe a) Source # unsafeLast :: Maybe a -> Element ( Maybe a) Source # maximumByEx :: ( Element ( Maybe a) -> Element ( Maybe a) -> Ordering ) -> Maybe a -> Element ( Maybe a) Source # minimumByEx :: ( Element ( Maybe a) -> Element ( Maybe a) -> Ordering ) -> Maybe a -> Element ( Maybe a) Source # |
|
MonoTraversable ( Maybe a) | |
MonoPointed ( Maybe a) | |
Pretty a => Pretty ( Maybe a) |
Ignore
|
Recursive ( Maybe a) | |
Defined in Data.Functor.Foldable Methods project :: Maybe a -> Base ( Maybe a) ( Maybe a) Source # cata :: ( Base ( Maybe a) a0 -> a0) -> Maybe a -> a0 Source # para :: ( Base ( Maybe a) ( Maybe a, a0) -> a0) -> Maybe a -> a0 Source # 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 Source # prepro :: Corecursive ( Maybe a) => ( forall b. Base ( Maybe a) b -> Base ( Maybe a) b) -> ( Base ( Maybe a) a0 -> a0) -> Maybe a -> a0 Source # 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 Source # |
|
Corecursive ( Maybe a) | |
Defined in Data.Functor.Foldable Methods embed :: Base ( Maybe a) ( Maybe a) -> Maybe a Source # ana :: (a0 -> Base ( Maybe a) a0) -> a0 -> Maybe a Source # apo :: (a0 -> Base ( Maybe a) ( Either ( Maybe a) a0)) -> a0 -> Maybe a Source # postpro :: Recursive ( Maybe a) => ( forall b. Base ( Maybe a) b -> Base ( Maybe a) b) -> (a0 -> Base ( Maybe a) a0) -> a0 -> Maybe a Source # 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 Source # |
|
Serialise a => Serialise ( Maybe a) |
Since: serialise-0.2.0.0 |
Pretty a => Pretty ( Maybe a) | |
SingKind a => SingKind ( Maybe a) |
Since: base-4.9.0.0 |
Defined in GHC.Generics Associated Types type DemoteRep ( Maybe a) |
|
Eq a => Eq ( Maybe a) Source # | |
Ord a => Ord ( Maybe a) Source # | |
Defined in PlutusTx.Ord |
|
Semigroup a => Semigroup ( Maybe a) Source # | |
Semigroup a => Monoid ( Maybe a) Source # | |
Defined in PlutusTx.Monoid |
|
UnsafeFromData a => UnsafeFromData ( Maybe a) Source # | |
Defined in PlutusTx.IsData.Instances Methods unsafeFromBuiltinData :: BuiltinData -> Maybe a Source # |
|
FromData a => FromData ( Maybe a) Source # | |
Defined in PlutusTx.IsData.Instances Methods fromBuiltinData :: BuiltinData -> Maybe ( Maybe a) Source # |
|
ToData a => ToData ( Maybe a) Source # | |
Defined in PlutusTx.IsData.Instances Methods toBuiltinData :: Maybe a -> BuiltinData Source # |
|
Generic1 Maybe |
Since: base-4.6.0.0 |
SingI (' Nothing :: Maybe a) |
Since: base-4.9.0.0 |
Defined in GHC.Generics |
|
Each ( Maybe a) ( Maybe b) a b |
|
Each ( Maybe a) ( Maybe b) a b | |
SingI a2 => SingI (' Just a2 :: Maybe a1) |
Since: base-4.9.0.0 |
Defined in GHC.Generics |
|
Typeable DefaultUni Maybe Source # | |
Defined in PlutusTx.Lift.Instances Methods typeRep :: Proxy Maybe -> RTCompile DefaultUni fun ( Type TyName DefaultUni ()) Source # |
|
type Failure Maybe | |
Defined in Basement.Monad |
|
type StM Maybe a | |
Defined in Control.Monad.Trans.Control |
|
type Rep ( Maybe a) | |
Defined in GHC.Generics
type
Rep
(
Maybe
a) =
D1
('
MetaData
"Maybe" "GHC.Maybe" "base" '
False
) (
C1
('
MetaCons
"Nothing" '
PrefixI
'
False
) (
U1
::
Type
->
Type
)
:+:
C1
('
MetaCons
"Just" '
PrefixI
'
False
) (
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
a)))
|
|
type Vertex ( Maybe g) | |
Defined in Algebra.Graph.Class |
|
type Index ( Maybe a) | |
Defined in Control.Lens.At |
|
type IxValue ( Maybe a) | |
Defined in Control.Lens.At |
|
type Element ( Maybe a) | |
Defined in Data.MonoTraversable |
|
type Base ( Maybe a) |
Example boring stub for non-recursive data types |
type DemoteRep ( Maybe a) | |
Defined in GHC.Generics |
|
data Sing (b :: Maybe a) | |
type Rep1 Maybe | |
Defined in GHC.Generics |
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