ocaml-ppx / ppx_import

Less redundancy in type declarations and signatures
MIT License
89 stars 29 forks source link

%import + @@deriving not working #1

Closed hcarty closed 10 years ago

hcarty commented 10 years ago

With OCaml 4.02.0 and the latest utop, ppx_deriving and ppx_import from opam:

# #require "ppx_deriving";;
# #require "ppx_import";;
# type t = [%import: Complex.t] [@@deriving Show];;
Cannot derive Show for [%import :Complex.t]
whitequark commented 10 years ago

You need to require ppx_import before ppx_deriving.

hcarty commented 10 years ago

Ok, thanks. Is that documented? And is there a way around that restriction?

whitequark commented 10 years ago

Not really (I considered this obvious, probably it's not). And no.

hcarty commented 10 years ago

Now that I look back at it this it makes sense as the import needs to be applied before anything can be derived. It's not obvious that the order of the #requires implies the order of ppx application. That is probably specified in the ocamlfind documentation somewhere.

whitequark commented 10 years ago

I'm actually not sure that it does (it should), but it seemed to work so far.