[web-devel] [Yesod] Re: ANN: Wai routes 0.7

Anupam Jain ajnsit at gmail.com
Wed Jun 10 19:18:45 UTC 2015


You are right. The example in the README is meant to be more of a
template which gives you a flavor of what the code looks like. It also
has chunks of code missing (and with ellipses in its place) that would
need to be filled in before it would compile. The code in the
examples/ directory on github has working code examples with cabal
files (https://github.com/ajnsit/wai-routes/blob/master/examples/Subsites.hs).
I am working on improving the documentation, and adding more examples.

To answer your other questions -

1. I just released v0.7 today. Docs on Hackage are built periodically,
and we should have proper documentation generated soon.

2. The TH code generates a "resource" for your route which is like an
abstract representation of your route declaration. It can be reused in
other parts of the code. Notably it is useful when you want to
separate the declaration for the Route datatype and the dispatching
code. In your example, since the resource is created but not used or
exported, it generates a warning. For now you can safely ignore it.

3. "HandlerS sub master" is the type of a handler for a Subsite "sub"
running within a master site "master". Unfortunately that type is not
very easy to work with. "HandlerM" is a Monadic type that provides
easy access to all wai-routes functionality, and can then be converted
to a HandlerS using runHandlerM. When you don't have a subsite, the
type is simply "HandlerM sub master", which is aliased to "Handler
master". That's why in your example, the handlers all have the type
"Handler MyRoute".

4. "RouteM" is another Monadic type which makes it easy to compose
multiple routes and middleware together to create a final wai
application. This along with "nested routes", and "subsites", helps
you better organise your application.

HTH

-- Anupam



On Wed, Jun 10, 2015 at 8:38 PM, Njagi Mwaniki
<mwanikibusiness at gmail.com> wrote:
> It could be just me but the example in your README is totally broken.  It
> needs at least the extensions like QuasiQotes and TemplateHaskell. Also
> where does DB (used in your example) come from?
>
> Anyway using other examples from your README I got a minimal working example
> here: https://gist.github.com/urbanslug/58a584c002f54ad75c02
>
> I have a few questions regarding the types.
>
> * The haddocks on hackage don't work yet, do they?
> * in myRoute L21 I get the warning `Defined but not used:
> ‘resourcesMyRoute’` can you help with that?
> * I'm confused about this type signature "runHandlerM :: HandlerM sub master
> () -> HandlerS sub master"
> * What are HandlerM and RouteM and sub and master? They are in many type
> signatures and I don't get them.
>
> Thank you.
>
> On Wednesday, 10 June 2015 01:54:33 UTC+3, Anupam wrote:
>>
>> Hi all,
>>
>> I have just released v0.7 of wai-routes, the typesafe urls framework
>> for wai. After letting the code rot for several months, I finally
>> managed to carve out some time to do a bit of housekeeping. The code
>> now compiles with ghc 7.8 and 7.10, and is compatible with wai-3.0.
>> The dependency on yesod-routes has also been removed, as that package
>> was deprecated, and its code has been folded into wai-routes.
>>
>> I also took the opportunity to add a few long pending features -
>> 1. Subsites! Simpler than the corresponding concept in Yesod, though
>> probably less powerful as well. This is still an evolving experimental
>> feature.
>> 2. Ability to get information about the currently executing route,
>> including the Route Attributes (which is exactly the same thing as in
>> Yesod).
>>
>> Get it at -
>> [http://hackage.haskell.org/package/wai-routes]
>> [https://github.com/ajnsit/wai-routes].
>>
>> Feedback would be greatly appreciated, especially from people using
>> wai-routes in their projects!
>>
>> -- Anupam
>
> --
> You received this message because you are subscribed to the Google Groups
> "Yesod Web Framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to yesodweb+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


More information about the web-devel mailing list