Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Contains all the commonly-named folds that aren’t core to the library. In general, this can be seen as a mapping from names you may have heard or read in a paper to how Yaya expects you to achieve the same end. Of course, you can always import this module and use the “common” name as well.
Synopsis
- type Colist a = Nu (XNor a)
- type List a = Mu (XNor a)
- type Nat = Mu Maybe
- type NonEmptyList a = Mu (AndMaybe a)
- newtype Partial a = Partial {
- fromPartial :: Nu (Either a)
- type Stream a = Nu (Pair a)
- apo :: (Projectable (->) t f, Corecursive (->) t f, Functor f) => GCoalgebra (->) (Either t) f a -> a -> t
- cataM :: (Monad m, Recursive (->) t f, Traversable f) => AlgebraM (->) m f a -> t -> m a
- cocontramap :: (Projectable (->) t (f b), Corecursive (->) u (f a), Profunctor f) => (a -> b) -> t -> u
- comap :: (Projectable (->) t (f a), Corecursive (->) u (f b), Bifunctor f) => (a -> b) -> t -> u
- comutu :: (Corecursive (->) t f, Functor f) => GCoalgebra (->) (Either a) f b -> GCoalgebra (->) (Either b) f a -> a -> t
- contramap :: (Recursive (->) t (f b), Steppable (->) u (f a), Profunctor f) => (a -> b) -> t -> u
- gapo :: (Corecursive (->) t f, Functor f) => Coalgebra (->) f b -> GCoalgebra (->) (Either b) f a -> a -> t
- gmutu :: (Comonad w, Comonad v, Recursive (->) t f, Functor f) => DistributiveLaw (->) f w -> DistributiveLaw (->) f v -> GAlgebra (->) (EnvT a w) f b -> GAlgebra (->) (EnvT b v) f a -> t -> a
- histo :: (Recursive (->) t f, Functor f) => GAlgebra (->) (Cofree f) f a -> t -> a
- insidePartial :: (Nu (Either a) -> Nu (Either b)) -> Partial a -> Partial b
- map :: (Recursive (->) t (f a), Steppable (->) u (f b), Bifunctor f) => (a -> b) -> t -> u
- mutu :: (Recursive (->) t f, Functor f) => GAlgebra (->) (Pair a) f b -> GAlgebra (->) (Pair b) f a -> t -> a
- mutuM :: (Monad m, Recursive (->) t f, Traversable f) => GAlgebraM (->) m (Pair a) f b -> GAlgebraM (->) m (Pair b) f a -> t -> m a
- para :: (Steppable (->) t f, Recursive (->) t f, Functor f) => GAlgebra (->) (Pair t) f a -> t -> a
- traverse :: (Recursive (->) t (f a), Steppable (->) u (f b), Bitraversable f, Traversable (f a), Monad m) => (a -> m b) -> t -> m u
- zygo :: (Recursive (->) t f, Functor f) => Algebra (->) f b -> GAlgebra (->) (Pair b) f a -> t -> a
- zygoM :: (Monad m, Recursive (->) t f, Traversable f) => AlgebraM (->) m f b -> GAlgebraM (->) m (Pair b) f a -> t -> m a
Documentation
type NonEmptyList a = Mu (AndMaybe a) Source #
Finite non-empty lists.
Represents partial functions that may eventually return a value (Left
).
NB: This is a newtype so we can create the usual instances.
Partial | |
|
type Stream a = Nu (Pair a) Source #
Always-infinite streams (as opposed to Colist
, which _may_ terminate).
apo :: (Projectable (->) t f, Corecursive (->) t f, Functor f) => GCoalgebra (->) (Either t) f a -> a -> t Source #
A recursion scheme that allows you to return a complete branch when unfolding.
cataM :: (Monad m, Recursive (->) t f, Traversable f) => AlgebraM (->) m f a -> t -> m a Source #
If you have a monadic algebra, you can fold it by distributing the monad over the algebra.
cocontramap :: (Projectable (->) t (f b), Corecursive (->) u (f a), Profunctor f) => (a -> b) -> t -> u Source #
comap :: (Projectable (->) t (f a), Corecursive (->) u (f b), Bifunctor f) => (a -> b) -> t -> u Source #
A version of map
that applies to Corecursive structures.
comutu :: (Corecursive (->) t f, Functor f) => GCoalgebra (->) (Either a) f b -> GCoalgebra (->) (Either b) f a -> a -> t Source #
contramap :: (Recursive (->) t (f b), Steppable (->) u (f a), Profunctor f) => (a -> b) -> t -> u Source #
A more general implementation of contramap
, because it can
also work to, from, or within monomorphic structures.
gapo :: (Corecursive (->) t f, Functor f) => Coalgebra (->) f b -> GCoalgebra (->) (Either b) f a -> a -> t Source #
gmutu :: (Comonad w, Comonad v, Recursive (->) t f, Functor f) => DistributiveLaw (->) f w -> DistributiveLaw (->) f v -> GAlgebra (->) (EnvT a w) f b -> GAlgebra (->) (EnvT b v) f a -> t -> a Source #
map :: (Recursive (->) t (f a), Steppable (->) u (f b), Bifunctor f) => (a -> b) -> t -> u Source #
A more general implementation of fmap
, because it can also work to, from,
or within monomorphic structures, obviating the need for classes like
MonoFunctor
.
mutu :: (Recursive (->) t f, Functor f) => GAlgebra (->) (Pair a) f b -> GAlgebra (->) (Pair b) f a -> t -> a Source #
A recursion scheme that allows two algebras to see each others’ results. (A
generalization of zygo
.) This is an example that falls outside the scope
of “comonadic folds”, but _would_ be covered by “adjoint folds”.
mutuM :: (Monad m, Recursive (->) t f, Traversable f) => GAlgebraM (->) m (Pair a) f b -> GAlgebraM (->) m (Pair b) f a -> t -> m a Source #
para :: (Steppable (->) t f, Recursive (->) t f, Functor f) => GAlgebra (->) (Pair t) f a -> t -> a Source #
A recursion scheme that gives you access to the original structure as you
fold. (A specialization of zygo
.)
traverse :: (Recursive (->) t (f a), Steppable (->) u (f b), Bitraversable f, Traversable (f a), Monad m) => (a -> m b) -> t -> m u Source #
A more general implementation of traverse
, because it
can also work to, from, or within monomorphic structures, obviating the
need for classes like MonoTraversable
.
zygo :: (Recursive (->) t f, Functor f) => Algebra (->) f b -> GAlgebra (->) (Pair b) f a -> t -> a Source #