yaya-0.6.2.2: Total recursion schemes.
Safe HaskellSafe
LanguageHaskell2010

Yaya.Fold.Common

Description

Common algebras that are useful when folding.

Synopsis

Documentation

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

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

Captures the input value if the application was undefined.

compareDay :: (Functor f, Foldable f) => (f () -> f () -> Ordering) -> Day f f Ordering -> Ordering Source #

Provides ordering over arbitrary pattern functors.

Since: 0.6.1.0

diagonal :: a -> Pair a a Source #

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

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

Provides equality over arbitrary pattern functors.

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

Provides equality over arbitrary pattern functors.

Since: 0.6.1.0

fromEither :: Either a a -> a Source #

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

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

When folded, returns the height of the data structure.

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.

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.

lucasSequence' :: Num n => n -> n -> (n, n) -> (n, (n, n)) Source #

never :: a -> Identity a Source #

Generates an infinite structure from an arbitrary seed.

replaceNeither :: XNor a b -> XNor a b -> XNor a b Source #

showsPrecF :: Show1 f => Int -> f (Int -> ShowS) -> ShowS Source #

Provides show over arbitrary pattern functors.

Since: 0.6.1.0

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).

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

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

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

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

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

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

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

xnor :: c -> (a -> b -> c) -> XNor a b -> c Source #

Eliminator for XNor, akin to either or maybe.

Since: 0.6.1.0