-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent sharing #23
Comments
With those changes and instance Universe Integer where
churchUniverse c n = foldr c n (0 : d [1..])
where d (x:xs) = x : negate x : d xs The residency size drops to
|
Your
But if we're going to change the interface, we might consider a strongly improved one rather than an incremental improvement. I've been pondering for a while whether instances should expose the "tree-like" structure available from
|
It is funny. I tried yours version, but it allocates I'm not sure whether parent/children approach is practical. It feels it will be tricky to write definitions for non trivial data. I'd rather church encode the tree then, so users could traverse it in different order but it's not a memoisable data-structure CAF. I.e |
Yet your proposal resembles http://hackage.haskell.org/package/countable-0.2/docs/Data-Countable.html definitions |
For example instance for |
You're right, we should have
|
how about using The IMHO then we can have possibly-infinite-height finite-branching tree, so we can encode I could try to implement / benchmark this idea, if it sounds feasible? |
I'm fully on board. |
I'm coming back to this. And I have to rethink. Tree is good for |
Something must be done to let us avoid sharing, but I haven't really looked deeply into the options yet. In some cases, it may prove a bit tricky to convince GHC to avoid sharing without obfuscating the code. For example, the |
For some usage patterns it's beneficial to produce
universe
stream on the fly, without memoising it. As it's a CAF it's get memoised by default:For example with:
maximal residency get out of hands:
One solution would be to change
Universe
class to beI could try to make this change, if it's a problem you think is worth solving. My gut feeling is that using church encoding is probably the best way to prevent sharing.
The text was updated successfully, but these errors were encountered: