Comments (22)
@f-f: Alright, I created the relevant issues and added the "standardize me" label to track them:
from dhall-lang.
Note that if you have a relative path within a Dhall expression it could expand out to either a filesystem path or URI depending on how the surrounding expression was imported. I'm assuming that if you had separate as Path
and as URI
features, you would be okay with the behavior changing (i.e. possibly rejecting the relative path literal) depending on where the expression was hosted? Maybe you would even consider that a feature (i.e. ensure that it doesn't expand out to a URI)
I'm also assuming that there would be matching Path/toText
and URI/toText
built-ins, too
from dhall-lang.
@f-f: What I propose is to create a ticket for each of the missing features to standardize and a label like "To be standardized" to use both for those issues and also other issues in the pipeline (such as toMap
)
from dhall-lang.
Another way to approach this could be for as Location
to instead return a union of a type like this:
someImport as Location : < Local : Text | Remote : Text | Environment : Text | Missing >
... that way you don't need any additional types/conversion-functions and code can choose to handle as many cases as the tool supports. In other words, if a tool can handle both Local
and Remote
paths then it can implement support for that.
from dhall-lang.
I guess if https://hackage.haskell.org/package/dhall-1.8.2/docs/Dhall-Parser.html exported pathParser :: Parser Path
I could use exprA (Left <$> absoluteFileParser <|> Right <$> pathParser)
, and then a custom stage to expand absolute file paths into text literals or imports as necessary. Still, seems like it could be common enough for Dhall to learn this.
from dhall-lang.
Yeah, this seems like a good idea to me and I think it would be simple to standardize and implement because that information already exists under the hood. My only suggestion is to wait until I finish the import semantics standardization (ETA: ~1 month at current rate) so that this can be proposed as a diff to that standard
Also, would this still have type Text
or did you intend this to return a new FilePath
type?
Also, one minor suggestion I have is to shorten the name to as Path
from dhall-lang.
Cool, I'm happy to wait - no rush on my side. A FilePath
type seems more sensible, assuming that http://foo as Path
doesn't type check. Could do as URI
and have local paths expand to absolute file:///
paths too. Was mostly spit-balling though, I have no real feelings on the colour of the bike shed.
from dhall-lang.
Or perhaps I should use as File
instead of as Path
to make it clear that it comes from the filesystem, whereas Path
can be the more general term for something that could be either a URI
or File
from dhall-lang.
as File
seems to imply reading as raw bytes. So we're back to FilePath
😄
from dhall-lang.
Oh yeah, good point. File
would suggest reading the contents of the file, not the path to it.
from dhall-lang.
Another thought on this, it would be quite nice if I could have properly typed URLs for dhall-to-cabal
too:
homepage = https://github.com/ocharles/dhall-to-cabal as URL
or something. Perhaps related to this.
from dhall-lang.
Yeah, I was assuming that this would include as URL
, too
from dhall-lang.
@ocharles @gromakovsky Do you mind taking a quick look at dhall-lang/dhall-haskell#449?
from dhall-lang.
@kirelagin has done a great job laying the ground work here. What sections of the standard documents need to change? I tried looking for as Text
, but couldn't really see it.
from dhall-lang.
@ocharles: This is because as Text
has not yet been standardized because I keep forgetting to 🙂
The relevant part of the standard to change would be somewhere around here:
I can get around to it myself soon, if necessary
from dhall-lang.
If you can do Text
, I can follow suit with URL
and (File)Path
.
from dhall-lang.
@Gabriel439 related: do we have a checklist somewhere of "stuff that is implemented but needs to be standardized"? If not, let's have an umbrella-issue in dhall-lang
for it
I think we are missing only:
as Text
- multiline strings
from dhall-lang.
It looks like we stumbled on a use-case for this one in purescript/spago#244
The problem we have there is that relative paths are included in configurations as Text
. The application gets them as they were typed bby the user, but the fact that Dhall files can have relative import means that in some cases the paths will not be correct anymore. So a "relative → absolute" resolution based on the location of the Dhall file (and not on the CWD
of the program) as described above would solve this
I can take a stab at standardizing this, but I have some questions:
- Are we fine with having a new
Location
type or should we have several, likeFilePath
,URI
, etc. If so, why should we have more than one? - As the PR linked above implemented, I think
env:SOMEVAR as Location
would cause an error right?
from dhall-lang.
I think whether or not to have two separate types comes down to whether or not we want the type of the expression to change if imported remotely vs locally.
The argument in favor of one type is that code still functions when hosted remotely vs locally (similar to the reason we support custom header forwarding and relative import resolution for remote imports).
The argument against is that code might only work for a path and break for a URL, so the type changing when imported remotely is a feature from that point of view.
from dhall-lang.
@Gabriel439 @ocharles PR for standardizing this up in #585
from dhall-lang.
I'll reopen this to continue discussing as AbsolutePath
as detailed in #585 (comment)
from dhall-lang.
This has been open for over a year. I'm going to close. If there's still a desire for as AbsolutePath
, feel free to reopen or open a new issue.
from dhall-lang.
Related Issues (20)
- Q. Are you interested in syntax diagrams for Dhall? HOT 6
- Reversing order of Merge and Selection? HOT 2
- Too many duplicate type annotations? HOT 2
- `with` record update syntax removes other record fields HOT 4
- ABNF grammar should list "as Bytes" import mode
- Should the ABNF grammar disallow shebangs inside expressions? HOT 1
- eta-reducing to merge HOT 4
- Builtins operators reference: Missing record projection HOT 2
- ABNF grammar should explicitly disallow keywords as identifiers? HOT 2
- ABNF grammar should include a mandatory whitespace after `import-hashed`? HOT 1
- Improvements and fixes in the standard documentation HOT 3
- Is this an incorrect test file: `dhall-lang/tests/import/success/unit/ImportRelativeToHomeB.dhall`? HOT 2
- Link to non existing tweet
- A minimalistic proposal for do-notation
- Thoughts on introducing a minimum amount of type inference in Dhall HOT 1
- Introduce Bytes/length and Text/length as built-ins? HOT 3
- Is there a security hole: malicious sha256-protected cached content? HOT 1
- Eta-equivalence in `assert`? HOT 13
- A type level equivalent of the `with` keyword HOT 11
- Convert assertions to Leibniz equality types HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dhall-lang.