plutus-tx-1.0.0.0: Libraries for Plutus Tx and its prelude
Safe Haskell None
Language Haskell2010

PlutusTx.Maybe

Synopsis

Documentation

data Maybe a Source #

The Maybe type encapsulates an optional value. A value of type Maybe a either contains a value of type a (represented as Just a ), or it is empty (represented as 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.

Constructors

Nothing
Just a

Instances

Instances details
Monad Maybe

Since: base-2.1

Instance details

Defined in GHC.Base

Functor Maybe

Since: base-2.1

Instance details

Defined in GHC.Base

MonadFix Maybe

Since: base-2.1

Instance details

Defined in Control.Monad.Fix

Methods

mfix :: (a -> Maybe a) -> Maybe a Source #

MonadFail Maybe

Since: base-4.9.0.0

Instance details

Defined in Control.Monad.Fail

Applicative Maybe

Since: base-2.1

Instance details

Defined in GHC.Base

Foldable Maybe

Since: base-2.1

Instance details

Defined in Data.Foldable

Traversable Maybe

Since: base-2.1

Instance details

Defined in Data.Traversable

ToJSON1 Maybe
Instance details

Defined in Data.Aeson.Types.ToJSON

FromJSON1 Maybe
Instance details

Defined in Data.Aeson.Types.FromJSON

Alternative Maybe

Since: base-2.1

Instance details

Defined in GHC.Base

MonadPlus Maybe

Since: base-2.1

Instance details

Defined in GHC.Base

Eq1 Maybe

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a -> b -> Bool ) -> Maybe a -> Maybe b -> Bool Source #

Ord1 Maybe

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Show1 Maybe

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Read1 Maybe

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

MonadFailure Maybe
Instance details

Defined in Basement.Monad

Associated Types

type Failure Maybe Source #

NFData1 Maybe

Since: deepseq-1.4.3.0

Instance details

Defined in Control.DeepSeq

Methods

liftRnf :: (a -> ()) -> Maybe a -> () Source #

Hashable1 Maybe
Instance details

Defined in Data.Hashable.Class

Functor Maybe Source #
Instance details

Defined in PlutusTx.Functor

Methods

fmap :: (a -> b) -> Maybe a -> Maybe b Source #

Applicative Maybe Source #
Instance details

Defined in PlutusTx.Applicative

Foldable Maybe Source #
Instance details

Defined in PlutusTx.Foldable

Methods

foldMap :: Monoid m => (a -> m) -> Maybe a -> m Source #

Traversable Maybe Source #
Instance details

Defined in PlutusTx.Traversable

Methods

traverse :: Applicative f => (a -> f b) -> Maybe a -> f ( Maybe b) Source #

MonadError () Maybe

Since: mtl-2.2.2

Instance details

Defined in Control.Monad.Error.Class

MonadBaseControl Maybe Maybe
Instance details

Defined in Control.Monad.Trans.Control

Associated Types

type StM Maybe a Source #

FunctorWithIndex () Maybe
Instance details

Defined in WithIndex

Methods

imap :: (() -> a -> b) -> Maybe a -> Maybe b Source #

FoldableWithIndex () Maybe
Instance details

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
Instance details

Defined in WithIndex

Methods

itraverse :: Applicative f => (() -> a -> f b) -> Maybe a -> f ( Maybe b) Source #

( 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 ))
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

recordToPairs :: Options -> ToArgs enc arity a0 -> S1 s ( K1 i ( Maybe a)) a0 -> pairs

Lift a => Lift ( Maybe a :: Type )
Instance details

Defined in Language.Haskell.TH.Syntax

PrettyDefaultBy config ( Maybe a) => PrettyBy config ( Maybe a)

By default a [Maybe a] is converted to [a] first and only then pretty-printed.

>>> braces $ prettyBy () (Just True)
{True}
>>> braces $ prettyBy () (Nothing :: Maybe Bool)
{}
>>> prettyBy () [Just False, Nothing, Just True]
[False, True]
>>> prettyBy () [Nothing, Just 'a', Just 'b', Nothing, Just 'c']
abc
Instance details

Defined in Text.PrettyBy.Internal

PrettyBy config a => DefaultPrettyBy config ( Maybe a)
Instance details

Defined in Text.PrettyBy.Internal

( Typeable DefaultUni a, Lift DefaultUni a) => Lift DefaultUni ( Maybe a) Source #
Instance details

Defined in PlutusTx.Lift.Instances

( Selector s, FromJSON a) => RecordFromJSON' arity ( S1 s ( K1 i ( Maybe a) :: Type -> Type ))
Instance details

Defined in Data.Aeson.Types.FromJSON

Methods

recordParseJSON' :: (ConName :* (TypeName :* ( Options :* FromArgs arity a0))) -> Object -> Parser ( S1 s ( K1 i ( Maybe a)) a0)

Eq a => Eq ( Maybe a)

Since: base-2.1

Instance details

Defined in GHC.Maybe

Data a => Data ( Maybe a)

Since: base-4.0.0.0

Instance details

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

Instance details

Defined in GHC.Maybe

Read a => Read ( Maybe a)

Since: base-2.1

Instance details

Defined in GHC.Read

Show a => Show ( Maybe a)

Since: base-2.1

Instance details

Defined in GHC.Show

Generic ( Maybe a)

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep ( Maybe a) :: Type -> Type Source #

Semigroup a => Semigroup ( Maybe a)

Since: base-4.9.0.0

Instance details

Defined in GHC.Base

Semigroup a => Monoid ( Maybe a)

Lift a semigroup into Maybe forming a Monoid according to http://en.wikipedia.org/wiki/Monoid : "Any semigroup S may be turned into a monoid simply by adjoining an element e not in S and defining e*e = e and e*s = s = s*e for all s ∈ S ."

Since 4.11.0 : constraint on inner a value generalised from Monoid to Semigroup .

Since: base-2.1

Instance details

Defined in GHC.Base

Hashable a => Hashable ( Maybe a)
Instance details

Defined in Data.Hashable.Class

ToJSON a => ToJSON ( Maybe a)
Instance details

Defined in Data.Aeson.Types.ToJSON

FromJSON a => FromJSON ( Maybe a)
Instance details

Defined in Data.Aeson.Types.FromJSON

Graph g => Graph ( Maybe g)
Instance details

Defined in Algebra.Graph.Class

Associated Types

type Vertex ( Maybe g) Source #

Undirected g => Undirected ( Maybe g)
Instance details

Defined in Algebra.Graph.Class

Reflexive g => Reflexive ( Maybe g)
Instance details

Defined in Algebra.Graph.Class

Transitive g => Transitive ( Maybe g)
Instance details

Defined in Algebra.Graph.Class

Preorder g => Preorder ( Maybe g)
Instance details

Defined in Algebra.Graph.Class

NFData a => NFData ( Maybe a)
Instance details

Defined in Control.DeepSeq

Methods

rnf :: Maybe a -> () Source #

Ixed ( Maybe a)
Instance details

Defined in Control.Lens.At

At ( Maybe a)
Instance details

Defined in Control.Lens.At

AsEmpty ( Maybe a)
Instance details

Defined in Control.Lens.Empty

MonoFunctor ( Maybe a)
Instance details

Defined in Data.MonoTraversable

MonoFoldable ( Maybe a)
Instance details

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 #

oelem :: Element ( Maybe a) -> Maybe a -> Bool Source #

onotElem :: Element ( Maybe a) -> Maybe a -> Bool Source #

MonoTraversable ( Maybe a)
Instance details

Defined in Data.MonoTraversable

MonoPointed ( Maybe a)
Instance details

Defined in Data.MonoTraversable

Pretty a => Pretty ( Maybe a)

Ignore Nothing s, print Just contents.

>>> pretty (Just True)
True
>>> braces (pretty (Nothing :: Maybe Bool))
{}
>>> pretty [Just 1, Nothing, Just 3, Nothing]
[1, 3]
Instance details

Defined in Prettyprinter.Internal

Recursive ( Maybe a)
Instance details

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)
Instance details

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

Instance details

Defined in Codec.Serialise.Class

Pretty a => Pretty ( Maybe a)
Instance details

Defined in Text.PrettyPrint.Annotated.WL

SingKind a => SingKind ( Maybe a)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Associated Types

type DemoteRep ( Maybe a)

Methods

fromSing :: forall (a0 :: Maybe a). Sing a0 -> DemoteRep ( Maybe a)

Eq a => Eq ( Maybe a) Source #
Instance details

Defined in PlutusTx.Eq

Ord a => Ord ( Maybe a) Source #
Instance details

Defined in PlutusTx.Ord

Semigroup a => Semigroup ( Maybe a) Source #
Instance details

Defined in PlutusTx.Semigroup

Semigroup a => Monoid ( Maybe a) Source #
Instance details

Defined in PlutusTx.Monoid

UnsafeFromData a => UnsafeFromData ( Maybe a) Source #
Instance details

Defined in PlutusTx.IsData.Instances

FromData a => FromData ( Maybe a) Source #
Instance details

Defined in PlutusTx.IsData.Instances

ToData a => ToData ( Maybe a) Source #
Instance details

Defined in PlutusTx.IsData.Instances

Generic1 Maybe

Since: base-4.6.0.0

Instance details

Defined in GHC.Generics

Associated Types

type Rep1 Maybe :: k -> Type Source #

Methods

from1 :: forall (a :: k). Maybe a -> Rep1 Maybe a Source #

to1 :: forall (a :: k). Rep1 Maybe a -> Maybe a Source #

SingI (' Nothing :: Maybe a)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

sing :: Sing ' Nothing

Each ( Maybe a) ( Maybe b) a b
each :: Traversal (Maybe a) (Maybe b) a b
Instance details

Defined in Control.Lens.Each

Each ( Maybe a) ( Maybe b) a b
Instance details

Defined in Lens.Micro.Internal

SingI a2 => SingI (' Just a2 :: Maybe a1)

Since: base-4.9.0.0

Instance details

Defined in GHC.Generics

Methods

sing :: Sing (' Just a2)

Typeable DefaultUni Maybe Source #
Instance details

Defined in PlutusTx.Lift.Instances

type Failure Maybe
Instance details

Defined in Basement.Monad

type StM Maybe a
Instance details

Defined in Control.Monad.Trans.Control

type StM Maybe a = a
type Rep ( Maybe a)
Instance details

Defined in GHC.Generics

type Vertex ( Maybe g)
Instance details

Defined in Algebra.Graph.Class

type Index ( Maybe a)
Instance details

Defined in Control.Lens.At

type Index ( Maybe a) = ()
type IxValue ( Maybe a)
Instance details

Defined in Control.Lens.At

type IxValue ( Maybe a) = a
type Element ( Maybe a)
Instance details

Defined in Data.MonoTraversable

type Element ( Maybe a) = a
type Base ( Maybe a)

Example boring stub for non-recursive data types

Instance details

Defined in Data.Functor.Foldable

type DemoteRep ( Maybe a)
Instance details

Defined in GHC.Generics

type DemoteRep ( Maybe a) = Maybe (DemoteRep a)
data Sing (b :: Maybe a)
Instance details

Defined in GHC.Generics

data Sing (b :: Maybe a) where
type Rep1 Maybe
Instance details

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

maybe :: b -> (a -> b) -> Maybe a -> b Source #

Plutus Tx version of maybe .

>>> maybe "platypus" (\s -> s) (Just "plutus")
"plutus"
>>> maybe "platypus" (\s -> s) Nothing
"platypus"

fromMaybe :: a -> Maybe a -> a Source #

Plutus Tx version of fromMaybe

mapMaybe :: (a -> Maybe b) -> [a] -> [b] Source #

Plutus Tx version of mapMaybe .

>>> mapMaybe (\i -> if i == 2 then Just '2' else Nothing) [1, 2, 3, 4]
"2"