Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / set / unordered.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 UnorderedSet (Element: T):> SET where type Element.t = Element.t =
9 struct
10
11 structure Element = Element
12
13 open List
14
15 type t = Element.t List.t
16
17 val {empty, singleton, size, equals, <=, >=, <, >, +, -, intersect, unions,
18 add, remove, contains, areDisjoint, subset, subsetSize,
19 map, replace, layout} =
20 List.set{equals = Element.equals,
21 layout = Element.layout}
22
23 val partition = List.partition
24 val power = List.power
25 val subsets = List.subsets
26
27 val fromList = fn l => List.fold(l, empty, fn (x, s) => add(s, x))
28 val toList = fn x => x
29
30 val union = op +
31
32 end