yaya-0.4.2.1: Total recursion schemes.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Yaya.Fold.Common

Description

Common algebras that are useful when folding.

Synopsis

Documentation

lowerMonoid :: Monoid m => (a -> m) -> XNor a m -> m Source #

Converts the free monoid (a list) into some other Monoid.

lowerSemigroup :: Semigroup m => (a -> m) -> AndMaybe a m -> m Source #

Converts the free semigroup (a non-empty list) into some other Semigroup.

lowerMonad :: Monad m => (forall x. f x -> m x) -> FreeF f a (m a) -> m a Source #

Converts the free monad into some other Monad.

equal :: (Functor f, Foldable f, Eq1 f) => Day f f Bool -> Bool Source #

Provides equality over arbitrary pattern functors.

height :: Foldable f => f Integer -> Integer Source #

When folded, returns the height of the data structure.

size :: Foldable f => f Natural -> Natural Source #

When folded, returns the number of nodes in the data structure.

NB: This is not the same as the length when applied to a list. I.e., length xs + 1 == cata size xs, because this is counting the nodes of the structure (how many Neithers and Boths), not how many elements (which would be equivalent to only counting Boths).

toRight :: Identity b -> Either a b Source #

Converts a provably infinite structure into a Partial one (that will never terminate).

definedOrInput :: (a -> Maybe b) -> a -> Either a b Source #

Captures the input value if the application was undefined.

fromEither :: Either a a -> a Source #

Collapses a Partial structure to a value (probably requiring unsafe instances).

never :: a -> Identity a Source #

Generates an infinite structure from an arbitrary seed.

takeAnother :: Day Maybe ((,) a) b -> XNor a b Source #

takeNext :: Day Maybe ((,) a) a -> a Source #

truncate' :: Functor f => Day Maybe f a -> FreeF f () a Source #

diagonal :: a -> (a, a) Source #

Converts a single value into a tuple with the same value on both sides. > x &&& y = (x *** y) . diagonal

sequence generators

unarySequence :: (a -> b) -> a -> (a, b) Source #

binarySequence :: (a -> b -> c) -> (a, b) -> (a, (b, c)) Source #

ternarySequence :: (a -> b -> c -> d) -> (a, b, c) -> (a, (b, c, d)) Source #

lucasSequence' :: Integral i => i -> i -> (i, i) -> (i, (i, i)) Source #