Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / basic / clearable-promise.sml
1 (* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 *
4 * MLton is released under a BSD-style license.
5 * See the file MLton-LICENSE for details.
6 *)
7
8 structure ClearablePromise: CLEARABLE_PROMISE =
9 struct
10
11 datatype 'a t = T of (unit -> 'a) * 'a Promise.t
12
13 fun clear (T (f, p)) = Promise.reset (p, f)
14
15 fun delay f = T (f, Promise.delay f)
16
17 exception Force = Promise.Force
18
19 fun force (T (_, p)) = Promise.force p
20
21 end