New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support platform specific import schemes #1034
Comments
@lisael: Yeah, I think this is a good idea. The only issue I can think of is that |
This is not easy to address :/. The best idea I got so far adds a lot of complexity, and I hope someone comes with something simpler:
let dhallcfg = https://raw.githubusercontent.com/dhall-lang/dhall-lang/v17.0.0/Prelude/Dhall/config.dhall
in dhallcfg::{
, freezeCommand = toMap {
, pydhall = "pydhall --freeze"
, dhallj = "dhallj --freeze"
}
} and change the tools that need to freeze imports so that they call the provided command according to the scheme namespaces (this requires that the implementations respect the Note that the Prelude defaults could be pre-loaded with the configurations of the official implementations, and used if this file doesn't exist so most users won't have to create the configuration file as long as they use only official implementations). This is a lot of work (on several projects) but it's the price to pay if we want to allow platform-specific import while not making platforms that chose to implement those second-class citizens regarding the tooling. |
Of course the standardization and the implementation of this mechanism can be postponed after the standardization ot the original issue, that IMO adds value by itself, because at the moment none of the standard tooling can even parse dhall files that use custom imports. |
@lisael: Don't worry too much about it. I don't think it's a deal-breaker if |
Standardize the way platform-specific imports are parsed, resolved and CBOR-encoded.
Use cases
Integration with the platform's packaging standards
A Dhall implementation may want to rely on language-specific semantics to locate dhall files. This permits users to use the language ecosystem's packaging standards to ship dhall files with an application or a library.
It's the use-case raised by Dhallj implementers:
With pydhall I plan to support
pkg_resources
data loading mechanism too.Custom resolution routine
I'll show a pydhall example here, as it's actually the use case that triggered my reflexions. I don't want the discussion here to forget about this use-case :).
The pydhall API way to define a configuration schema is to define python classes:
Then the end-user can import this schema in their dhall configuration:
This import resolves as:
Proposed design
pydhall+
,dhallj+
..)[24, <hash>, <import_type>, 8, <scheme_as_string>, <uri_authority>, <uri_path_element> ...]
as Text
,...) and of the chaining semantics)Notes
An implementation SHOULD provide a way to show the user the hash of an import. This permits the user to use standard Dhall tooling on dhall files that use custom imports:
Is a correct input for
dhall format
,dhall normalize
,dhall-to-json
tools without modifying those, as long as the result of the import was cached beforehand.The text was updated successfully, but these errors were encountered: