kjo
kjo

Reputation: 35301

running `module M = ...` at the toplevel

Learning OCaml is rapidly bringing me to the point of complete physical exhaustion...

In this page

https://ocaml.org/learn/tutorials/modules.html

it says

In the ocaml toplevel, the following trick allows to visualize the contents of an existing module, such as List:

# module M = List;;
module M :
  sig
    val length : 'a list -> int
    val hd : 'a list -> 'a
    val tl : 'a list -> 'a list
    val nth : 'a list -> int -> 'a
    val rev : 'a list -> 'a list
    ...

When I type the exact same thing, character-by-character, at the toplevel, the only output I get is

module M = List

I.e., a helpful echo of what I just typed (minus the ;;), which at least reassures me that the interpreter is not lost in some infinite loop.

What do I need to do to get the advertised behavior?

Upvotes: 0

Views: 57

Answers (1)

rafix
rafix

Reputation: 1749

This trick only works for older ocaml versions ( < 4.02.X )

With the latest ocaml version you have to use '#show_module' , e.g.

#show_module List ;;

Upvotes: 5

Related Questions