Dhall-haskell: enable conversion for `Map NonList|NonRecord Any`

Created on 4 Oct 2019  路  5Comments  路  Source: dhall-lang/dhall-haskell

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:

  • [x] 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 >
  • [x] Text
enhancement jsoyaml

Most helpful comment

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.

All 5 comments

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

```yaml
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: */

      `

Yes

Work on this issue should probably wait for the switch to aeson-yaml as planned in https://github.com/dhall-lang/dhall-haskell/pull/1248#issuecomment-537304799.

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.

I have made a separate issue for discussing dhall-yaml: https://github.com/dhall-lang/dhall-haskell/issues/1435.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mgajda picture mgajda  路  3Comments

jvanbruegge picture jvanbruegge  路  4Comments

vmchale picture vmchale  路  5Comments

SiriusStarr picture SiriusStarr  路  5Comments

Profpatsch picture Profpatsch  路  4Comments