I want to place signature/structure pair inside a structure, like so:
structure Outer :> OUTER =
struct
signature INNER =
sig
...
end
structure Inner :> INNER =
struct
...
end
end
but even the simplest of examples produces an error:
../test.sml:1.18-2.6 Error: syntax error: replacing STRUCT with EQUALOP ../test.sml:5.6 Error: syntax error found at END
It appears that signatures are not allowed inside structures. What is the best way to achieve this functionality?
Although structures nest in SML, signatures do not. It's not clear what functionality you want to achieve:
Hiding a named signature is impossible.
Having the INNER
signature depend on types declared in structure Outer
is achieved through fibration (the where type
clause). There's a length section on fibration in the tutorial by Harper and Pierce in Benjamin Pierce's book on advanced types in programming languages.