fatuhoku
fatuhoku

Reputation: 4911

How do you inspect the type of (*) on OCaml's toplevel?

I wanted to see the type of the multiplication function (*), so I tapped it into the OCaml toplevel.

# (*)

However, the toplevel echoed:

(*);; 1: this is the start of a comment.

and then consumed any further input I put in. I figured that I had to get out of the comment mode by pressing Ctrl+d to send EOF. Great. But surely, I should be able to query the type of any function, including our mysterious multiplication function (*)?!

I would be incredibly disappointed if that is a limitation of the toplevel.

Upvotes: 7

Views: 1636

Answers (1)

sepp2k
sepp2k

Reputation: 370435

It does recognize *) as the end of the comment, but it's still waiting for the end of the expression. I.e. if you enter two semicolons, it will give you a syntax error and allow you to enter another expression.

To get the function * type ( * );; with spaces to distinguish it from comment symbols.

Upvotes: 17

Related Questions