mfp/extprot

name clash when using external types

Closed this issue · 2 comments

consider

type url = string options "ocaml.type" = "Url.t, Url.parse_exn, Url.show"

this will generate module Url with type Url.url = Url.t while the following generated code will reference Url.t directly which is not in scope now because generated Url module hides the external one.

mfp commented

I know this comes two years late, but here it goes for the record:

using a different alias, annoying as it might be, seems a reasonable workaround in this case

type url_ = ...

The ocaml type is "inlined", so that references to url_ in the protocol become Url.t in the generated type definitions. The one remaining annoyance outside the proto is that the generated pp_url_ function includes
the trailing underscore, but these functions are sort of an inner implementation detail anyway, as the user is only supposed to use messages externally.

yes, this works and that's what I ended up using