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 | structure General: GENERAL_EXTRA = | |
10 | struct | |
11 | type unit = Primitive.Unit.unit | |
12 | ||
13 | type exn = exn | |
14 | exception Bind = Bind | |
15 | exception Match = Match | |
16 | exception Chr | |
17 | exception Div = Div | |
18 | exception Domain = Domain | |
19 | exception Fail of string | |
20 | exception Overflow = Overflow | |
21 | exception Size = Size | |
22 | exception Span = Span | |
23 | exception Subscript = Subscript | |
24 | ||
25 | datatype order = datatype Primitive.Order.order | |
26 | ||
27 | val ! = Primitive.Ref.deref | |
28 | val op := = Primitive.Ref.assign | |
29 | fun (f o g) x = f (g x) | |
30 | fun x before () = x | |
31 | fun ignore _ = () | |
32 | val exnName = Primitive.Exn.name | |
33 | ||
34 | local | |
35 | val messagers: (exn -> string option) list ref = ref [] | |
36 | in | |
37 | val addExnMessager: (exn -> string option) -> unit = | |
38 | fn f => messagers := f :: !messagers | |
39 | ||
40 | val rec exnMessage: exn -> string = | |
41 | fn e => | |
42 | let | |
43 | val rec find = | |
44 | fn [] => exnName e | |
45 | | m :: ms => | |
46 | case m e of | |
47 | NONE => find ms | |
48 | | SOME s => s | |
49 | in | |
50 | find (!messagers) | |
51 | end | |
52 | end | |
53 | end | |
54 | ||
55 | structure GeneralGlobal: GENERAL_GLOBAL = General | |
56 | open GeneralGlobal |