Problem
ppx authors frequently encounter issues where code generated implicitly relies on Stdlib modules and functions being in scope. This creates problems for users who:
- Use alternative standard libraries (Base, Core, etc.)
- Want explicit control over what's in scope
- Compile with
-nopervasives or similar flags
It's not rare to generate code that relies on Array, List, String Printf or even raise, invalid_arg, etc.
Current workarounds
Right now I track down each stdlib dependency in generated code (easy to lose cases such as |> or <=)
I have used a cram test with (flags -nopervasives) to catch assumptions (but it is unreliable since nopervasives propagate to all dependencies).
Potential solution
Could ppxlib/metaquote provide:
- Fully qualified generation - Generate
Stdlib.List.map instead of List.map
- Configuration option - Allow PPX authors to specify whether to generate qualified names
- Lint/warning system - Warn when generated code assumes stdlib availability
- Some utilities - A way to test ppx output without stdlib assumptions (nopervasives seems not useful)
Problem
ppx authors frequently encounter issues where code generated implicitly relies on Stdlib modules and functions being in scope. This creates problems for users who:
-nopervasivesor similar flagsIt's not rare to generate code that relies on
Array,List,StringPrintfor evenraise,invalid_arg, etc.Current workarounds
Right now I track down each stdlib dependency in generated code (easy to lose cases such as
|>or<=)I have used a cram test with
(flags -nopervasives)to catch assumptions (but it is unreliable since nopervasives propagate to all dependencies).Potential solution
Could ppxlib/metaquote provide:
Stdlib.List.mapinstead ofList.map