plutarch-1.9.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Plutarch.Internal.TryFrom

Synopsis

Documentation

class PSubtype a b => PTryFrom (a :: PType) (b :: PType) Source #

PTryFrom a b represents a subtyping relationship between a and b, and a way to go from a to b. Laws: - (punsafeCoerce . fst) $ tcont (ptryFrom x) ≡ pure x

Instances

Instances details
PTryFrom PData PData Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

Associated Types

type PTryFromExcess PData PData :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s PData, Reduce (PTryFromExcess PData PData s)) -> Term s r) -> Term s r Source #

PTryFrom PInteger PPositive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.TryFrom

Associated Types

type PTryFromExcess PInteger PPositive :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PInteger -> ((Term s PPositive, Reduce (PTryFromExcess PInteger PPositive s)) -> Term s r) -> Term s r Source #

(PIsData a, PTryFrom PData (PAsData a)) => PTryFrom PData (PDataNewtype a) Source #

Since: 1.7.0

Instance details

Defined in Plutarch.Builtin

Associated Types

type PTryFromExcess PData (PDataNewtype a) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PDataNewtype a), Reduce (PTryFromExcess PData (PDataNewtype a) s)) -> Term s r) -> Term s r Source #

PTryFrom PData (PAsData (PDataNewtype a)) Source #

Since: 1.7.0

Instance details

Defined in Plutarch.Builtin

Associated Types

type PTryFromExcess PData (PAsData (PDataNewtype a)) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData (PDataNewtype a)), Reduce (PTryFromExcess PData (PAsData (PDataNewtype a)) s)) -> Term s r) -> Term s r Source #

PTryFrom PData (PAsData PBool) Source #

Since: 1.7.0

Instance details

Defined in Plutarch.Internal.TryFrom

Associated Types

type PTryFromExcess PData (PAsData PBool) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData PBool), Reduce (PTryFromExcess PData (PAsData PBool) s)) -> Term s r) -> Term s r Source #

PTryFrom PData (PAsData PByteString) Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData PByteString), Reduce (PTryFromExcess PData (PAsData PByteString) s)) -> Term s r) -> Term s r Source #

(PTryFrom PData (PAsData a), PIsData a) => PTryFrom PData (PAsData (PBuiltinList (PAsData a))) Source #

Recover a `PBuiltinList (PAsData a)`

Instance details

Defined in Plutarch.Internal.TryFrom

Associated Types

type PTryFromExcess PData (PAsData (PBuiltinList (PAsData a))) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData (PBuiltinList (PAsData a))), Reduce (PTryFromExcess PData (PAsData (PBuiltinList (PAsData a))) s)) -> Term s r) -> Term s r Source #

PTryFrom PData (PAsData (PBuiltinList PData)) Source #

This verifies a list to be indeed a list but doesn't recover the inner data use this instance instead of the one for `PData (PAsData (PBuiltinList (PAsData a)))` as this is O(1) instead of O(n)

Instance details

Defined in Plutarch.Internal.TryFrom

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData (PBuiltinList PData)), Reduce (PTryFromExcess PData (PAsData (PBuiltinList PData)) s)) -> Term s r) -> Term s r Source #

(PTryFrom PData a, a ~ PAsData a', PIsData a', PTryFrom PData b, b ~ PAsData b', PIsData b') => PTryFrom PData (PAsData (PBuiltinPair a b)) Source #

Recover a `PAsData (PBuiltinPair a b)`

Instance details

Defined in Plutarch.Internal.TryFrom

Associated Types

type PTryFromExcess PData (PAsData (PBuiltinPair a b)) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData (PBuiltinPair a b)), Reduce (PTryFromExcess PData (PAsData (PBuiltinPair a b)) s)) -> Term s r) -> Term s r Source #

PTryFrom PData (PAsData PData) Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

Associated Types

type PTryFromExcess PData (PAsData PData) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData PData), Reduce (PTryFromExcess PData (PAsData PData) s)) -> Term s r) -> Term s r Source #

PTryFrom PData (PAsData PInteger) Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

Associated Types

type PTryFromExcess PData (PAsData PInteger) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData PInteger), Reduce (PTryFromExcess PData (PAsData PInteger) s)) -> Term s r) -> Term s r Source #

(PTryFrom (PBuiltinList PData) (PDataRecord as), PTryFromExcess (PBuiltinList PData) (PDataRecord as) ~ HRecP ase) => PTryFrom PData (PAsData (PDataRecord as)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Associated Types

type PTryFromExcess PData (PAsData (PDataRecord as)) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData (PDataRecord as)), Reduce (PTryFromExcess PData (PAsData (PDataRecord as)) s)) -> Term s r) -> Term s r Source #

PTryFrom PData (PDataSum ys) => PTryFrom PData (PAsData (PDataSum ys)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Associated Types

type PTryFromExcess PData (PAsData (PDataSum ys)) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData (PDataSum ys)), Reduce (PTryFromExcess PData (PAsData (PDataSum ys)) s)) -> Term s r) -> Term s r Source #

(PTryFrom PData a, PTryFrom PData b) => PTryFrom PData (PAsData (PEitherData a b)) Source #

@since WIP

Instance details

Defined in Plutarch.Either

Associated Types

type PTryFromExcess PData (PAsData (PEitherData a b)) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData (PEitherData a b)), Reduce (PTryFromExcess PData (PAsData (PEitherData a b)) s)) -> Term s r) -> Term s r Source #

PTryFrom PData (PAsData PPositive) Source #

@since WIP

Instance details

Defined in Plutarch.Internal.TryFrom

Associated Types

type PTryFromExcess PData (PAsData PPositive) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData PPositive), Reduce (PTryFromExcess PData (PAsData PPositive) s)) -> Term s r) -> Term s r Source #

PTryFrom PData (PAsData PRational) Source #

NOTE: This instance produces a verified PPositive as the excess output.

Instance details

Defined in Plutarch.Rational

Associated Types

type PTryFromExcess PData (PAsData PRational) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData PRational), Reduce (PTryFromExcess PData (PAsData PRational) s)) -> Term s r) -> Term s r Source #

SumValidation 0 ys => PTryFrom PData (PDataSum ys) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Associated Types

type PTryFromExcess PData (PDataSum ys) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PDataSum ys), Reduce (PTryFromExcess PData (PDataSum ys) s)) -> Term s r) -> Term s r Source #

(PTryFrom PData a, PTryFrom PData b) => PTryFrom PData (PEitherData a b) Source #

@since WIP

Instance details

Defined in Plutarch.Either

Associated Types

type PTryFromExcess PData (PEitherData a b) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PEitherData a b), Reduce (PTryFromExcess PData (PEitherData a b) s)) -> Term s r) -> Term s r Source #

(Helper2 (PSubtype' PData pty) pty, PTryFrom (PBuiltinList PData) (PDataRecord as), PTryFromExcess (PBuiltinList PData) (PDataRecord as) ~ HRecP ase) => PTryFrom (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Associated Types

type PTryFromExcess (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as)) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s (PBuiltinList PData) -> ((Term s (PDataRecord ((name ':= pty) ': as)), Reduce (PTryFromExcess (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as)) s)) -> Term s r) -> Term s r Source #

PTryFrom (PBuiltinList PData) (PDataRecord ('[] :: [PLabeledType])) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

Associated Types

type PTryFromExcess (PBuiltinList PData) (PDataRecord '[]) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s (PBuiltinList PData) -> ((Term s (PDataRecord '[]), Reduce (PTryFromExcess (PBuiltinList PData) (PDataRecord '[]) s)) -> Term s r) -> Term s r Source #

type family PTryFromExcess a b :: PType Source #

Instances

Instances details
type PTryFromExcess PData PData Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

type PTryFromExcess PInteger PPositive Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

type PTryFromExcess PData (PDataNewtype a) Source # 
Instance details

Defined in Plutarch.Builtin

type PTryFromExcess PData (PAsData (PDataNewtype a)) Source # 
Instance details

Defined in Plutarch.Builtin

type PTryFromExcess PData (PAsData PBool) Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

type PTryFromExcess PData (PAsData PByteString) Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

type PTryFromExcess PData (PAsData (PBuiltinList (PAsData a))) Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

type PTryFromExcess PData (PAsData (PBuiltinList PData)) Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

type PTryFromExcess PData (PAsData (PBuiltinPair a b)) Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

type PTryFromExcess PData (PAsData PData) Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

type PTryFromExcess PData (PAsData PInteger) Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

type PTryFromExcess PData (PAsData (PDataRecord as)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PTryFromExcess PData (PAsData (PDataSum ys)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PTryFromExcess PData (PAsData (PEitherData a b)) Source # 
Instance details

Defined in Plutarch.Either

type PTryFromExcess PData (PAsData PPositive) Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

type PTryFromExcess PData (PAsData PRational) Source # 
Instance details

Defined in Plutarch.Rational

type PTryFromExcess PData (PDataSum ys) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PTryFromExcess PData (PDataSum ys) = Const () :: S -> Type
type PTryFromExcess PData (PEitherData a b) Source # 
Instance details

Defined in Plutarch.Either

type PTryFromExcess (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as)) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

type PTryFromExcess (PBuiltinList PData) (PDataRecord ((name ':= pty) ': as))
type PTryFromExcess (PBuiltinList PData) (PDataRecord ('[] :: [PLabeledType])) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal

ptryFrom' :: forall s r. PTryFrom a b => Term s a -> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r) -> Term s r Source #

ptryFrom :: forall b a s r. PTryFrom a b => Term s a -> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r) -> Term s r Source #

type family PSubtype (a :: PType) (b :: PType) :: Constraint where ... Source #

Equations

PSubtype a b = (PSubtype' a b ~ 'PSubtypeRelation, PSubtypeHelper a b (PSubtype' a b)) 

type family PSubtype' (a :: PType) (b :: PType) :: PSubtypeRelation where ... Source #

Equations

PSubtype' a a = 'PSubtypeRelation 
PSubtype' a b = Helper a b (PInner b) 

pupcast :: forall a b s. PSubtype a b => Term s b -> Term s a Source #

pupcastF :: forall a b (p :: PType -> PType) s. (PSubtype a b, PCovariant p) => Proxy p -> Term s (p b) -> Term s (p a) Source #

pdowncastF :: forall a b (p :: PType -> PType) s. (PSubtype a b, PContravariant p) => Proxy p -> Term s (p a) -> Term s (p b) Source #