PathInfo: Write generalized instance for [a]#1
PathInfo: Write generalized instance for [a]#1ori-sky wants to merge 1 commit intoHappstack:masterfrom
Conversation
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.
For example, in combination with the web-routes-th package, the
following data type is possible:
data Route = Search
| ViewSubTree [Integer]
| NewLeaf [Integer] String
This would match for the following URLs:
/search
/view-sub-tree/<Integer>/<Integer>/..etc..
/new-leaf/<Integer>/<Integer>/..etc../<String>
|
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: If we think more abstractly about the problem, if we have the sequence Accordingly, I am reluctant to pull this patch. I should note that it could be argued that the existing instances are also bogus since they would cause similar problems with: |
|
Ah, I understand the problem. Whilst I think the ability to parse and match on URLs of that kind of format is still a desirable thing, I can't really think of any way to solve the problem you've outlined. I should note that I actually did notice a similar problem to the case you highlighted with Might a plausible alternative to keep structural information be to represent lists as a list of comma-separated values or something similar? For example: would equate to: NewLeaf [1, 2, 53] "hello" |
This patch replaces the two specialized instances of
PathInfofor[String]and[Text]with an instance for[a]for all typesa. The generalized instance has identical behaviour for[String]and[Text]to the removed instances.For example, in combination with the
web-routes-thpackage, the following data type is possible:This would match for the following URLs: