diff --git a/std/disposable.glu b/std/disposable.glu new file mode 100644 index 0000000000..ac166f352c --- /dev/null +++ b/std/disposable.glu @@ -0,0 +1,20 @@ +let { ? } = import! std.io +let { (<*) } = import! std.applicative + + +#[implicit] +type Disposable a = { + dispose : a -> IO () +} + +let dispose ?disposable : [Disposable a] -> a -> IO () = disposable.dispose + +let using disposable fn : forall r . [Disposable a] -> a -> (a -> IO r) -> IO r = + fn disposable <* dispose disposable + +{ + Disposable, + + dispose, + using +}