Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import * as TreeF from '#treeF'
import {cata, cataE, para, struct, zipFolds} from 'effect-ts-folds'
import type {
TreeEffectFold,
TreeEffectFolder,
TreeFold,
TreeFolder,
TreeProductFolder,
} from './types.js'
/**
* Run a {@link TreeFolder}<A, B> on a {@link Tree}<A> to fold into a value of
* type `B`.
* @category fold
* @function
*/
export const treeCata: <A, B>(φ: TreeFolder<A, B>) => TreeFold<A, B> = cata(
TreeF.Traversable,
)
/**
* Run a {@link TreeProductFolder}<A, B> on a {@link Tree}<A> to fold into a value of
* type `B`. Just like {@link treeCata} except the folder function
* gets all previous computed values.
* @category fold
* @function
*/
export const treePara: <A, B>(φ: TreeProductFolder<A, B>) => TreeFold<A, B> =
para(TreeF.Traversable)
/**
* Just like {@link treeCata}, except the folder is _effectful_.
* @category fold
* @function
*/
export const treeCataEffect: <A, B, E = never, R = never>(
φ: TreeEffectFolder<A, B, E, R>,
) => TreeEffectFold<A, B, E, R> = cataE(TreeF.Traversable)
/**
* Zip a pair of folds to create a single fold. It will fold into a pair of the
* result of the zipped folds.
* @category fold
* @function
*/
export const zipTreeFolds = zipFolds(TreeF.Covariant)
/**
* Create a fold that folds into a struct from a struct of folds.
* @category fold
* @function
*/
export const structTreeFolds = struct(TreeF.Covariant)
|