Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / basic / unique-id.fun
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 functor UniqueId():> UNIQUE_ID =
9 struct
10 type t = unit ref
11
12 fun new(): t = ref()
13
14 val equals = Ref.equals
15
16 fun layout _ = Layout.empty
17
18 fun toString _ = ""
19 end
20
21 functor UnitUniqueId():> UNIQUE_ID =
22 struct
23 open Unit
24
25 fun new() = ()
26
27 fun toString _ = ""
28 end
29
30 functor IntUniqueId():> UNIQUE_ID =
31 struct
32 open Int
33
34 val cur: t ref = ref 0
35
36 fun new(): t = (Int.inc cur; !cur)
37 end