SML# Document Version 3.7.1
14 SML# feature: separate compilation

14.7 Replications

An interface file describes resources themselves. So, for example, for a module of the form

structure Foo =
struct
  structure A = Bar
  structure B = Bar
...
end

one cannot write its interface as

structure Foo =
struct
  structure A : SigBar
  structure B : SigBar
...
end

The interface language mechanism so far describes forces us to repeat most of the contents of Bar twice. To suppress this redundancy, the interface language allow replication declaration of the following form.

  • structure id = path

  • exception id = path

  • datatype id = datatype path

  • val id = path

If you know that in advance that two resources are replication of the same resources, then you can declare them as replication using this mechanism in an interface file. For example, Bar structure is provided by an interface file bar.smi and that you know that both A and B should be replications of Bar, then you can simply write the following interface file.

_require "bar.smi"
structure Foo =
struct
  structure A = Bar
  structure B = Bar
...
end