[web-devel] Overlapping in routes
Alexey Khudyakov
alexey.skladnoy at gmail.com
Sun Jun 26 22:22:17 CEST 2011
On 26.06.2011 09:13, Michael Snoyman wrote:
> Hi Alexey,
>
> Simple answer is that overlapping is disabled by default. If you want
> to allow overlapping, you have to use a separate parseRoutesNoChecking
> function, which is not exported from Yesod by default (you have to
> look in web-routes-quasi).
>
It's disabled by default but could be enabled. So I have to understand
how should it work in case of overlapping. It's reckless to try to write
fast function without knowing what's correct.
Also at the moment I have idea about routes. Dispatch on constructors
works in constant time regardless of number of constructors. I mean
functions like this:
> f (Con1 _) = ...
> f (Con2 _) = ...
> ...
Therefore it could make sense to split routing in two parts. First is
to convert route into typed representation and second is to dispatch
in that representation.
Something along thes lines:
>
> class Routable r where
> fromRoute :: [Text] → Maybe r
> renderRoute :: r -> [Text]
>
> dispatch :: MyRoute -> Whatever
> dispatch = ...
Than it becomes easy to check correctness of routing, benchmark it.
And web-routes-quasi will become useful on its own.
Subsites do complicate matter but I don't think they could invalidate
this scheme.
P.S. I only benchmarked data types like that. But execution type do not
change from 10 to 300 constructors.
> data I = I1 Int | I2 Int ...
More information about the web-devel
mailing list