Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | (* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh |
2 | * Jagannathan, and Stephen Weeks. | |
3 | * Copyright (C) 1997-2000 NEC Research Institute. | |
4 | * | |
5 | * MLton is released under a BSD-style license. | |
6 | * See the file MLton-LICENSE for details. | |
7 | *) | |
8 | ||
9 | functor Field (S: FIELD_STRUCTS): FIELD = | |
10 | struct | |
11 | ||
12 | open S | |
13 | ||
14 | datatype t = | |
15 | Int of int | |
16 | | Symbol of Symbol.t | |
17 | ||
18 | val equals = | |
19 | fn (Int n, Int n') => Int.equals (n, n') | |
20 | | (Symbol s, Symbol s') => Symbol.equals (s, s') | |
21 | | _ => false | |
22 | ||
23 | val toString = | |
24 | fn Int n => Int.toString (n + 1) | |
25 | | Symbol s => Symbol.toString s | |
26 | ||
27 | val layout = Layout.str o toString | |
28 | ||
29 | val op <= = | |
30 | fn (Int n, Int n') => Int.<= (n, n') | |
31 | | (Symbol s, Symbol s') => Symbol.<= (s, s') | |
32 | | (Symbol _, Int _) => false | |
33 | | (Int _, Symbol _) => true | |
34 | ||
35 | end |