You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the solution you'd like
I would like to have some kind of primitive to create a memoized thunk/lazy value. A signature that was proposed on discord is the following:
memo : '{} a -> '{} a
The lazy value needs to be pure, since it would be a complete mess otherwise.
It might also be the case that some of the rules on recursive definitions would need to be loosened if the primitive is used, to actually allow self-referential lazy definitions, but I'm not completely sure.
Describe alternatives you've considered
There are other possible interfaces that could be used to introduce laziness. I haven't completely thought through the options.
Without some way to get laziness, one would have to make do without the improved asymptomatics of those algorithms.
Another option would be to have a separate type for lazy values. This might have the disadvantage of not being able to use it in as many places though.
Is your feature request related to a problem? Please describe.
Some algorithms and tricks are only possible in pure languages when you have access to laziness/memoized thunks. See e.g. Okasaki's "Purely Functional Data Structures", many of which depend on laziness to get their desired asymptomatics. Or tricks like using info about the final data structure to put info in leaves
Describe the solution you'd like
I would like to have some kind of primitive to create a memoized thunk/lazy value. A signature that was proposed on discord is the following:
The lazy value needs to be pure, since it would be a complete mess otherwise.
It might also be the case that some of the rules on recursive definitions would need to be loosened if the primitive is used, to actually allow self-referential lazy definitions, but I'm not completely sure.
Describe alternatives you've considered
There are other possible interfaces that could be used to introduce laziness. I haven't completely thought through the options.
Without some way to get laziness, one would have to make do without the improved asymptomatics of those algorithms.
Additional context
This post by Edward Kmett lists a few more things that are difficult or impossible to do without laziness: https://www.reddit.com/r/haskell/comments/5xge0v/comment/deia53t/
The text was updated successfully, but these errors were encountered: