Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Data.Functor.FoldableM
Synopsis
- apoM :: (Monad m, Traversable (Base t), Corecursive t) => (a -> m (Base t (Either t a))) -> a -> m t
Documentation
apoM :: (Monad m, Traversable (Base t), Corecursive t) => (a -> m (Base t (Either t a))) -> a -> m t Source #
apoM is the monadic counterpart of the apomorphism. 2 | Exercise: Read the definition of the ana and apo 3 | http://hackage.haskell.org/package/recursion-schemes-5.1.3/docs/src/Data.Functor.Foldable.html#ana 4 | http://hackage.haskell.org/package/recursion-schemes-5.1.3/docs/src/Data.Functor.Foldable.html#apo
In general apo is an extended anamorphism. Anamoprhism builds up an expression tree, using 5 | a seed and a function that creates a new layer of the tree. Anamorphism builds the tree from 6 | top to bottom.
The apomorphism, has the ability to generate a subtree in one go and stop the recursion there.
apoM is the Monadic variant, which can have some side effect meanwhile the generation of the 7 | next layer happens.