Fold a structure F
to a value A
.
Fold a structure F
to a value A
, accumulating effects in the monad M
.
Transform a structure F
contained in W
, to a structure G
,
in bottom-up fashion.
Transform a structure F
contained in W
, to a structure G
,
in bottom-up fashion.
Transform a structure F
containing values in W
, to a structure G
,
in bottom-up fashion.
Transform a structure F
containing values in W
, to a structure G
,
in bottom-up fashion.
Provides a type describing the pattern functor of some {co}recursive type
T
.
Provides a type describing the pattern functor of some {co}recursive type
T
. For standard fixed-point types like matryoshka.data.Fix,
Based[Fix[F]]#Base
is simply F
. However, directly recursive types
generally have a less obvious pattern functor. E.g., Based[Cofree[F,
A]]#Base
is EnvT[A, F, ?]
.
A type that is both Recursive and Corecursive.
This is a workaround for a certain use case (e.g., matryoshka.patterns.Diff and matryoshka.patterns.PotentialFailure).
This is a workaround for a certain use case (e.g., matryoshka.patterns.Diff and matryoshka.patterns.PotentialFailure). Define an instance of this rather than Recursive and Corecursive when possible.
Unfold a value A
to a structure F
.
Unfold a value A
to a structure F
, accumulating effects in the monad
M
.
Transform a structure F
to a structure G
, in top-down fashion,
accumulating effects in the monad M
.
Transform a structure F
to a structure G
, in top-down fashion,
accumulating effects in the monad M
.
Transform a structure F
to a structure G
containing values in N
,
in top-down fashion, accumulating effects in the monad M
.
Unfolds for corecursive data types.
This is a workaround for a certain use case (e.g., matryoshka.patterns.Diff and matryoshka.patterns.PotentialFailure).
This is a workaround for a certain use case (e.g., matryoshka.patterns.Diff and matryoshka.patterns.PotentialFailure). Define an instance of this rather than Corecursive when possible.
To avoid diverging implicits with fixed-point types, we need to defer the lookup.
A NaturalTransformation that sequences two types
Fold a structure F
(usually a Functor
) contained in W
(usually a
Comonad
), to a value A
.
Fold a structure F
(usually a Functor
) contained in W
(usually a
Comonad
), to a value A
, accumulating effects in the monad M
.
Unfold a value A
to a structure F
(usually a Functor
), contained in
E
.
Unfold a value A
to a structure F
(usually a Functor
), contained in
E
, accumulating effects in the monad M
.
Fold a structure F
containing values in W
, to a value A
.
An algebra and its dual form an isomorphism.
Fold a structure F
containing values in W
, to a value A
,
accumulating effects in the monad M
.
Unfold a value A
to a structure F
containing values in N
.
Unfold a value A
to a structure F
containing values in N
,
accumulating effects in the monad M
.
Like Zip
, but it can fail to merge, so it’s much more general.
Folds for recursive data types.
This is a workaround for a certain use case (e.g., matryoshka.patterns.Diff and matryoshka.patterns.PotentialFailure).
This is a workaround for a certain use case (e.g., matryoshka.patterns.Diff and matryoshka.patterns.PotentialFailure). Define an instance of this rather than Recursive when possible.
Transform a structure F
to a structure G
.
Transform a structure F
to a structure G
. For a top-down
transformation, T#Base
must be F
, and for a bottom-up transformation,
T#Base
must be G
.
Transform a structure F
to a structure G
, accumulating effects in the
monad M
.
Transform a structure F
to a structure G
, accumulating effects in the
monad M
. For a top-down transformation, T#Base
must be F
, and for a
bottom-up transformation, T#Base
must be G
.
An extractor to make it easier to pattern-match on arbitrary Recursive structures.
An extractor to make it easier to pattern-match on arbitrary Recursive structures.
NB: This extractor is irrufutable and doesn’t break exhaustiveness checking.
Aligns “These” into a single structure, short-circuting when we hit a “This” or “That”.
Turns any F-algebra, into a transform that attributes the tree with the results for each node.
A function to be called like attributeElgotM[M](myElgotAlgebraM)
.
Generates an infinite sequence from two seed values.
Similar to a hylomorphism, this composes a futumorphism and a histomorphism.
cata ⋘ futu
cataM ⋘ futuM
elgotZygo ⋘ ana
elgotZygoM ⋘ anaM
Count the instances of form
in the structure.
This packages contains fixed-point operators as well as instances of recursion schemes for various extant data types.
This packages contains fixed-point operators as well as instances of recursion schemes for various extant data types.
The reason these are relegated to their own package is because, in general, you should eschew using them directly, but rather rely on the type class constraints, and only require specific types at the boundaries.
Useful for ignoring the annotation when folding a cofree.
This implicit allows Delay implicits to be found when searching for a traditionally-defined instance.
See delayEqual
.
A general DistributiveLaw for the case where the scalaz.Comonad is also scalaz.Applicative.
A general DistributiveLaw for the case where the scalaz.Comonad is also scalaz.Distributive.
Allows for more complex unfolds, like
futuGApo(φ0: Coalgebra[F, B], φ: GCoalgebra[λ[α => EitherT[Free[F, ?], B, α]], F, A])
histo ⋘ ana
cata ⋘ elgotGApo
Composition of an elgot-anamorphism and an elgot-catamorphism that avoids building the intermediate recursive data structure.
Composition of an elgot-anamorphism and an elgot-catamorphism that avoids building the intermediate recursive data structure.
elgotCata ⋘ elgotAna
cataM ⋘ elgotGApoM
Returns (on the left) the first element that passes f
.
There is a fold/unfold isomorphism for any AlgebraIso.
There is a fold prism for any AlgebraPrism.
A generalized version of a hylomorphism that composes any coalgebra and algebra.
A generalized version of a hylomorphism that composes any coalgebra and
algebra. (gcata ⋘ gana
)
A Kleisli ghylo
(gcataM ⋘ ganaM
)
The largest number of hops from a node to a leaf.
The hylomorphism is the fundamental operation of recursion schemes.
The hylomorphism is the fundamental operation of recursion schemes. It
first applies ψ
, recursively breaking an A
into layers of F
, then
applies φ
, combining the F
s into a B
. It can also be seen as the
(fused) composition of an anamorphism and a catamorphism that avoids
building the intermediate recursive data structure.
A Kleisli hylomorphism.
Makes it possible to use ElgotAlgebras on EnvT.
Makes it possible to use ElgotAlgebras on EnvT.
Merges a tuple of functors, if possible.
Converts a failable fold into a non-failable, by returning the default upon failure.
Converts a failable fold into a non-failable, by simply returning the argument upon failure.
Repeatedly applies the function to the result as long as it returns Some.
Repeatedly applies the function to the result as long as it returns Some. Finally returns the last non-None value (which may be the initial input).
The number of nodes in this structure.
Replaces all instances of original
in the structure with replacement
.
Converts a fixed-point structure into a generic Tree.
Converts a fixed-point structure into a generic Tree.
One use of this is using .cata(toTree).drawTree
rather than .show
to
get a pretty-printed tree.
There is an unfold prism for any CoalgebraPrism.
Collects the set of all subtrees.
Combines a tuple of zippable functors.
Generic algebras that operate over most functors.
Operations that modify algebras in various ways to make them easier to combine with others.
Natural transformations required for generalized folds and unfolds.
Traversals that apply an unfold and a fold in a single pass.
Generalized folds, unfolds, and refolds.