タイガーブックを読む前に2

前記事で、smlnjのインストールをやった。 そのあと本通りにやると、

CM.make();

で以下のようなエラーが。

stdIn:1.2-1.11 Error: operator and operand do not agree [tycon mismatch]
  operator domain: string
  operand:         unit
  in expression:
    CM.make ()

CM.makeは引数渡さなきゃいけないらしかった。

CM.make "sources.cm";

で、実行すると、

sources.cm:8.1-8.14 Error: Io: openIn failed on "/smlnj-lib.cm", No such file or directory

これは、実際はライブラリがインストールされてるけど、適切に探せてなかったらしい。 なので、sources.cmをsmlnj-lib.cmを以下に修正。

$/smlnj-lib.cm

で、次のエラーは

errormsg.sml:7.24-7.39 Error: unbound structure: TextIO in path TextIO.instream
errormsg.sml:21.26-21.38 Error: unbound structure: TextIO in path TextIO.stdIn
errormsg.sml:27.18-27.30 Error: unbound structure: TextIO in path TextIO.stdIn
errormsg.sml:36.12-36.24 Error: unbound structure: Int in path Int.toString
errormsg.sml:34.12-34.24 Error: unbound structure: Int in path Int.toString
errormsg.sml:49.8-49.23 Error: unbound structure: TextIO in path TextIO.flushOut
errormsg.sml:49.24-49.37 Error: unbound structure: TextIO in path TextIO.stdOut

こんなの。 次は、

takoeight0821.hatenablog.jp

この人のを参考にして、basisを追加。

$/basis.cm

そうすると、

Standard ML of New Jersey v110.85 [built: Sat Dec 22 16:51:02 2018]
- CM.make "sources.cm";
- Parse.parse;
val it = fn : string -> unit

Parse.parseが使えるようになっている。