Safe Haskell | None |
---|---|
Language | Haskell2010 |
Combinators for processing/constructing trees recursively
Synopsis
- module AST.Class.Recursive
- fold :: Recursively KFunctor k => (forall n. KRecWitness k n -> Tree n (Const a) -> a) -> Tree Pure k -> a
- unfold :: Recursively KFunctor k => (forall n. KRecWitness k n -> a -> Tree n (Const a)) -> a -> Tree Pure k
- wrap :: forall k w. Recursively KFunctor k => (forall n. KRecWitness k n -> Tree n w -> Tree w n) -> Tree Pure k -> Tree w k
- wrapM :: forall m k w. (Monad m, RTraversable k) => (forall n. KRecWitness k n -> Tree n w -> m (Tree w n)) -> Tree Pure k -> m (Tree w k)
- unwrap :: forall k w. Recursively KFunctor k => (forall n. KRecWitness k n -> Tree w n -> Tree n w) -> Tree w k -> Tree Pure k
- unwrapM :: forall m k w. (Monad m, RTraversable k) => (forall n. KRecWitness k n -> Tree w n -> m (Tree n w)) -> Tree w k -> m (Tree Pure k)
- foldMapRecursive :: forall k p a. (Recursively KFoldable k, Recursively KFoldable p, Monoid a) => (forall n q. KRecWitness k n -> Tree n q -> a) -> Tree k p -> a
- data KRecWitness k n where
- KRecSelf :: KRecWitness k k
- KRecSub :: KWitness k c -> KRecWitness c n -> KRecWitness k n
- (#>>) :: forall c k n r. (Recursive c, c k, RNodes k) => Proxy c -> (c n => r) -> KRecWitness k n -> r
- (#**#) :: (Recursive c, c k, RNodes k) => Proxy c -> (KRecWitness k n -> c n => r) -> KRecWitness k n -> r
- (##>>) :: forall c k n r. Recursively c k => Proxy c -> (c n => r) -> KRecWitness k n -> r
Documentation
module AST.Class.Recursive
fold :: Recursively KFunctor k => (forall n. KRecWitness k n -> Tree n (Const a) -> a) -> Tree Pure k -> a Source #
Recursively fold up a tree to produce a result (aka catamorphism)
unfold :: Recursively KFunctor k => (forall n. KRecWitness k n -> a -> Tree n (Const a)) -> a -> Tree Pure k Source #
Build/load a tree from a seed value (aka anamorphism)
wrap :: forall k w. Recursively KFunctor k => (forall n. KRecWitness k n -> Tree n w -> Tree w n) -> Tree Pure k -> Tree w k Source #
wrapM :: forall m k w. (Monad m, RTraversable k) => (forall n. KRecWitness k n -> Tree n w -> m (Tree w n)) -> Tree Pure k -> m (Tree w k) Source #
unwrap :: forall k w. Recursively KFunctor k => (forall n. KRecWitness k n -> Tree w n -> Tree n w) -> Tree w k -> Tree Pure k Source #
unwrapM :: forall m k w. (Monad m, RTraversable k) => (forall n. KRecWitness k n -> Tree w n -> m (Tree n w)) -> Tree w k -> m (Tree Pure k) Source #
foldMapRecursive :: forall k p a. (Recursively KFoldable k, Recursively KFoldable p, Monoid a) => (forall n q. KRecWitness k n -> Tree n q -> a) -> Tree k p -> a Source #
Fold over all of the recursive child nodes of a Tree
in pre-order
data KRecWitness k n where Source #
KRecWitness k n
is a witness that n
is a recursive node of k
KRecSelf :: KRecWitness k k | |
KRecSub :: KWitness k c -> KRecWitness c n -> KRecWitness k n |
(#>>) :: forall c k n r. (Recursive c, c k, RNodes k) => Proxy c -> (c n => r) -> KRecWitness k n -> r infixr 0 Source #
Proxy
c #> r replaces a recursive witness parameter of
r@ with a constraint on the witnessed node
(#**#) :: (Recursive c, c k, RNodes k) => Proxy c -> (KRecWitness k n -> c n => r) -> KRecWitness k n -> r infixr 0 Source #
A variant of #>>
which does not consume the witness parameter.
Proxy
c0 Proxy c1 #>> r
brings into context both the c0 n
and c1 n
constraints.
(##>>) :: forall c k n r. Recursively c k => Proxy c -> (c n => r) -> KRecWitness k n -> r infixr 0 Source #
Proxy
c #> r replaces a recursive witness parameter of
r with a
Recursively c@ constraint on the witnessed node