Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / set / object-oriented.sml
CommitLineData
7f918cf1
CE
1(* Copyright (C) 1999-2006, 2008 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
8functor Set () =
9struct
10
11type 'a obj = {rep: 'a, equal: 'a * 'a -> bool}
12
13datatype 'a t =
14 Empty
15 | NonEmpty of {elts: 'a list,
16 equal: ('a * 'a -> bool)}
17
18val empty = Empty
19
20fun singleton {rep, equal} = NonEmpty{elts = [rep], equal = equal}
21
22fun add(Empty, re) = singleton re
23 | add(NonEmpty{elts, equal}, {rep, equal})
24
25
26 how do you make sure that it's the same equality function??