yesodweb/yesod — Issue #174: Routes with pieces that cannot match should not overlap
Author: mlinksva
Created: 2011-11-22 06:17:19+00:00
State: open

```haskell
mkYesod "SomewhatOverlapping" [parseRoutes|
/ HomeR GET
/item/#Int ItemR GET
/item/#Int/edit ItemEditR GET
/item/new ItermNewR GET
/item/edited ItemEditedR POST
|]
```

/item/#Int is said to overlap with each of /item/new and /item/edited. I can see why in Yesod.Internal.findOverlaps -- unless the last static piece differs, or routes have different numbers of pieces, the routes overlap. But 'new' and 'edit' don't parse as Ints, so the routes are actually unambiguous.

Obviously I can get around this easily by changing /item/new to /item-new and /item/edited to /item-edited or similar, or if I were tied to the above scheme, use parseRoutesNoCheck.

But it would be convenient and nice to be able to specify any routes that can't actually overlap, without turning checks off ... doing this in a general way beyond known static pieces that can't be parsed as known dynamic pieces' types presumably would be harder (I don't know enough Haskell yet), but could be powerful for supporting legacy cases like /articles/2003 and /articles/#Year in the online book intro, if the type Year were defined to have a minimum bound of 2003, in which case it could also be tested whether pieces that can be parsed, also fall within range of dynamic value.