{"action":"created","issue":{"url":"https://api.github.com/repos/dhall-lang/dhall-json/issues/27","repository_url":"https://api.github.com/repos/dhall-lang/dhall-json","labels_url":"https://api.github.com/repos/dhall-lang/dhall-json/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/dhall-lang/dhall-json/issues/27/comments","events_url":"https://api.github.com/repos/dhall-lang/dhall-json/issues/27/events","html_url":"https://github.com/dhall-lang/dhall-json/issues/27","id":320326139,"number":27,"title":"Convert some association lists to homogeneous maps?","user":{"login":"Gabriel439","id":1313787,"avatar_url":"https://avatars3.githubusercontent.com/u/1313787?v=4","gravatar_id":"","url":"https://api.github.com/users/Gabriel439","html_url":"https://github.com/Gabriel439","followers_url":"https://api.github.com/users/Gabriel439/followers","following_url":"https://api.github.com/users/Gabriel439/following{/other_user}","gists_url":"https://api.github.com/users/Gabriel439/gists{/gist_id}","starred_url":"https://api.github.com/users/Gabriel439/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gabriel439/subscriptions","organizations_url":"https://api.github.com/users/Gabriel439/orgs","repos_url":"https://api.github.com/users/Gabriel439/repos","events_url":"https://api.github.com/users/Gabriel439/events{/privacy}","received_events_url":"https://api.github.com/users/Gabriel439/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":24,"created_at":"2018-05-04T15:48:19Z","updated_at":"2018-05-18T14:17:44Z","closed_at":"2018-05-14T15:51:32Z","author_association":"COLLABORATOR","body":"The context for this is: https://github.com/dhall-lang/dhall-lang/issues/136\r\n\r\nMany JSON schemas expect homogeneous maps (i.e. the JSON equivalent of Haskell's `Data.Map.Map`), such as in the following contrived JSON configuration:\r\n\r\n```json\r\n{\r\n  \"users\": {\r\n    \"john\": {\r\n      \"admin\": false\r\n    },\r\n    \"mary\": {\r\n      \"admin\": true\r\n    },\r\n    \"alice\": {\r\n      \"admin\": false\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n... where you would not necessarily know the set of users statically in advance.\r\n\r\nThe idiomatic Dhall type corresponding to the above JSON configuration would be something like:\r\n\r\n```haskell\r\n{ users : List { key : Text, value : { admin : Bool } } }\r\n```\r\n\r\nThe question here is whether or not `dhall-to-json` and `dhall-to-yaml` should support automatically converting association lists with a reserved field name to homogeneous maps.\r\n\r\nThe easiest way to explain this is to show the following example encoding of the above JSON configuration:\r\n\r\n```haskell\r\n{ users =\r\n    [ { key = \"john\", value = { admin = False } }\r\n    , { key = \"mary\", value = { admin = True } }\r\n    , { key = \"alice\", value = { admin = False } }\r\n    ]\r\n}\r\n```\r\n\r\nSome variations on this proposal:\r\n\r\n* Make this behavior opt-in (i.e. off by default) and guard it behind a command line flag\r\n* Don't implement this in `dhall-to-json`/`dhall-to-yaml` and instead implement this in more specific integrations (like `dhall-to-terraform`)\r\n* Don't reserve the field named `value`; any field name is fine as long as the other field is named `key`\r\n* Reserve different field names\r\n* Allow the user to specify which field name(s) to reserve for this transformation on the command line\r\n* Don't do this at all :)"},"comment":{"url":"https://api.github.com/repos/dhall-lang/dhall-json/issues/comments/390221770","html_url":"https://github.com/dhall-lang/dhall-json/issues/27#issuecomment-390221770","issue_url":"https://api.github.com/repos/dhall-lang/dhall-json/issues/27","id":390221770,"user":{"login":"Gabriel439","id":1313787,"avatar_url":"https://avatars3.githubusercontent.com/u/1313787?v=4","gravatar_id":"","url":"https://api.github.com/users/Gabriel439","html_url":"https://github.com/Gabriel439","followers_url":"https://api.github.com/users/Gabriel439/followers","following_url":"https://api.github.com/users/Gabriel439/following{/other_user}","gists_url":"https://api.github.com/users/Gabriel439/gists{/gist_id}","starred_url":"https://api.github.com/users/Gabriel439/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gabriel439/subscriptions","organizations_url":"https://api.github.com/users/Gabriel439/orgs","repos_url":"https://api.github.com/users/Gabriel439/repos","events_url":"https://api.github.com/users/Gabriel439/events{/privacy}","received_events_url":"https://api.github.com/users/Gabriel439/received_events","type":"User","site_admin":false},"created_at":"2018-05-18T14:17:44Z","updated_at":"2018-05-18T14:17:44Z","author_association":"COLLABORATOR","body":"@blast-hardcheese: The way I see it, if the Dhall to Terraform bindings are the only place to get a schema for Terraform features that will encourage more people to use Dhall 🙂"}}
{"actor":{"display_login":"Gabriel439"}}