如何在 Windows 访问 Poly/ML 中的图书馆?

How to access a library in Poly/ML on Windows?

我已经从 "PolyML5.6-64bit.msi" 安装程序安装了 Poly/ML;我可以通过在“开始”菜单中单击它来启动 REPL;但我不知道如何从中访问任何库?我尝试做 use "something",但它会导致如下错误:

> use "Math";
Exception-
   Io
     {cause = SysErr ("No such file or directory", SOME ENOENT), function =
      "TextIO.openIn", name = "Math"} raised

类似于 use "Basis"use "Windows"

请注意,我是 SML 的新手;我似乎在一些通用的 SML 教程中找到了 use 命令,完全不知道我是否正确使用它:/

编辑:另外,目标安装目录似乎只包含以下三个二进制文件,不确定那里是否应该有一些来源:

C:\Program Files\Poly ML>dir
 Volume in drive C is Windows
 Volume Serial Number is CENS-ORED

 Directory of C:\Program Files\Poly ML

26.02.2016  00:03    <DIR>          .
26.02.2016  00:03    <DIR>          ..
25.01.2016  14:22           681 472 PolyLib.dll
25.01.2016  14:23         8 182 784 PolyML.exe
25.01.2016  14:22            20 480 PolyPerf.dll
               3 File(s)      8 884 736 bytes

edit2: 嗯...从进一步的浏览中,我开始认为显然 Poly/ML 似乎是 used by most people purely from within the "Isabelle IDE"?所以也许如果我安装这个,一切都会开箱即用?我会尝试,但最初的问题现在仍然悬而未决。

edit3: 呃,Isabelle IDE 很奇怪,特别是不知道如何 "Run" 在其中打开 SML 文件:/ 可能会在这种情况下卸载(即删除?)它,同时考虑到我现在已经得到了原始问题的答案。

我在 Linux 上使用 Poly/ML,而不是 Windows。但我几乎可以肯定以下内容在 Windows.

上也是正确的

不需要使用use函数加载Basis Library的模块,启动Poly/ML REPL时已经在顶层环境中了。例如:

lolcathost% poly
Poly/ML 5.6 Release
> structure M = Math;
structure M: MATH
> M.pi;
val it = 3.141592654: real
> 

您使用use函数加载您自己的代码。该参数必须是绝对路径或相对于当前工作目录的路径。 我不知道是否可以在 REPL 中更改当前工作目录。 如果需要,请查看如何更改当前工作目录。

此外,对于较大的项目,您可能希望使用 Poly/ML's make system 而不是 use


回复您的评论:

顶层环境中的模块PolyML.Compiler provides functions to retrieve the names of the existing values, types, signatures, structures and functors

但是,名称本身并不是很有用。这里有一些技巧可以让 REPL 告诉你更多信息。

类型:假设您想知道list的构造函数是什么。

> datatype foo = datatype list;
datatype 'a foo = :: of 'a * 'a foo | nil
> 

或者类型同义词 StringCvt.reader 是如何定义的。

> datatype foo = datatype StringCvt.reader;
type ('a, 'b) foo = 'b -> ('a * 'b) option
> 

当然,如果你在抽象数据类型上使用这个技巧,你不会得到太多信息:

> datatype foo = datatype string;
eqtype foo
> 

结构:假设您想知道结构 Byte 的值和类型组件是什么。

> structure Foo = struct open Byte end;
structure Foo:
  sig
    val byteToChar: Word8.word -> char
    val bytesToString: Word8Vector.vector -> string
    val charToByte: char -> Word8.word
    val packString: Word8Array.array * int * substring -> unit
    val stringToBytes: string -> Word8Vector.vector
    val unpackString: Word8ArraySlice.slice -> string
    val unpackStringVec: Word8VectorSlice.slice -> string
  end
> 

签名:假设您想知道签名 BYTE 的值和类型组件是什么。

> functor Foo (X : BYTE) = struct open X end;
functor Foo (X: BYTE): 
  sig
    val byteToChar: Word8.word -> char
    val bytesToString: Word8Vector.vector -> string
    val charToByte: char -> Word8.word
    val packString: Word8Array.array * int * substring -> unit
    val stringToBytes: string -> Word8Vector.vector
    val unpackString: Word8ArraySlice.slice -> string
    val unpackStringVec: Word8VectorSlice.slice -> string
  end
>