Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Plutarch.Extra.Traversable
Synopsis
- class PFunctor t => PTraversable (t :: (S -> Type) -> S -> Type) where
- ptraverse :: forall (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PApplicative f, PSubcategory f a, PSubcategory f b, PSubcategory f (t b), PSubcategory t a, PSubcategory t b) => Term s ((a :--> f b) :--> (t a :--> f (t b)))
- ptraverse_ :: forall (b :: S -> Type) (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PApplicative f, PSubcategory f b, PBoring b, PSubcategory t a) => Term s ((a :--> f b) :--> (t a :--> f b))
- class PTraversable t => PSemiTraversable (t :: (S -> Type) -> S -> Type) where
- psemitraverse :: forall (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PApply f, PSubcategory f a, PSubcategory f b, PSubcategory f (t b)) => Term s ((a :--> f b) :--> (t a :--> f (t b)))
- psemitraverse_ :: forall (b :: S -> Type) (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PApply f, PSubcategory f b, PBoring b, PSubcategory t a) => Term s ((a :--> f b) :--> (t a :--> f b))
- psemifold :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PSemiTraversable t, forall (s' :: S). Semigroup (Term s' a), PSubcategory t a) => Term s (t a :--> a)
- psemifoldMap :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PSemiTraversable t, forall (s' :: S). Semigroup (Term s' b), PSubcategory t a) => Term s ((a :--> b) :--> (t a :--> b))
- psemifoldComonad :: forall (t :: (S -> Type) -> S -> Type) (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PComonad f, PSemiTraversable t, forall (s' :: S). Semigroup (Term s' (f b)), PSubcategory f b, PSubcategory t a) => Term s ((a :--> f b) :--> (t a :--> b))
- pfold :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PTraversable t, forall (s' :: S). Monoid (Term s' a), PSubcategory t a) => Term s (t a :--> a)
- pfoldMap :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PTraversable t, forall (s' :: S). Monoid (Term s' b), PSubcategory t a) => Term s ((a :--> b) :--> (t a :--> b))
- pfoldComonad :: forall (t :: (S -> Type) -> S -> Type) (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PComonad f, PTraversable t, forall (s' :: S). Monoid (Term s' (f b)), PSubcategory f b, PSubcategory t a) => Term s ((a :--> f b) :--> (t a :--> b))
- psum :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PTraversable t, PNum a, PSubcategory t a) => Term s (t a :--> a)
- plength :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PTraversable t, PSubcategory t a) => Term s (t a :--> PInteger)
- pany :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PTraversable t, PSubcategory t a) => Term s ((a :--> PBool) :--> (t a :--> PBool))
- pall :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PTraversable t, PSubcategory t a) => Term s ((a :--> PBool) :--> (t a :--> PBool))
Type classes
class PFunctor t => PTraversable (t :: (S -> Type) -> S -> Type) where Source #
Since: 1.0.0
Methods
ptraverse :: forall (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PApplicative f, PSubcategory f a, PSubcategory f b, PSubcategory f (t b), PSubcategory t a, PSubcategory t b) => Term s ((a :--> f b) :--> (t a :--> f (t b))) Source #
ptraverse_ :: forall (b :: S -> Type) (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PApplicative f, PSubcategory f b, PBoring b, PSubcategory t a) => Term s ((a :--> f b) :--> (t a :--> f b)) Source #
This avoids re-building the input PTraversable
if we end up throwing
it away anyway. In the case where we only care about the effect, and
don't need the PTraversable
afterwards, this can be more efficient.
Note
This is 'boredom-polymorphic' to ensure that we don't run into issues
with PSubcategory
constraints. This is why we choose the order of type
variables as we do: it allows you to easily choose which PBoring
thing
you want.
Since: 1.2.0
Instances
class PTraversable t => PSemiTraversable (t :: (S -> Type) -> S -> Type) where Source #
Since: 1.0.0
Methods
psemitraverse :: forall (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PApply f, PSubcategory f a, PSubcategory f b, PSubcategory f (t b)) => Term s ((a :--> f b) :--> (t a :--> f (t b))) Source #
psemitraverse_ :: forall (b :: S -> Type) (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PApply f, PSubcategory f b, PBoring b, PSubcategory t a) => Term s ((a :--> f b) :--> (t a :--> f b)) Source #
Instances
PSemiTraversable PIdentity Source # | Since: 1.0.0 |
Defined in Plutarch.Extra.Traversable Methods psemitraverse :: forall (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PApply f, PSubcategory f a, PSubcategory f b, PSubcategory f (PIdentity b)) => Term s ((a :--> f b) :--> (PIdentity a :--> f (PIdentity b))) Source # psemitraverse_ :: forall (b :: S -> Type) (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PApply f, PSubcategory f b, PBoring b, PSubcategory PIdentity a) => Term s ((a :--> f b) :--> (PIdentity a :--> f b)) Source # | |
PSemiTraversable PSum Source # | Since: 1.0.0 |
Defined in Plutarch.Extra.Traversable Methods psemitraverse :: forall (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PApply f, PSubcategory f a, PSubcategory f b, PSubcategory f (PSum b)) => Term s ((a :--> f b) :--> (PSum a :--> f (PSum b))) Source # psemitraverse_ :: forall (b :: S -> Type) (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PApply f, PSubcategory f b, PBoring b, PSubcategory PSum a) => Term s ((a :--> f b) :--> (PSum a :--> f b)) Source # | |
PSemiTraversable (PPair a) Source # | Since: 1.0.0 |
Defined in Plutarch.Extra.Traversable Methods psemitraverse :: forall (f :: (S -> Type) -> S -> Type) (a0 :: S -> Type) (b :: S -> Type) (s :: S). (PApply f, PSubcategory f a0, PSubcategory f b, PSubcategory f (PPair a b)) => Term s ((a0 :--> f b) :--> (PPair a a0 :--> f (PPair a b))) Source # psemitraverse_ :: forall (b :: S -> Type) (f :: (S -> Type) -> S -> Type) (a0 :: S -> Type) (s :: S). (PApply f, PSubcategory f b, PBoring b, PSubcategory (PPair a) a0) => Term s ((a0 :--> f b) :--> (PPair a a0 :--> f b)) Source # | |
PSemiTraversable (PTagged tag) Source # | Since: 1.2.0 |
Defined in Plutarch.Extra.Tagged Methods psemitraverse :: forall (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PApply f, PSubcategory f a, PSubcategory f b, PSubcategory f (PTagged tag b)) => Term s ((a :--> f b) :--> (PTagged tag a :--> f (PTagged tag b))) Source # psemitraverse_ :: forall (b :: S -> Type) (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PApply f, PSubcategory f b, PBoring b, PSubcategory (PTagged tag) a) => Term s ((a :--> f b) :--> (PTagged tag a :--> f b)) Source # |
Functions
Folds
psemifold :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PSemiTraversable t, forall (s' :: S). Semigroup (Term s' a), PSubcategory t a) => Term s (t a :--> a) Source #
Collapse a non-empty 'structure' full of a Semigroup
.
Since: 1.2.0
psemifoldMap :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PSemiTraversable t, forall (s' :: S). Semigroup (Term s' b), PSubcategory t a) => Term s ((a :--> b) :--> (t a :--> b)) Source #
Collapse a non-empty 'structure' with a projection into a Semigroup
.
Since: 1.2.0
psemifoldComonad :: forall (t :: (S -> Type) -> S -> Type) (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PComonad f, PSemiTraversable t, forall (s' :: S). Semigroup (Term s' (f b)), PSubcategory f b, PSubcategory t a) => Term s ((a :--> f b) :--> (t a :--> b)) Source #
Collapse a non-empty 'structure' with a projection into a PComonad
.
This is the most general semifold possible.
Since: 1.2.0
pfold :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PTraversable t, forall (s' :: S). Monoid (Term s' a), PSubcategory t a) => Term s (t a :--> a) Source #
Collapse a possibly empty 'structure' full of a Monoid
.
Since: 1.0.0
pfoldMap :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PTraversable t, forall (s' :: S). Monoid (Term s' b), PSubcategory t a) => Term s ((a :--> b) :--> (t a :--> b)) Source #
Collapse a possibly empty 'structure' with a projection into a Monoid
.
Since: 1.0.0
pfoldComonad :: forall (t :: (S -> Type) -> S -> Type) (f :: (S -> Type) -> S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S). (PComonad f, PTraversable t, forall (s' :: S). Monoid (Term s' (f b)), PSubcategory f b, PSubcategory t a) => Term s ((a :--> f b) :--> (t a :--> b)) Source #
Collapse a possibly empty 'structure' with a projection into a
PComonad
. This is the most general fold possible.
Since: 1.0.0
Specialized folds
psum :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PTraversable t, PNum a, PSubcategory t a) => Term s (t a :--> a) Source #
'Add up' all the elements in the structure.
Since: 1.0.0
plength :: forall (t :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S). (PTraversable t, PSubcategory t a) => Term s (t a :--> PInteger) Source #
Counts the number of elements in the 'structure'.
Since: 1.0.0