The module Data.Unrestricted.Linear provides tools for manipulating linear values non-linearly. One of them is given by the type class Consumable whose single class method consume :: a %1 -> () allows us to consume or drop a linear value of type a, 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 class Disposable
class Disposable a where
dispose :: a %1 -> IO ()
which would generalise Consumable
instance Consumable a => Disposable a where
dispose x = return (consume x)
Of course, something similar could be done for Dupable and Moveable.
The module
Data.Unrestricted.Linearprovides tools for manipulating linear values non-linearly. One of them is given by the type classConsumablewhose 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.Linearby defining a type classDisposablewhich would generalise
ConsumableOf course, something similar could be done for
DupableandMoveable.