A discussion we’re currently having around our JVM implementation https://github.com/travisbrown/dhallj is how to handle imports from the JVM classpath. When running on the JVM you basically have two parallel filesystems - the local filesystem and the classpath and imports are potentially ambiguous between the two.
We’ve thought of a few options for solving this and thought we’d seek feedback here.
Option 1: a (very small) extension to the spec
We would allow the user to write let import = cp:/absolute/path/to/import in ...
This uses very similar syntax to env
imports and requires the user to specify an absolute path to avoid classloader-related ambiguity. I believe the semantics would be pretty much the same as an absolute path local import (including referential sanity), just with a different mechanism for resolving the content of the file.
Option 2
No extension to the spec. We would require the user to pass some kind of discriminating function
prefix : Path -> FileSystem
Obvious advantage is that it doesn’t require extending the spec. Disadvantages are the user experience and the fact that it doesn’t really help you if the prefixes are the same on both local and classpath filesystems (unlikely though this may be!)
Option 3
Something else we have’t thought of! Suggestions?