import { Recursive } from "@tsplus/stdlib/prelude/Recursive/definition" import type { Unfolder } from "@tsplus/stdlib/prelude/Recursive/Unfolder" /** * Use a `Covariant` and an `Unfolder.Fn` function to generate a Recurisve * structure. The `unfolder` is non-recursive and generates a single level of the * structure. * i.e. _anamorphism_ * * @tsplus static Recursive/Ops unfold */ export function unfold( F: Covariant, unfolder: Unfolder.Fn ): (a: Z) => Recursive { return function self(a): Recursive { return Recursive(F.map(self)(unfolder(a))) } }