解决 SML/NJ 编译管理器中的库冲突
Resolve library conflict in SML/NJ Compilation Manager
我正在使用 SML/NJ 110.79,其中包括对 Successor ML 项目定义的新结构的支持。其中,Fn
结构。
碰巧,我在 my personal project with utilities 之一中已经有了一个同名结构,它在 110.79 之前工作正常。
使用 110.79,为此 .cm 文件:
group is
$/basis.cm
$SMACKAGE/sml-extras/v0.1.0/sources.sml.cm
不过我收到以下错误:
sources.cm:3.3-3.45 Error: structure Fn imported from
$SMLNJ-BASIS/(basis.cm):basis-common.cm@155252(fn.sml) and also from
$SMACKAGE/sml-extras/v0.1.0/(sources.sml.cm):src/fn.sml
有谁知道如何通过编译管理器解决这个冲突。理想情况下,我的 Fn
结构将能够 "extend" 标准 Fn
只需 open
-ing 它,但使用 sml-extras 库的项目将看不到标准Fn
结构,只有我的加长版。
这可能吗?我的 sml-extras.cm 项目中是否需要 wrap/re-export 整个 basis.cm 库?
我设法通过使用我认为在 CM manual §2.9.
中所谓的 管理 库解决了这个问题
确切的意思是创建一个辅助 .cm 文件来包装基础库和 re-exports 只有我们感兴趣的符号。
sources.cm
这是主项目文件。
library
structure Main
is
(* Let's say this library redefines the Fn and Ref structures *)
(* and the REF signature. *)
$SMACKAGE/sml-extras/v0.1.0/sources.sml.cm
(* This excludes out Fn, Ref and REF from the Basis library, but *)
(* imports anything else. *)
amended-basis.cm
main.sml
amended-basis.cm
此文件导入 $/basis.cm
,然后导入 re-exports 除 Fn
、Ref
和 REF
之外的所有文件。
group
library($/basis.cm) - (
structure Fn
structure Ref
signature REF
)
is
$/basis.cm
main.sml
structure Main =
struct
open Fn (* sml-extras's Fn *)
end
该解决方案基于 CM 手册第 4 节中描述的集合演算 和附录 A 中的 EBNF 语法。
另一个解决方案是将 sml-extras 更改为 re-export 整个 $/basis.cm
,同时隐藏冲突的符号。但是,为了模块化,我决定采用上面详述的解决方案。
我正在使用 SML/NJ 110.79,其中包括对 Successor ML 项目定义的新结构的支持。其中,Fn
结构。
碰巧,我在 my personal project with utilities 之一中已经有了一个同名结构,它在 110.79 之前工作正常。
使用 110.79,为此 .cm 文件:
group is
$/basis.cm
$SMACKAGE/sml-extras/v0.1.0/sources.sml.cm
不过我收到以下错误:
sources.cm:3.3-3.45 Error: structure Fn imported from $SMLNJ-BASIS/(basis.cm):basis-common.cm@155252(fn.sml) and also from $SMACKAGE/sml-extras/v0.1.0/(sources.sml.cm):src/fn.sml
有谁知道如何通过编译管理器解决这个冲突。理想情况下,我的 Fn
结构将能够 "extend" 标准 Fn
只需 open
-ing 它,但使用 sml-extras 库的项目将看不到标准Fn
结构,只有我的加长版。
这可能吗?我的 sml-extras.cm 项目中是否需要 wrap/re-export 整个 basis.cm 库?
我设法通过使用我认为在 CM manual §2.9.
中所谓的 管理 库解决了这个问题确切的意思是创建一个辅助 .cm 文件来包装基础库和 re-exports 只有我们感兴趣的符号。
sources.cm
这是主项目文件。
library
structure Main
is
(* Let's say this library redefines the Fn and Ref structures *)
(* and the REF signature. *)
$SMACKAGE/sml-extras/v0.1.0/sources.sml.cm
(* This excludes out Fn, Ref and REF from the Basis library, but *)
(* imports anything else. *)
amended-basis.cm
main.sml
amended-basis.cm
此文件导入 $/basis.cm
,然后导入 re-exports 除 Fn
、Ref
和 REF
之外的所有文件。
group
library($/basis.cm) - (
structure Fn
structure Ref
signature REF
)
is
$/basis.cm
main.sml
structure Main =
struct
open Fn (* sml-extras's Fn *)
end
该解决方案基于 CM 手册第 4 节中描述的集合演算 和附录 A 中的 EBNF 语法。
另一个解决方案是将 sml-extras 更改为 re-export 整个 $/basis.cm
,同时隐藏冲突的符号。但是,为了模块化,我决定采用上面详述的解决方案。