Q:

How to get type information in interactive Ocaml?

I am using Ocaml of version 4.  When I define interactively some type, the interpreter prints out string representation of the type immediately after that:
# type foo = Yes | No;;         <-- This is what I entered
type foo = Yes | No             <-- This is what interpreter bounced

But after I type more definitions, sometimes I want to see the text representation of the type again.
In Haskell, I could type ":t foo".
How can I do this in Ocaml?

A:

In utop you can use the #typeof directive:
#typeof "list";;
type 'a list = [] | :: of 'a * 'a list 

You can put values and types inside double quotes:
let t = [`Hello, `World];;
#typeof "t";;
val t : ([> `Hello ] * [> `World ]) list   

P.S. And even better solution would be to use merlin.

