Repeatedly apply a "reduce" or fold operation to a functor instance using
co-recursion.
Since the operation is co-recursive, in practice, you're typically building up
a data structure (like a tree).
The nice thing about using an anamorphism is that it lets you write the operation
without having to worry about the recursive bit.
tl,dr:
If you can write a map function for the data structure you're targeting, then
just give that function to fn.any along with the non-recursive
operation you want performed, and it will take care of repeatedly applying the
operation (called a "coalgebra") to the data structure, returning you the final
result.
fn.ana
Short for anamorphism. Dual of
fn.cata
.Repeatedly apply a "reduce" or fold operation to a functor instance using co-recursion.
Since the operation is co-recursive, in practice, you're typically building up a data structure (like a tree).
The nice thing about using an anamorphism is that it lets you write the operation without having to worry about the recursive bit.
tl,dr:
If you can write a
map
function for the data structure you're targeting, then just give that function tofn.any
along with the non-recursive operation you want performed, and it will take care of repeatedly applying the operation (called a "coalgebra") to the data structure, returning you the final result.See also:
fn.cata