comparison src/mono_util.sml @ 288:4260ad920c36

Converting string to int
author Adam Chlipala <adamc@hcoop.net>
date Sun, 07 Sep 2008 11:33:13 -0400
parents c0e4ac23522d
children df00701f2323
comparison
equal deleted inserted replaced
287:3ed7a7c7b060 288:4260ad920c36
48 in 48 in
49 joinL compareFields (xts1, xts2) 49 joinL compareFields (xts1, xts2)
50 end 50 end
51 | (TDatatype (n1, _), TDatatype (n2, _)) => Int.compare (n1, n2) 51 | (TDatatype (n1, _), TDatatype (n2, _)) => Int.compare (n1, n2)
52 | (TFfi (m1, x1), TFfi (m2, x2)) => join (String.compare (m1, m2), fn () => String.compare (x1, x2)) 52 | (TFfi (m1, x1), TFfi (m2, x2)) => join (String.compare (m1, m2), fn () => String.compare (x1, x2))
53 | (TOption t1, TOption t2) => compare (t1, t2)
53 54
54 | (TFun _, _) => LESS 55 | (TFun _, _) => LESS
55 | (_, TFun _) => GREATER 56 | (_, TFun _) => GREATER
56 57
57 | (TRecord _, _) => LESS 58 | (TRecord _, _) => LESS
58 | (_, TRecord _) => GREATER 59 | (_, TRecord _) => GREATER
59 60
60 | (TDatatype _, _) => LESS 61 | (TDatatype _, _) => LESS
61 | (_, TDatatype _) => GREATER 62 | (_, TDatatype _) => GREATER
63
64 | (TFfi _, _) => LESS
65 | (_, TFfi _) => GREATER
62 66
63 and compareFields ((x1, t1), (x2, t2)) = 67 and compareFields ((x1, t1), (x2, t2)) =
64 join (String.compare (x1, x2), 68 join (String.compare (x1, x2),
65 fn () => compare (t1, t2)) 69 fn () => compare (t1, t2))
66 70
86 (x, t'))) 90 (x, t')))
87 xts, 91 xts,
88 fn xts' => (TRecord xts', loc)) 92 fn xts' => (TRecord xts', loc))
89 | TDatatype _ => S.return2 cAll 93 | TDatatype _ => S.return2 cAll
90 | TFfi _ => S.return2 cAll 94 | TFfi _ => S.return2 cAll
95 | TOption t =>
96 S.map2 (mft t,
97 fn t' =>
98 (TOption t, loc))
91 in 99 in
92 mft 100 mft
93 end 101 end
94 102
95 fun map typ c = 103 fun map typ c =
184 | PPrim _ => ctx 192 | PPrim _ => ctx
185 | PCon (_, _, NONE) => ctx 193 | PCon (_, _, NONE) => ctx
186 | PCon (_, _, SOME p) => pb (p, ctx) 194 | PCon (_, _, SOME p) => pb (p, ctx)
187 | PRecord xps => foldl (fn ((_, p, _), ctx) => 195 | PRecord xps => foldl (fn ((_, p, _), ctx) =>
188 pb (p, ctx)) ctx xps 196 pb (p, ctx)) ctx xps
197 | PNone _ => ctx
198 | PSome (_, p) => pb (p, ctx)
189 in 199 in
190 S.map2 (mfe (pb (p, ctx)) e, 200 S.map2 (mfe (pb (p, ctx)) e,
191 fn e' => (p, e')) 201 fn e' => (p, e'))
192 end) pes, 202 end) pes,
193 fn pes' => 203 fn pes' =>