Skip to content

Dispose with side effects  #436

Description

@pedromsrocha

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions