{"action":"created","issue":{"url":"https://api.github.com/repos/Gabriel439/Haskell-Dhall-Library/issues/38","repository_url":"https://api.github.com/repos/Gabriel439/Haskell-Dhall-Library","labels_url":"https://api.github.com/repos/Gabriel439/Haskell-Dhall-Library/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/Gabriel439/Haskell-Dhall-Library/issues/38/comments","events_url":"https://api.github.com/repos/Gabriel439/Haskell-Dhall-Library/issues/38/events","html_url":"https://github.com/Gabriel439/Haskell-Dhall-Library/issues/38","id":222083138,"number":38,"title":"Record Subtyping / Union Types?","user":{"login":"markus1189","id":591567,"avatar_url":"https://avatars3.githubusercontent.com/u/591567?v=3","gravatar_id":"","url":"https://api.github.com/users/markus1189","html_url":"https://github.com/markus1189","followers_url":"https://api.github.com/users/markus1189/followers","following_url":"https://api.github.com/users/markus1189/following{/other_user}","gists_url":"https://api.github.com/users/markus1189/gists{/gist_id}","starred_url":"https://api.github.com/users/markus1189/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markus1189/subscriptions","organizations_url":"https://api.github.com/users/markus1189/orgs","repos_url":"https://api.github.com/users/markus1189/repos","events_url":"https://api.github.com/users/markus1189/events{/privacy}","received_events_url":"https://api.github.com/users/markus1189/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-04-17T07:31:43Z","updated_at":"2017-04-18T11:12:22Z","closed_at":null,"body":"Are there any plans to support a form of record subtyping?  For example if `<:` is the subtyping relation that considers \r\n\r\n> `record1 <: record2` iff `record1` contains a subset of the attributes of `record2`\r\n\r\nThe advantage is that you can allow users to have multiple configurations in one file and/or let them specify their own custom additonal files.\r\n\r\nTo be more concrete, consider this example:\r\n\r\n```\r\n$ cat > configSchema1\r\n{ consumerKey: Text, accessToken: Text, browser: Text, username: Text }\r\n$ cat > configSchema2\r\n{ username: Text, timeout: Natural }\r\n$ cat > programConfig\r\n{ consumerKey: \"123\",\r\n  accessToken: \"123\",\r\n  browser: \"chromium\",\r\n  username: Text\r\n}\r\n```\r\n\r\nIt would be cool if the `programConfig` could be typed as either `configSchema1` or `configSchema2`.  \r\n\r\nAdditional thought, what about anonymous type level unions? e.g. `configSchema1 \\/ configSchema2`, where `\\/` is the type level union type for records, s.t. the result would be \r\n\r\n```\r\n{ consumerKey: Text, accessToken: Text, browser: Text, username: Text, timeout: Natural }\r\n``` \r\n\r\nThen you could write:\r\n\r\n```\r\n$ cat > typedConfig\r\n./programConfig : ./configSchema1 \\/ ./configSchema2\r\n```\r\n\r\nOh and of course besides the union thing, subtyping would allow it to pass \"larger\" records into functions taking smaller ones:\r\n\r\n```\r\nlet f = \\(r: {foo: Text, bar: Natural}) -> r.foo\r\nin f { foo = \"123\", bar = +1, baz = \"foobar\" } \r\n```\r\n\r\nWhich would currently fail because the record as an unexpected field `baz`"},"comment":{"url":"https://api.github.com/repos/Gabriel439/Haskell-Dhall-Library/issues/comments/294788122","html_url":"https://github.com/Gabriel439/Haskell-Dhall-Library/issues/38#issuecomment-294788122","issue_url":"https://api.github.com/repos/Gabriel439/Haskell-Dhall-Library/issues/38","id":294788122,"user":{"login":"markus1189","id":591567,"avatar_url":"https://avatars3.githubusercontent.com/u/591567?v=3","gravatar_id":"","url":"https://api.github.com/users/markus1189","html_url":"https://github.com/markus1189","followers_url":"https://api.github.com/users/markus1189/followers","following_url":"https://api.github.com/users/markus1189/following{/other_user}","gists_url":"https://api.github.com/users/markus1189/gists{/gist_id}","starred_url":"https://api.github.com/users/markus1189/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markus1189/subscriptions","organizations_url":"https://api.github.com/users/markus1189/orgs","repos_url":"https://api.github.com/users/markus1189/repos","events_url":"https://api.github.com/users/markus1189/events{/privacy}","received_events_url":"https://api.github.com/users/markus1189/received_events","type":"User","site_admin":false},"created_at":"2017-04-18T11:12:22Z","updated_at":"2017-04-18T11:12:22Z","body":"Okay I wholeheartedly support the idea of avoiding all forms of subtyping as an experiment :)\r\n\r\nIf I understand `inherit` correctly, that does not solve the use case of having a `larger` config file where additional fields are ignored, right? The use case I have in mind is something like:\r\n\r\n```\r\n$ cat > config\r\n{ \r\n  one = 1,\r\n  two = 2,\r\n  three = 3\r\n}\r\n```\r\n\r\nNow imagine this `config` file as being shared by two libraries that use `dhall` to configure themself.\r\n\r\nHowever, both of them need only a subset of the actual config:\r\n\r\n```\r\n$ cat > schema1\r\n{ one : Integer, two: Integer }\r\n$ cat schema2\r\n{ two : Integer, three : Integer }\r\n```\r\n\r\nIt would be cool, if there was something that allows you to have `config` as-is, where it represents a set of all required attributes, without forcing you to split them.\r\n\r\nI think I'll have to think about something that makes this possible without subtyping."}}
{"actor":{"display_login":"markus1189"}}