Commit | Line | Data |
---|---|---|
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 | ||
8 | functor Set () = | |
9 | struct | |
10 | ||
11 | type 'a obj = {rep: 'a, equal: 'a * 'a -> bool} | |
12 | ||
13 | datatype 'a t = | |
14 | Empty | |
15 | | NonEmpty of {elts: 'a list, | |
16 | equal: ('a * 'a -> bool)} | |
17 | ||
18 | val empty = Empty | |
19 | ||
20 | fun singleton {rep, equal} = NonEmpty{elts = [rep], equal = equal} | |
21 | ||
22 | fun 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?? |