Skip to content

Commit

Permalink
feat(std): Add std.disposable
Browse files Browse the repository at this point in the history
  • Loading branch information
Laegluin committed Dec 3, 2018
1 parent 33e1881 commit 066655d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions std/disposable.glu
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 066655d

Please sign in to comment.