Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 36 lines (26 sloc) 0.747 kB
d5bb18a @MedeaMelana Moved example to its own module
authored
1 {-# LANGUAGE TypeOperators #-}
27f7be8 @MedeaMelana Updated example to use the overloaded strings and the new / operator.
authored
2 {-# LANGUAGE OverloadedStrings #-}
ac94924 @MedeaMelana First version of TH support: the `parse' parts of the derived routers…
authored
3 {-# LANGUAGE TemplateHaskell #-}
a5dc2c5 @MedeaMelana Updated example
authored
4 {-# LANGUAGE NoMonoPatBinds #-}
ac94924 @MedeaMelana First version of TH support: the `parse' parts of the derived routers…
authored
5
6 import Web.Zwaluw
7 import Web.Zwaluw.TH
d5bb18a @MedeaMelana Moved example to its own module
authored
8
27f7be8 @MedeaMelana Updated example to use the overloaded strings and the new / operator.
authored
9 import Prelude hiding (id, (.), (/))
d5bb18a @MedeaMelana Moved example to its own module
authored
10 import Control.Category
11
12
27f7be8 @MedeaMelana Updated example to use the overloaded strings and the new / operator.
authored
13 -- A datatype modelling all pages in a website.
14
d5bb18a @MedeaMelana Moved example to its own module
authored
15 data Sitemap
16 = Home
a5dc2c5 @MedeaMelana Updated example
authored
17 | CatOverview
18 | CatDetail Int
19 | Product Int String
d5bb18a @MedeaMelana Moved example to its own module
authored
20 deriving (Eq, Show)
21
a5dc2c5 @MedeaMelana Updated example
authored
22 (rHome, rCatOverview, rCatDetail, rProduct) = $(deriveRouterTuple ''Sitemap)
27f7be8 @MedeaMelana Updated example to use the overloaded strings and the new / operator.
authored
23
24
25 -- The router. Specifies how to parse a URL into a Sitemap and back.
26
27 sitemap :: Router r (Sitemap :- r)
28 sitemap = id /
bd3d35c @MedeaMelana Full TH support.
authored
29 ( rHome
a5dc2c5 @MedeaMelana Updated example
authored
30 <> "categories" . cats
31 <> rProduct . ("product" / int . "-" . part)
bd3d35c @MedeaMelana Full TH support.
authored
32 )
33 where
a5dc2c5 @MedeaMelana Updated example
authored
34 cats = rCatOverview
35 <> rCatDetail / int
Something went wrong with that request. Please try again.