Mayer Goldberg
Mayer Goldberg

Reputation: 1438

pre-loaded module in ocaml, and their contents

Two questions:

  1. How can I find what are the modules that are pre-loaded in my ocaml session?
  2. Given a module, how can I list its contents?

In SML, a standard "trick" was to define a dummy module and open in it a module the contents of which I wanted to inspect. The signature of the dummy module would then list the contents of the module in SML. This does not work in ocaml.

Found this: To see the packages pre-loaded, use #use "topfind";; to use the topfind package, and the #list;; will list the pre-loaded packages!

Upvotes: 1

Views: 72

Answers (1)

Jeffrey Scofield
Jeffrey Scofield

Reputation: 66808

I don't know a way to list the modules currently loaded.

To show the contents of a module:

# #show_module Pervasives;;
module Pervasives :
  sig
    external raise : exn -> 'a = "%raise"
    external raise_notrace : exn -> 'a = "%raise_notrace"
    val invalid_arg : string -> 'a
    . . .
    val unsafe_really_input : in_channel -> bytes -> int -> int -> unit
    val do_at_exit : unit -> unit
  end

The initial set of top-level directives is given in Section 9.2 of the OCaml manual.

Upvotes: 2

Related Questions