Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | (* Copyright (C) 1999-2005 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 Sum(S: SUM_STRUCTS): SUM = | |
9 | struct | |
10 | ||
11 | open S | |
12 | ||
13 | datatype t = | |
14 | X of X.t | |
15 | | Y of Y.t | |
16 | ||
17 | val outX = | |
18 | fn X x => x | |
19 | | _ => Error.bug "Sum.outX" | |
20 | ||
21 | val outY = | |
22 | fn Y y => y | |
23 | | _ => Error.bug "Sum.outY" | |
24 | ||
25 | val map = | |
26 | fn (X x, f, _) => f x | |
27 | | (Y y, _, f) => f y | |
28 | ||
29 | val equals = | |
30 | fn (X l, X l') => X.equals(l, l') | |
31 | | (Y l, Y l') => Y.equals(l, l') | |
32 | | _ => false | |
33 | ||
34 | fun layout s = map(s, X.layout, Y.layout) | |
35 | ||
36 | end |