ocamltuareg

Why can't I evaluate this OCaml line with tuareg mode's C-c C-e command?


Background: I'm using Emacs 23.3, OCaml 3.12.0 and tuareg 1.45.7.

I'm looking at the Hickey OCaml book, and trying to run the examples on pg. 157 of the book, 167 of the .pdf. The problem arises with the expression

type ’a blob = < draw : unit; .. > as ’a

When I type that into my emacs buffer in tuareg-mode, and try to evaluate it with C-c C-e, I get the following error in the caml toplevel:

# type 'a blob = < draw : unit; .. > as ';;
Characters 39-41:
  type 'a blob = < draw : unit; .. > as ';;
                                         ^^
Error: Syntax error

Notice how the final a doesn't appear in command sent to the toplevel. If I type the line into the toplevel directly, it works just fine:

# type 'a blob = < draw : unit; .. > as 'a;;
type 'a blob = 'a constraint 'a = < draw : unit; .. >

So my question is: Why doesn't this work, and how can I fix it? Updating tuareg doesn't seem to be an option: I've tried to use tuareg version 2.0, but that won't even load properly.

Update: This was fixed in the tuareg SVN trunk as of 12/8/12. I don't think they've updated the release with the fix, but you can grab the trunk anonymously with

svn checkout svn://svn.forge.ocamlcore.org/svn/tuareg/trunk

bearing in mind the usual caveats about development vs. release versions.


Solution

  • That's a bug in Tuareg. For some reason he can't compute correctly the end of the phrase. To work around it, two possibilities:

    Edit: it appears that the bug has been reported upstream. Hopefully they'll fix it sooner or later.