-
Notifications
You must be signed in to change notification settings - Fork 102
Open
Description
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
-nopervasivesor 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.mapinstead ofList.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)
Metadata
Metadata
Assignees
Labels
No labels