osa1 github gitlab twitter cv rss

Epic OCamlYacc fail

March 1, 2013 - Tagged as: ocaml, en.

I’ve been trying to compile an OCaml library from 2000 recently and I came up against a strange OCamlYacc error; OCamlYacc doesn’t compile the parser file because parser function has a polymorphic type(with a type variable 'a).

At first I tried to understand with which concrete type 'a type variable is being equated, so that I could replace it with the concrete type and the program would be compiled.

After several hours wasted, I decided to follow some different path. I replaced type variables in .mly with some dummy type like my_epic_dummy_type and compiled it with OCamlYacc. Then I replaced my_epic_dummy_type types with the type variable 'a in compiled .ml and .mli files.

And the library worked as expected.

Now the question naturally arises: Why does OCamlYacc refuse to compile parser function with polymorphic type ? I have no idea.