liqwid-plutarch-extra-3.21.1: A collection of Plutarch extras from Liqwid Labs
Safe HaskellSafe-Inferred
LanguageHaskell2010

Plutarch.Extra.Star

Synopsis

Type

newtype PStar (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S) Source #

The (profunctorial) view over a Kleisli arrow. Its name comes from category theory, as it is one of the ways we can lift a functor (in this case, f) into a profunctor.

This essentially enables us to work with a :--> f b using PSemigroupoid and PCategory operations as easily as we do a :--> b, provided that f is at least a PBind. With the addition of a PApplicative (for identities), we become a full PCategory. Furthermore, we can also compose freely with ordinary Plutarch :--> at both ends of a PStar, provided f is at least PFunctor.

Since: 3.0.1

Constructors

PStar (Term s (a :--> f b)) 

Instances

Instances details
(PApplicative f, PBind f) => PCategory (PStar f) Source #

Strengthening f by adding PApplicative gives us an identity, which makes us a full category, on par with Plut as evidenced by :-->. , @since 3.0.1

Instance details

Defined in Plutarch.Extra.Star

Methods

pidentity :: forall (a :: S -> Type) (s :: S). (PContraSubcategory (PStar f) a, PCoSubcategory (PStar f) a) => Term s (PStar f a a) Source #

PBind f => PSemigroupoid (PStar f) Source #

Strengthening f to PBind allows us to compose PStar f computations like ordinary Plutarch functions.

Since: 3.0.1

Instance details

Defined in Plutarch.Extra.Star

Methods

(#>>>) :: forall (a :: S -> Type) (b :: S -> Type) (c :: S -> Type) (s :: S). (PContraSubcategory (PStar f) a, PContraSubcategory (PStar f) b, PCoSubcategory (PStar f) b, PCoSubcategory (PStar f) c) => Term s (PStar f a b) -> Term s (PStar f b c) -> Term s (PStar f a c) Source #

PFunctor f => PProfunctor (PStar f) Source #

If f is at least a PFunctor, we can pre-process and post-process work done in PStar f using pure functions.

Since: 3.1.0

Instance details

Defined in Plutarch.Extra.Star

Associated Types

type PContraSubcategory (PStar f) :: (S -> Type) -> Constraint Source #

type PCoSubcategory (PStar f) :: (S -> Type) -> Constraint Source #

Methods

pdimap :: forall (a :: S -> Type) (b :: S -> Type) (c :: S -> Type) (d :: S -> Type) (s :: S). (PContraSubcategory (PStar f) a, PContraSubcategory (PStar f) b, PCoSubcategory (PStar f) c, PCoSubcategory (PStar f) d) => Term s ((a :--> b) :--> ((c :--> d) :--> (PStar f b c :--> PStar f a d))) Source #

plmap :: forall (a :: S -> Type) (b :: S -> Type) (c :: S -> Type) (s :: S). (PContraSubcategory (PStar f) a, PContraSubcategory (PStar f) b, PCoSubcategory (PStar f) c) => Term s ((a :--> b) :--> (PStar f b c :--> PStar f a c)) Source #

prmap :: forall (a :: S -> Type) (c :: S -> Type) (d :: S -> Type) (s :: S). (PContraSubcategory (PStar f) a, PCoSubcategory (PStar f) c, PCoSubcategory (PStar f) d) => Term s ((c :--> d) :--> (PStar f a c :--> PStar f a d)) Source #

PApplicative f => PApplicative (PStar f a) Source #

Strengthening to PApplicative for f allows arbitrary lifts into PStar f a, using the same 'view' as in the PFunctor instance.

Since: 3.0.1

Instance details

Defined in Plutarch.Extra.Star

Methods

ppure :: forall (a0 :: S -> Type) (s :: S). PSubcategory (PStar f a) a0 => Term s (a0 :--> PStar f a a0) Source #

PApply f => PApply (PStar f a) Source #

Strengthening to PApply for f allows us to combine together computations in PStar f a using the same 'view' as in the PFunctor instance.

Since: 3.0.1

Instance details

Defined in Plutarch.Extra.Star

Methods

pliftA2 :: forall (a0 :: S -> Type) (b :: S -> Type) (c :: S -> Type) (s :: S). (PSubcategory (PStar f a) a0, PSubcategory (PStar f a) b, PSubcategory (PStar f a) c) => Term s ((a0 :--> (b :--> c)) :--> (PStar f a a0 :--> (PStar f a b :--> PStar f a c))) Source #

PBind f => PBind (PStar f a) Source #

Strengthening to PBind for f allows dynamic control flow on the basis of the result of a PStar f a, using the same 'view' as the PFunctor instance.

Since: 3.0.1

Instance details

Defined in Plutarch.Extra.Star

Methods

(#>>=) :: forall (a0 :: S -> Type) (b :: S -> Type) (s :: S). (PSubcategory (PStar f a) a0, PSubcategory (PStar f a) b) => Term s (PStar f a a0) -> Term s (a0 :--> PStar f a b) -> Term s (PStar f a b) Source #

PFunctor f => PFunctor (PStar f a) Source #

This essentially makes PStar f a b equivalent to the Haskell ReaderT a f b: that is, a read-only environment of type a producing a result of type b in an effect f. If f is only a PFunctor, we can only lift, but not compose.

Since: 3.0.1

Instance details

Defined in Plutarch.Extra.Star

Associated Types

type PSubcategory (PStar f a) :: (S -> Type) -> Constraint Source #

Methods

pfmap :: forall (a0 :: S -> Type) (b :: S -> Type) (s :: S). (PSubcategory (PStar f a) a0, PSubcategory (PStar f a) b) => Term s ((a0 :--> b) :--> (PStar f a a0 :--> PStar f a b)) Source #

pfconst :: forall (a0 :: S -> Type) (b :: S -> Type) (s :: S). (PSubcategory (PStar f a) a0, PSubcategory (PStar f a) b) => Term s (a0 :--> (PStar f a b :--> PStar f a a0)) Source #

DerivePlutusType (PStar f a b) Source #

Since: 3.0.1

Instance details

Defined in Plutarch.Extra.Star

Associated Types

type DPTStrat (PStar f a b) Source #

PlutusType (PStar f a b) Source # 
Instance details

Defined in Plutarch.Extra.Star

Associated Types

type PInner (PStar f a b) :: PType Source #

type PCovariant' (PStar f a b) Source #

type PContravariant' (PStar f a b) Source #

type PVariant' (PStar f a b) Source #

Methods

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

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

Generic (PStar f a b s) Source # 
Instance details

Defined in Plutarch.Extra.Star

Associated Types

type Rep (PStar f a b s) :: Type -> Type Source #

Methods

from :: PStar f a b s -> Rep (PStar f a b s) x Source #

to :: Rep (PStar f a b s) x -> PStar f a b s Source #

type PCoSubcategory (PStar f) Source # 
Instance details

Defined in Plutarch.Extra.Star

type PContraSubcategory (PStar f) Source # 
Instance details

Defined in Plutarch.Extra.Star

type PSubcategory (PStar f a) Source # 
Instance details

Defined in Plutarch.Extra.Star

type DPTStrat (PStar f a b) Source # 
Instance details

Defined in Plutarch.Extra.Star

type PContravariant' (PStar f a b) Source # 
Instance details

Defined in Plutarch.Extra.Star

type PContravariant' (PStar f a b) = All2 PContravariant'' (PCode (PStar f a b))
type PCovariant' (PStar f a b) Source # 
Instance details

Defined in Plutarch.Extra.Star

type PCovariant' (PStar f a b) = All2 PCovariant'' (PCode (PStar f a b))
type PInner (PStar f a b) Source #

Since: 3.0.1

Instance details

Defined in Plutarch.Extra.Star

type PInner (PStar f a b) = DerivedPInner (DPTStrat (PStar f a b)) (PStar f a b)
type PVariant' (PStar f a b) Source # 
Instance details

Defined in Plutarch.Extra.Star

type PVariant' (PStar f a b) = All2 PVariant'' (PCode (PStar f a b))
type Rep (PStar f a b s) Source #

Since: 3.0.1

Instance details

Defined in Plutarch.Extra.Star

type Rep (PStar f a b s) = D1 ('MetaData "PStar" "Plutarch.Extra.Star" "liqwid-plutarch-extra-3.21.1-KPadsMN5oqEA2Ctxwq6qig" 'True) (C1 ('MetaCons "PStar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s (a :--> f b)))))

Functions

papplyStar :: forall (a :: S -> Type) (b :: S -> Type) (f :: (S -> Type) -> S -> Type) (s :: S). Term s (a :--> (PStar f a b :--> f b)) Source #

'Run' the PStar as the function it secretly is. Useful for cases where you want to build up a large computation using PStar instances, then execute.

Since: 3.0.1