Camlp5: Converting a polymorphic type definition to strict syntax

42 views Asked by At

I have some old code using Camlp5. I have always used the version of Camlp5 shipped with Debian. Now this version 8.00.04 in strict mode. My old code does not compile any more. The problem seems to be the syntax for defining a polymorphic type. A minimal example is

let loc = Ploc.dummy

let _ = <:str_item< declare
  type t 'a = unit;
end >>

When I do

ocamlopt.opt -I +camlp5 -pp "camlp5o q_MLast.cmo" minimal.ml

I get

File "minimal.ml", line 3, characters 8-54:
3 | ........<:str_item< declare
  |   type t 'a = unit;
3 | end >>
Error: This expression has type 'a option
       but an expression was expected of type bool option * bool

My guess is that, since compiling last worked, Debian switched from transitional to strict mode for Camlp5. However, I have no idea what syntax strict mode expects for a polymorphic type definition. Nor where I could look it up.

How can I convert my old code to work with the new version of Camlp5?

1

There are 1 answers

0
kne On

Answering my own question.

Apparently, there is no quotation for type variables. Hence I needed to use an antiquotation:

let loc = Ploc.dummy

let _ = <:str_item< declare
  type t $list:[Ploc.VaVal (Some "a"), (None,false)]$ = unit;
end >>