1 (* Copyright (C
) 1999-2006 Henry Cejtin
, Matthew Fluet
, Suresh
2 * Jagannathan
, and Stephen Weeks
.
3 * Copyright (C
) 1997-2000 NEC Research Institute
.
5 * MLton is released under a BSD
-style license
.
6 * See the file MLton
-LICENSE for details
.
9 structure SML90
:> SML90
=
11 type instream
= TextIO.instream
12 type outstream
= TextIO.outstream
13 exception Abs
= Overflow
14 exception Quot
= Overflow
15 exception Prod
= Overflow
16 exception Neg
= Overflow
17 exception Sum
= Overflow
18 exception Diff
= Overflow
19 exception Floor
= Overflow
20 exception Exp
= Overflow
25 exception Io
of string
30 val sqrt
= fn x
=> if Real.< (x
, 0.0) then raise Sqrt
else sqrt x
31 val exp
= fn x
=> let val y
= exp x
36 val ln
= fn x
=> if Real.> (x
, 0.0) then ln x
else raise Ln
45 else Char.ord(String.sub(s
, 0))
47 val chr
= String.str
o Char.chr
48 fun explode s
= List.map
String.str (String.explode s
)
49 val implode
= String.concat
51 case TextIO.lookahead ins
of
55 val std_in
= TextIO.stdIn
57 TextIO.openIn f
handle IO
.Io _
=> raise Io (concat
["Cannot open ", f
])
59 TextIO.inputN ins
handle IO
.Io _
=> raise Io
"Input stream is closed"
60 val close_in
= TextIO.closeIn
61 fun end_of_stream ins
= TextIO.endOfStream ins
handle _
=> true
62 val std_out
= TextIO.stdOut
65 handle IO
.Io _
=> raise Io (concat
["Cannot open ", f
])
67 TextIO.output (out
, s
)
68 handle IO
.Io _
=> raise Io
"Output stream is closed"
69 val close_out
= TextIO.closeOut