Skip to content
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

enable conversion for Map NonList|NonRecord Any #1379

Open
2 of 11 tasks
DrSensor opened this issue Oct 4, 2019 · 5 comments
Open
2 of 11 tasks

enable conversion for Map NonList|NonRecord Any #1379

DrSensor opened this issue Oct 4, 2019 · 5 comments

Comments

@DrSensor
Copy link

DrSensor commented Oct 4, 2019

I've just noticed that dhall-to-yaml doesn't transform Map Natural Text which I use to define .sublime-syntax match patterns (by converting List/indexed into Map)

block-comment:
  - captures:
    - mapKey: 1
      mapValue: punctuation.definition.comment.scl.scl
    match: (/\*)(?:\s*(?=\s|(\*/)))?
    push:
    - meta_scope: comment.block
    - pop: true
      captures:
      - mapKey: 0
        mapValue: punctuation.definition.comment.scl.scl
      match: \*/

Unlike JSON, key in YAML can be any type except List and Record, which are:

  • Text
  • Natural
  • Integer
  • Double
  • Bool
  • Optional Type, except List and Record
  • Union Type, except List and Record

Also, some key type that I think need to be converted too on dhall-to-json:

  • None Text, --omitEmpty will delete record field
  • Some Text
  • let any_Union_that_has = < T1: Text | T2: Optional Text | T3 >
  • Text
@sjakobi
Copy link
Collaborator

sjakobi commented Oct 4, 2019

To be clear: You'd like your example to be converted like this?

block-comment:
  - captures:
      1: punctuation.definition.comment.scl.scl
    match: (/\*)(?:\s*(?=\s|(\*/)))?
    push:
    - meta_scope: comment.block
    - pop: true
      captures:
        0: punctuation.definition.comment.scl.scl
      match: \*/
`

@DrSensor
Copy link
Author

DrSensor commented Oct 4, 2019

Yes

@sjakobi
Copy link
Collaborator

sjakobi commented Oct 5, 2019

Work on this issue should probably wait for the switch to aeson-yaml as planned in #1248 (comment).

@sjakobi
Copy link
Collaborator

sjakobi commented Oct 16, 2019

If we want to generate and parse YAML with non-Text keys, we will have to move away from the current Dhall-JSON-YAML pipeline, where Dhall expressions are first encoded as JSON and then translated to YAML. It would probably make sense to move the HsYAML-based logic to a separate package dhall-yaml(?) then. The aeson-yaml-based code could possibly stay in dhall-json. In any case it would be nice to get rid of the gpl flag again.

@sjakobi
Copy link
Collaborator

sjakobi commented Oct 18, 2019

I have made a separate issue for discussing dhall-yaml: #1435.

@DrSensor DrSensor changed the title dhall-to-yaml: enable conversion for Map NonList|NonRecord Any enable conversion for Map NonList|NonRecord Any Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants