-
Notifications
You must be signed in to change notification settings - Fork 37
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
Dispose with side effects #436
Comments
Why not be more general? class Monad m => Disposable m a where
dispose :: a %1 -> m () |
I'm always in favour of general solutions, so agree! 😃 |
I'd agree to a PR adding this. There are discussion about disposable objects somewhere in the streaming sublibrary, in particular. So it's something that we've been thinking of around here as well. |
Which order should the class parameters go in? I can't decide which partial application seems more likely. |
I'm pretty sure that we want Think of the original proposal that was (up to a renaming) But anyway, beyond what I can articulate, I'm quite sure it's the right call. |
This would come in pretty useful for my reference counting library too (it's still a work in progress, I'll publish it in due time). And class Monad m => Shareable m a where
share :: a -o m (a,a) |
@alt-romes PR still welcome 🙂 . |
I'm happy to do a PR, but I've not settled on the design. Is I don't particularly like it, but did we consider something like Ah, and I don't think we need to require the |
I like On the other hand, they are less discoverable names than
We definitely don't need to. And probably shouldn't. |
The module
Data.Unrestricted.Linear
provides tools for manipulating linear values non-linearly. One of them is given by the type classConsumable
whose single class methodconsume :: a %1 -> ()
allows us to consume or drop a linear value of typea
, by returning an unit type()
.However, sometimes consuming a linear value might cause an effect, for example deallocating a memory cell. I think it would be nice to capture situations like this in the module
Data.Unrestricted.Linear
by defining a type classDisposable
which would generalise
Consumable
Of course, something similar could be done for
Dupable
andMoveable
.The text was updated successfully, but these errors were encountered: