The Nu datatype is the simplest way to model corecursion via a direct encoding of the ana function.
@higherkind class Nu<out F>(val a: Any?, val unNu: Coalgebra<F, Any?>) : NuOf<F>
Nu’s constructor is isomorphic to ana.
Nu warns that a datatype can be be infinite, and should be used for any algorithms
that can work on infinite data (for example
map). Due to it being a direct encoding
of ana, Nu also has a very fast Corecursive instance.
Do you like Arrow?✖