recursion-schemes-ext-0.1.1.1: Amateur addenda to recursion-schemes

Safe HaskellNone
LanguageHaskell2010

Data.Functor.Foldable.Extensions

Contents

Description

Several extensions to Edward Kmett's recursion schemes package. The monadic recursion schemes and exotic recursion schemes should be stable, but the recursion schemes for interdependent data type (and their attendant typeclasses) are experimental.

Synopsis

Classes

class (Functor f, Functor g) => SubHom f g a b where Source #

Class that yields g-algebra homomorphisms between mutually recursive types.

Minimal complete definition

homo

Methods

homo :: (f a -> a) -> (g b -> b) -> g b -> b Source #

Homomorphism of g-algebras parametrized by an f-algebra

class SubType b where Source #

Minimal complete definition

switch

Methods

switch :: b -> b Source #

Resolve nested functions.

Instances

class (Functor f, Functor g) => CoSubHom f g a b where Source #

Class that yields g-coalgebra homomorphisms between mutually recursive types.

Minimal complete definition

homoCo

Methods

homoCo :: (a -> f a) -> (b -> g b) -> b -> g b Source #

Homomorphism of g-coalgebras paramterized by an f-coalgebra

class Dummy t where Source #

We need this class to make type resolution work.

Minimal complete definition

dummy

Methods

dummy :: t Source #

Instances

Monadic recursion schemes

cataM :: (Recursive t, Traversable (Base t), Monad m) => (Base t a -> m a) -> t -> m a Source #

A monadic catamorphism

anaM :: (Corecursive t, Traversable (Base t), Monad m) => (a -> m (Base t a)) -> a -> m t Source #

A monadic anamorphism

hyloM :: (Functor f, Monad m, Traversable f) => (f b -> m b) -> (a -> m (f a)) -> a -> m b Source #

A monadic hylomorphism

Recursion schemes for interdependent data types

dendro Source #

Arguments

:: (SubHom (Base t) (Base t') a b, SubType b, Recursive t') 
=> t

dummy type

-> (Base t a -> a)

A (Base t)-algebra

-> (Base t' b -> b)

A (Base t')-algebra

-> t' 
-> b 

A dendromorphism allows us to entangle two catamorphisms

dendroTri Source #

Arguments

:: (SubHom (Base t) (Base t') a b, SubType b, Recursive t', SubHom (Base t'') (Base t) c a, SubType a, Recursive t) 
=> t

dummy type

-> t''

another dummy type

-> (Base t'' c -> c)

A (Base t'')-algebra

-> (Base t a -> a) 
-> (Base t' b -> b) 
-> t' 
-> b 

Entangle three base functors.

symplecto Source #

Arguments

:: (SubHom g f b b, CoSubHom g f a a) 
=> (g b -> b)

A g-algebra

-> (a -> g a)

A g-coalgebra

-> (f b -> b)

An f-algebra

-> (a -> f a)

An f-coalgebra

-> a 
-> b 

Entangle two hylomorphisms. Not the same thing as a symplectomorphism from geometry.

chema Source #

Arguments

:: (CoSubHom (Base t) (Base t') a b, SubType b, Corecursive t') 
=> t

dummy type

-> (a -> Base t a) 
-> (b -> Base t' b) 
-> b 
-> t' 

Exotic recursion schemes

dicata :: Recursive a => (Base a (b, a) -> b) -> (Base a (b, a) -> a) -> a -> b Source #

Catamorphism collapsing along two data types simultaneously. Basically a fancy zygomorphism.

micro :: Corecursive a => (b -> Either a (Base a b)) -> b -> a Source #

A micromorphism is an Elgot algebra specialized to unfolding.