Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- type Algebra f a = f a -> a
- type GAlgebra w f a = f (w a) -> a
- type ElgotAlgebra w f a = w (f a) -> a
- type AlgebraM m f a = f a -> m a
- type GAlgebraM m w f a = f (w a) -> m a
- type ElgotAlgebraM m w f a = w (f a) -> m a
- type Coalgebra f a = a -> f a
- type GCoalgebra m f a = a -> f (m a)
- type ElgotCoalgebra m f a = a -> m (f a)
- type CoalgebraM m f a = a -> m (f a)
- type GCoalgebraM m n f a = a -> m (f (n a))
- class Projectable t f | t -> f where
- class Projectable t f => Steppable t f | t -> f where
- class Recursive t f | t -> f where
- class Corecursive t f | t -> f where
- recursiveEq :: (Recursive t f, Steppable u f, Functor f, Foldable f, Eq1 f) => t -> u -> Bool
- recursiveShowsPrec :: (Recursive t f, Show1 f) => Int -> t -> ShowS
- data Mu f = Mu (forall a. Algebra f a -> a)
- data Nu f where
- zipAlgebras :: Functor f => Algebra f a -> Algebra f b -> Algebra f (a, b)
- lowerDay :: Projectable t g => Algebra (Day f g) a -> Algebra f (t -> a)
- cata2 :: (Recursive t f, Projectable u g) => Algebra (Day f g) a -> t -> u -> a
- lowerAlgebra :: (Functor f, Comonad w) => DistributiveLaw f w -> GAlgebra w f a -> Algebra f (w a)
- lowerAlgebraM :: (Applicative m, Traversable f, Comonad w, Traversable w) => DistributiveLaw f w -> GAlgebraM m w f a -> AlgebraM m f (w a)
- lowerCoalgebra :: (Functor f, Monad m) => DistributiveLaw m f -> GCoalgebra m f a -> Coalgebra f (m a)
- lowerCoalgebraM :: (Applicative m, Traversable f, Monad n, Traversable n) => DistributiveLaw n f -> GCoalgebraM m n f a -> CoalgebraM m f (n a)
- gcata :: (Recursive t f, Functor f, Comonad w) => DistributiveLaw f w -> GAlgebra w f a -> t -> a
- elgotCata :: (Recursive t f, Functor f, Comonad w) => DistributiveLaw f w -> ElgotAlgebra w f a -> t -> a
- gcataM :: (Monad m, Recursive t f, Traversable f, Comonad w, Traversable w) => DistributiveLaw f w -> GAlgebraM m w f a -> t -> m a
- elgotCataM :: (Monad m, Recursive t f, Traversable f, Comonad w, Traversable w) => DistributiveLaw f w -> ElgotAlgebraM m w f a -> t -> m a
- ezygoM :: (Monad m, Recursive t f, Traversable f) => AlgebraM m f b -> ElgotAlgebraM m ((,) b) f a -> t -> m a
- gana :: (Corecursive t f, Functor f, Monad m) => DistributiveLaw m f -> GCoalgebra m f a -> a -> t
- elgotAna :: (Corecursive t f, Functor f, Monad m) => DistributiveLaw m f -> ElgotCoalgebra m f a -> a -> t
- lambek :: (Steppable t f, Recursive t f, Functor f) => Coalgebra f t
- colambek :: (Projectable t f, Corecursive t f, Functor f) => Algebra f t
- type DistributiveLaw f g = forall a. f (g a) -> g (f a)
- distIdentity :: Functor f => DistributiveLaw f Identity
- seqIdentity :: Functor f => DistributiveLaw Identity f
- distTuple :: Functor f => Algebra f a -> DistributiveLaw f ((,) a)
- distEnvT :: Functor f => Algebra f a -> DistributiveLaw f w -> DistributiveLaw f (EnvT a w)
- seqEither :: Functor f => Coalgebra f a -> DistributiveLaw (Either a) f
- attributeAlgebra :: (Steppable t (EnvT a f), Functor f) => Algebra f a -> Algebra f t
- attributeCoalgebra :: Coalgebra f a -> Coalgebra (EnvT a f) a
- ignoringAttribute :: Algebra f a -> Algebra (EnvT b f) a
- unFree :: Steppable t f => Algebra (FreeF f t) t
- constEmbed :: Algebra (Const a) a
- constProject :: Coalgebra (Const a) a
- constCata :: Algebra (Const b) a -> b -> a
- constAna :: Coalgebra (Const b) a -> a -> b
- class HFunctor h where
- hmap :: (forall a. f a -> g a) -> h f a -> h g a
- class DFunctor d where
- dmap :: (forall a. f a -> g a) -> d f -> d g
- type BialgebraIso f a = Iso' (f a) a
- type AlgebraPrism f a = Prism' (f a) a
- type CoalgebraPrism f a = Prism' a (f a)
- cursiveIso :: Steppable t f => BialgebraIso f t
- birecursiveIso :: (Recursive t f, Corecursive t f) => BialgebraIso f a -> Iso' t a
- recursivePrism :: (Recursive t f, Corecursive t f, Traversable f) => AlgebraPrism f a -> Prism' t a
Documentation
type ElgotAlgebra w f a = w (f a) -> a Source #
type ElgotAlgebraM m w f a = w (f a) -> m a Source #
type GCoalgebra m f a = a -> f (m a) Source #
type ElgotCoalgebra m f a = a -> m (f a) Source #
type CoalgebraM m f a = a -> m (f a) Source #
Note that using a CoalgebraM
“directly” is partial (e.g., with anaM
).
However, `ana . Compose` can accept a CoalgebraM
and produce something
like an effectful stream.
type GCoalgebraM m n f a = a -> m (f (n a)) Source #
class Projectable t f | t -> f where Source #
This type class is lawless on its own, but there exist types that can’t
implement the corresponding embed
operation. Laws are induced by
implementing either Steppable
(which extends this) or Corecursive
(which doesn’t).
Instances
Projectable Natural Maybe Source # | |
Projectable Void Identity Source # | |
Functor f => Projectable (Nu f) f Source # | |
Functor f => Projectable (Mu f) f Source # | |
Projectable (Fix f) f Source # | |
Projectable [a] (XNor a) Source # | |
Projectable (NonEmpty a) (AndMaybe a) Source # | |
Projectable (Maybe a) (Const (Maybe a) :: Type -> Type) Source # | |
Projectable (Either a b) (Const (Either a b) :: Type -> Type) Source # | |
Projectable (Cofree f a) (EnvT a f) Source # | |
Projectable (Free f a) (FreeF f a) Source # | |
class Projectable t f => Steppable t f | t -> f where Source #
Structures you can walk through step-by-step.
Instances
Steppable Natural Maybe Source # | |
Steppable Void Identity Source # | |
Functor f => Steppable (Nu f) f Source # | |
Functor f => Steppable (Mu f) f Source # | |
Steppable (Fix f) f Source # | |
Steppable [a] (XNor a) Source # | |
Steppable (NonEmpty a) (AndMaybe a) Source # | |
Steppable (Maybe a) (Const (Maybe a) :: Type -> Type) Source # | |
Steppable (Either a b) (Const (Either a b) :: Type -> Type) Source # | |
Steppable (Cofree f a) (EnvT a f) Source # | |
Steppable (Free f a) (FreeF f a) Source # | |
class Recursive t f | t -> f where Source #
Inductive structures that can be reasoned about in the way we usually do – with pattern matching.
class Corecursive t f | t -> f where Source #
Coinductive (potentially-infinite) structures that guarantee _productivity_ rather than termination.
Instances
Corecursive (Nu f) f Source # | |
Functor f => Corecursive (Fix f) f Source # | |
Corecursive [a] (XNor a) Source # | |
Corecursive (NonEmpty a) (AndMaybe a) Source # | |
Corecursive (Maybe a) (Const (Maybe a) :: Type -> Type) Source # | |
Corecursive (Either a b) (Const (Either a b) :: Type -> Type) Source # | |
Functor f => Corecursive (Cofree f a) (EnvT a f) Source # | |
Functor f => Corecursive (Free f a) (FreeF f a) Source # | |
recursiveEq :: (Recursive t f, Steppable u f, Functor f, Foldable f, Eq1 f) => t -> u -> Bool Source #
A fixed-point operator for inductive / finite data structures.
A fixed-point operator for coinductive / potentially-infinite data structures.
lowerDay :: Projectable t g => Algebra (Day f g) a -> Algebra f (t -> a) Source #
Algebras over Day convolution are convenient for binary operations, but
aren’t directly handleable by cata
.
lowerAlgebra :: (Functor f, Comonad w) => DistributiveLaw f w -> GAlgebra w f a -> Algebra f (w a) Source #
lowerAlgebraM :: (Applicative m, Traversable f, Comonad w, Traversable w) => DistributiveLaw f w -> GAlgebraM m w f a -> AlgebraM m f (w a) Source #
Makes it possible to provide a GAlgebraM
to cataM
.
lowerCoalgebra :: (Functor f, Monad m) => DistributiveLaw m f -> GCoalgebra m f a -> Coalgebra f (m a) Source #
Makes it possible to provide a GCoalgebra
to ana
.
lowerCoalgebraM :: (Applicative m, Traversable f, Monad n, Traversable n) => DistributiveLaw n f -> GCoalgebraM m n f a -> CoalgebraM m f (n a) Source #
Makes it possible to provide a GCoalgebraM
to anaM
.
gcata :: (Recursive t f, Functor f, Comonad w) => DistributiveLaw f w -> GAlgebra w f a -> t -> a Source #
elgotCata :: (Recursive t f, Functor f, Comonad w) => DistributiveLaw f w -> ElgotAlgebra w f a -> t -> a Source #
gcataM :: (Monad m, Recursive t f, Traversable f, Comonad w, Traversable w) => DistributiveLaw f w -> GAlgebraM m w f a -> t -> m a Source #
elgotCataM :: (Monad m, Recursive t f, Traversable f, Comonad w, Traversable w) => DistributiveLaw f w -> ElgotAlgebraM m w f a -> t -> m a Source #
ezygoM :: (Monad m, Recursive t f, Traversable f) => AlgebraM m f b -> ElgotAlgebraM m ((,) b) f a -> t -> m a Source #
gana :: (Corecursive t f, Functor f, Monad m) => DistributiveLaw m f -> GCoalgebra m f a -> a -> t Source #
elgotAna :: (Corecursive t f, Functor f, Monad m) => DistributiveLaw m f -> ElgotCoalgebra m f a -> a -> t Source #
colambek :: (Projectable t f, Corecursive t f, Functor f) => Algebra f t Source #
type DistributiveLaw f g = forall a. f (g a) -> g (f a) Source #
There are a number of distributive laws, including
sequenceA
, distribute
, and
sequenceL
. Yaya also provides others for specific recursion
schemes.
distIdentity :: Functor f => DistributiveLaw f Identity Source #
A less-constrained distribute
for Identity
.
seqIdentity :: Functor f => DistributiveLaw Identity f Source #
distEnvT :: Functor f => Algebra f a -> DistributiveLaw f w -> DistributiveLaw f (EnvT a w) Source #
attributeAlgebra :: (Steppable t (EnvT a f), Functor f) => Algebra f a -> Algebra f t Source #
Converts an Algebra
to one that annotates the tree with the result for
each node.
attributeCoalgebra :: Coalgebra f a -> Coalgebra (EnvT a f) a Source #
Converts a Coalgebra
to one that annotates the tree with the seed that
generated each node.
ignoringAttribute :: Algebra f a -> Algebra (EnvT b f) a Source #
This is just a more obvious name for composing lowerEnvT
with your
algebra directly.
constEmbed :: Algebra (Const a) a Source #
constProject :: Coalgebra (Const a) a Source #
type BialgebraIso f a = Iso' (f a) a Source #
type AlgebraPrism f a = Prism' (f a) a Source #
type CoalgebraPrism f a = Prism' a (f a) Source #
cursiveIso :: Steppable t f => BialgebraIso f t Source #
birecursiveIso :: (Recursive t f, Corecursive t f) => BialgebraIso f a -> Iso' t a Source #
recursivePrism :: (Recursive t f, Corecursive t f, Traversable f) => AlgebraPrism f a -> Prism' t a Source #