Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / basic / counter.sml
CommitLineData
7f918cf1
CE
1(* Copyright (C) 2009 Matthew Fluet.
2 * Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 *
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
7 *)
8
9structure Counter: COUNTER =
10struct
11
12datatype t = T of int ref
13
14fun new n = T(ref n)
15
16fun reset(T r, n) = r := n
17
18fun tick(T r) = Int.inc r
19
20fun value(T r) = !r
21
22fun next c = value c before tick c
23
24val equals = fn (T r, T r') => r = r'
25
26end