When resolving module name conflicts, you must obtain the signature ORD_MAP

I am working on a relatively large SML code base. It was originally written to compile with MLton, but now I work with it under SML / NJ. I need to use RedBlackMapFn , which is defined in smlnj-lib.cm . However, I get the error message:

 elaborate/elaborate-bomenv.fun:9.20-9.27 Error: unbound signature: ORD_KEY elaborate/elaborate-bomenv.fun:14.21-14.40 Error: unbound functor: RedBlackMapFn elaborate/elaborate-bomenv.fun:32.20-32.27 Error: unbound signature: ORD_KEY elaborate/elaborate-bomenv.fun:37.21-37.40 Error: unbound functor: RedBlackMapFn 

Therefore, I assume that smlnj-lib.cm not pulled by CM. To fix this, I added $/smlnj-lib.cm to the sources.cm file in the directory in which I work. This causes a separate issue:

 elaborate/sources.cm:25.1-25.18 Error: structure Random imported from $SMLNJ-LIB/Util/ smlnj-lib.cm@243997 (random.sml) and also from ./(sources.cm):lib/(sources.cm):basic/(sources.cm):random.sml elaborate/sources.cm:25.1-25.18 Error: structure Queue imported from $SMLNJ-LIB/Util/ smlnj-lib.cm@436143 (queue.sml) and also from ./(sources.cm):lib/(sources.cm):basic/(sources.cm):two-list-queue.sml 

No dice. I tried to remove the Random structure that comes from ./(sources.cm):lib/(sources.cm):basic/(sources.cm):random.sml , but it seems that it is not equivalent to the one defined in the standard library, so I can’t just replace it with another one.

I would like to use something like Python import ... from ... as ... mechanism to give a new name Random , coming from the standard library, but the CM documentation does not offer any hints as to how I go. about.

How can I resolve file name conflict in multiple SML files?

+5
source share
1 answer

I ended up splitting the problematic file into a separate .cm . The problem file is here elaborate-bomenv.{sig, fun} . The .cm file for this sources.cm directory that caused errors when it looked like this:

 Group ... is $/basis.cm ... elaborate-bomenv.fun elaborate-bomenv.sig ... 

So, I made elaborate-bomenv-sources.cm that looks like this:

 Group signature ELABORATE_BOMENV functor BOMEnv is $/smlnj-lib.cm ... elaborate-bomenv.sig elaborate-bomenv.fun 

and modified the original sources.cm as follows:

 Group ... is $/basis.cm ... ./elaborate-bomenv-sources.cm ... 

Which is ugly, but it works.

+3
source

Source: https://habr.com/ru/post/1200738/


All Articles