Is there a way to get a list of the signature
s or structure
s available in the top-level environment from the SML/NJ REPL? I'm looking to get a listing of the signatures/structures that appear to be defined in the sources.cm
files in the sml source directory. Something along the lines of
- signature s = LIST;
only listing the bindings in the top-level environment instead.
You can make use of the internal structures that SML/NJ provides:
fun boundSignatures () =
let
fun isSignature symbol = Symbol.nameSpace symbol = Symbol.SIGspace
val signatures = List.filter isSignature (EnvRef.listBoundSymbols ())
in
List.app (fn s => print (Symbol.name s ^ "\n")) signatures
end
Please note that, due to autoloading, EnvRef.listBoundSymbols
won't return symbol names for modules which are available, but haven't yet been loaded:
- boundSignatures ();
ENVREF
val it = () : unit
- signature S = STATICENV;
[autoloading]
[autoloading done]
- boundSignatures ();
STATICENV
ENVREF
S
val it = () : unit