{"action":"created","issue":{"url":"https://api.github.com/repos/Happstack/web-routes/issues/1","labels_url":"https://api.github.com/repos/Happstack/web-routes/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/Happstack/web-routes/issues/1/comments","events_url":"https://api.github.com/repos/Happstack/web-routes/issues/1/events","html_url":"https://github.com/Happstack/web-routes/pull/1","id":129544971,"number":1,"title":"PathInfo: Write generalized instance for [a]","user":{"login":"shockkolate","id":4142775,"avatar_url":"https://avatars.githubusercontent.com/u/4142775?v=3","gravatar_id":"","url":"https://api.github.com/users/shockkolate","html_url":"https://github.com/shockkolate","followers_url":"https://api.github.com/users/shockkolate/followers","following_url":"https://api.github.com/users/shockkolate/following{/other_user}","gists_url":"https://api.github.com/users/shockkolate/gists{/gist_id}","starred_url":"https://api.github.com/users/shockkolate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shockkolate/subscriptions","organizations_url":"https://api.github.com/users/shockkolate/orgs","repos_url":"https://api.github.com/users/shockkolate/repos","events_url":"https://api.github.com/users/shockkolate/events{/privacy}","received_events_url":"https://api.github.com/users/shockkolate/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-28T19:02:35Z","updated_at":"2016-01-29T22:20:24Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Happstack/web-routes/pulls/1","html_url":"https://github.com/Happstack/web-routes/pull/1","diff_url":"https://github.com/Happstack/web-routes/pull/1.diff","patch_url":"https://github.com/Happstack/web-routes/pull/1.patch"},"body":"This patch replaces the two specialized instances of `PathInfo` for `[String]` and `[Text]` with an instance for `[a]` for all types `a`. The generalized instance has identical behaviour for `[String]` and `[Text]` to the removed instances.\r\n\r\nFor example, in combination with the `web-routes-th` package, the following data type is possible:\r\n\r\n```haskell\r\ndata Route = Search\r\n           | ViewSubTree [Integer]\r\n           | NewLeaf [Integer] String\r\n```\r\n\r\nThis would match for the following URLs:\r\n\r\n```\r\n/search\r\n/view-sub-tree/<Integer>/<Integer>/..etc..\r\n/new-leaf/<Integer>/<Integer>/..etc../<String>\r\n```"},"comment":{"url":"https://api.github.com/repos/Happstack/web-routes/issues/comments/176996159","html_url":"https://github.com/Happstack/web-routes/pull/1#issuecomment-176996159","issue_url":"https://api.github.com/repos/Happstack/web-routes/issues/1","id":176996159,"user":{"login":"stepcut","id":174413,"avatar_url":"https://avatars.githubusercontent.com/u/174413?v=3","gravatar_id":"","url":"https://api.github.com/users/stepcut","html_url":"https://github.com/stepcut","followers_url":"https://api.github.com/users/stepcut/followers","following_url":"https://api.github.com/users/stepcut/following{/other_user}","gists_url":"https://api.github.com/users/stepcut/gists{/gist_id}","starred_url":"https://api.github.com/users/stepcut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stepcut/subscriptions","organizations_url":"https://api.github.com/users/stepcut/orgs","repos_url":"https://api.github.com/users/stepcut/repos","events_url":"https://api.github.com/users/stepcut/events{/privacy}","received_events_url":"https://api.github.com/users/stepcut/received_events","type":"User","site_admin":false},"created_at":"2016-01-29T22:20:23Z","updated_at":"2016-01-29T22:20:23Z","body":"The generalized instance permits nested lists -- but nested lists are problematic because they are ambiguous. As implemented, the result is currently a runtime parse error:\r\n\r\n```\r\n*Web.Routes.PathInfo> fromPathInfo (Data.Text.Encoding.encodeUtf8  $ toPathInfo [[1,2,3::Int],[4,5,6::Int]]) :: Either String [[Int]]\r\n*** Exception: Text.ParserCombinators.Parsec.Prim.many: combinator 'many' is applied to a parser that accepts an empty string.\r\n```\r\n\r\nIf we think more abstractly about the problem, if we have the sequence `[[1,2,3],[4,5,6]]` and serialize that to `/1/2/3/4/5/6` we have lost important structural information. `[[1,2,3,4],[5,6]]` also serializes to `/1/2/3/4/5/6`. This means we can not uniquely parse URL back to a unique value.\r\n\r\nAccordingly, I am reluctant to pull this patch.\r\n\r\nI should note that it could be argued that the existing instances are also bogus since they would cause similar problems with:\r\n\r\n```\r\ndata Route = Foo [Text] [Text]\r\n```\r\n"}}