Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upUse "in" as a field name (despite its keyword status) #31
Comments
chepner
changed the title
Use "in" as a field name
Use "in" as a field name (despite its keyword status)
Mar 16, 2017
This comment has been minimized.
This comment has been minimized.
|
There isn't a way to name a field For example, the https://github.com/Gabriel439/Haskell-Dhall-Library/blob/master/src/Dhall.hs#L428 So it would make sense to do the same for the However, that change alone would require that you need to compile your own custom |
This comment has been minimized.
This comment has been minimized.
scott-fleischman
commented
Apr 28, 2017
|
It would also be handy to have a way to put dashes in record names, such as While a transformation function could work, it may also be beneficial to allow some sort of escaped or quoted record field name, perhaps like the |
This comment has been minimized.
This comment has been minimized.
|
I like the idea of quoted record field names. That should be pretty easy to implement and it solves this problem cleanly |
This comment has been minimized.
This comment has been minimized.
|
In Scala you can use backticks, I personally like that as syntax
|
This comment has been minimized.
This comment has been minimized.
|
So for @scott-fleischman's use case, I can actually just add |
This comment has been minimized.
This comment has been minimized.
|
So I have some new reservations about this proposal after attempting a first pass at implementing this. Let's assume for simplicity that we begin from @markus1189's proposal and use backticks to escape identifiers. The next decision is: what set of characters do you permit within backticks? There are three choices that I'm ware of:
So my inclination here is to still rely on field modifiers instead of verbatim identifiers to solve the original problem, but to add |
Gabriel439
added a commit
that referenced
this issue
Apr 30, 2017
This comment has been minimized.
This comment has been minimized.
|
I think the argument for the 2) approach is that you can have a pipeline into a format that is not dhall: |
This comment has been minimized.
This comment has been minimized.
|
So for each |
This comment has been minimized.
This comment has been minimized.
|
Actually, I've changed my mind on this. I'll support the second option since it seems like an unusually common use case that shouldn't require going to the Haskell API |
Gabriel439
added a commit
that referenced
this issue
Apr 30, 2017
This comment has been minimized.
This comment has been minimized.
|
Alright. I created a pull request that implements @markus1189's proposed syntax: #43 Let me know if that solves your use case |
chepner commentedMar 16, 2017
Is there any way to produce a record with a field name "in"? (I fear not, since it's a keyword for
letexpressions.) I was playing with the idea of using Dhall to produce a YAML file (withdhall-to-yaml) for use with Swagger (http://swagger.io), which as part of defining parameters that an API endpoint can accept, uses an object key "in" to specify where a parameter can occur.For example,
to produce