Search code examples
ocamlutop

Is there a way to list all functions of a module in utop?


In utop, when opening a library (via ~require ...) or when opening a module (via open Module_name), is there a way to get the content of the library or module? utop offers this by completion tabs, but I would like to see all the functions at once.


Solution

  • In utop you can use the #show command. For example

    utop # #show Stack;;
    module Stack :
      sig
        type 'a t
        exception Empty
        val create : unit -> 'a t
        val push : 'a -> 'a t -> unit
        val pop : 'a t -> 'a
        val top : 'a t -> 'a
        val clear : 'a t -> unit
        val copy : 'a t -> 'a t
        val is_empty : 'a t -> bool
        val length : 'a t -> int
        val iter : ('a -> unit) -> 'a t -> unit
      end