Skip to content

Conversation

@nomicflux
Copy link
Contributor

Intended as a branch PR, since it provides it provides a couple ideas for dealing with anamorphisms.

Having a Coalgebra<Lazy<A>, Functor<Lazy<A>, F> doesn't prevent stack overflows. The base Anamorphism class then does away with the Lazy requirement altogether, as it doesn't seem to add anything.

Two approaches so far have succeeded in providing (infinite) anamorphisms without stack overflow. The first was a ComposeF which would bind together the functor F and Lazy, but type inference was terrible (requiring multiple explicit casts to start retrieving any results). A FixLazy which required a Fn0<Unfixed> to create a Lazy<Unfixed> also achieved the same results, with better (though still not great) type inference, and again without requiring the user to supply any Lazy annotations. LazyAnamorphism uses this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant