Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ocaml: Error - this expression has type x but is used with type x

Tags:

ocaml

tuareg

This is my error:

Error: This expression has type nfa but is here used with type nfa

What could possibly be happening to cause this? I'm using emacs tuareg, and loading evaluating files one by one. Sometimes this happens, and other times it doesn't.

like image 298
Nick Heiner Avatar asked Sep 30 '09 01:09

Nick Heiner


1 Answers

There's a good description of this in the ocaml tutorial. What's happened is you have shadowed a type definition with a new definition:

type nfa = int
let f (x: nfa) = x

type nfa = int
let g (x: nfa) = x

Restarting the top-level will clear out the old definitions.

like image 94
David Crawshaw Avatar answered Sep 18 '22 14:09

David Crawshaw