plutarch-1.9.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Plutarch.Maybe

Synopsis

Type

data PMaybe (a :: S -> Type) (s :: S) Source #

Plutus Maybe type, with Scott-encoded repr

Constructors

PJust (Term s a) 
PNothing 

Instances

Instances details
PEq a => PEq (PMaybe a) Source # 
Instance details

Defined in Plutarch.Maybe

Methods

(#==) :: forall (s :: S). Term s (PMaybe a) -> Term s (PMaybe a) -> Term s PBool Source #

PLiftable a => PLiftable (PMaybe a) Source #

@since WIP

Instance details

Defined in Plutarch.Maybe

Associated Types

type AsHaskell (PMaybe a) Source #

type PlutusRepr (PMaybe a) Source #

DerivePlutusType (PMaybe a) Source # 
Instance details

Defined in Plutarch.Maybe

Associated Types

type DPTStrat (PMaybe a) Source #

PlutusType (PMaybe a) Source # 
Instance details

Defined in Plutarch.Maybe

Associated Types

type PInner (PMaybe a) :: PType Source #

type PCovariant' (PMaybe a) Source #

type PContravariant' (PMaybe a) Source #

type PVariant' (PMaybe a) Source #

Methods

pcon' :: forall (s :: S). PMaybe a s -> Term s (PInner (PMaybe a)) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner (PMaybe a)) -> (PMaybe a s -> Term s b) -> Term s b Source #

PShow a => PShow (PMaybe a) Source # 
Instance details

Defined in Plutarch.Maybe

Methods

pshow' :: forall (s :: S). Bool -> Term s (PMaybe a) -> Term s PString Source #

Generic (PMaybe a s) Source # 
Instance details

Defined in Plutarch.Maybe

Associated Types

type Rep (PMaybe a s) :: Type -> Type Source #

Methods

from :: PMaybe a s -> Rep (PMaybe a s) x Source #

to :: Rep (PMaybe a s) x -> PMaybe a s Source #

type AsHaskell (PMaybe a) Source # 
Instance details

Defined in Plutarch.Maybe

type PlutusRepr (PMaybe a) Source # 
Instance details

Defined in Plutarch.Maybe

type DPTStrat (PMaybe a) Source # 
Instance details

Defined in Plutarch.Maybe

type PContravariant' (PMaybe a) Source # 
Instance details

Defined in Plutarch.Maybe

type PCovariant' (PMaybe a) Source # 
Instance details

Defined in Plutarch.Maybe

type PInner (PMaybe a) Source # 
Instance details

Defined in Plutarch.Maybe

type PVariant' (PMaybe a) Source # 
Instance details

Defined in Plutarch.Maybe

type PVariant' (PMaybe a)
type Rep (PMaybe a s) Source # 
Instance details

Defined in Plutarch.Maybe

type Rep (PMaybe a s) = D1 ('MetaData "PMaybe" "Plutarch.Maybe" "plutarch-1.9.0-DaxzFvLNVysDL1hkJ4YFrw" 'False) (C1 ('MetaCons "PJust" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s a))) :+: C1 ('MetaCons "PNothing" 'PrefixI 'False) (U1 :: Type -> Type))

Functions

Introduction

pjust :: forall (a :: S -> Type) (s :: S). Term s (a :--> PMaybe a) Source #

Construct a PJust value.

@since WIP

pnothing :: forall (a :: S -> Type) (s :: S). Term s (PMaybe a) Source #

Construct a PNothing value.

@since WIP

Predicates

pisJust :: forall (a :: S -> Type) (s :: S). Term s (PMaybe a :--> PBool) Source #

Yields true if the given PMaybe value is of form PJust _.

@since WIP

Eliminators

pfromJust :: forall (a :: S -> Type) (s :: S). Term s (PMaybe a :--> a) Source #

Extracts the element out of a PJust and throws an error if its argument is PNothing.

ptraceIfNothing Source #

Arguments

:: forall (a :: S -> Type) (s :: S). Term s PString

The custom error message.

-> Term s (PMaybe a) 
-> Term s a 

Extracts the element out of a PJust and throws a custom error if it's given a PNothing.

@since WIP

pfromMaybe :: forall (a :: S -> Type) (s :: S). Term s (a :--> (PMaybe a :--> a)) Source #

Extract a PMaybe by providing a default value in case of PJust.

@since WIP

pmaybe :: forall (b :: S -> Type) (a :: S -> Type) (s :: S). Term s (b :--> ((a :--> b) :--> (PMaybe a :--> b))) Source #

Given a default value, a function and a PMaybe value, yields the default value if the PMaybe value is PNothing and applies the function to the value stored in the PJust otherwise.

@since WIP

passertPJust :: forall (a :: S -> Type) (s :: S). Term s (PString :--> (PMaybe a :--> a)) Source #

Extract the value stored in a PMaybe container. If there's no value, throw an error with the given message.

@since WIP

pmapMaybe :: Term s ((a :--> b) :--> (PMaybe a :--> PMaybe b)) Source #

Map underlying value if PMaybe is PJust, do nothing if it is PNothing

@since WIP