-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExampleTH.hs
More file actions
35 lines (26 loc) · 747 Bytes
/
Copy pathExampleTH.hs
File metadata and controls
35 lines (26 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE NoMonoPatBinds #-}
import Web.Zwaluw
import Web.Zwaluw.TH
import Prelude hiding (id, (.), (/))
import Control.Category
-- A datatype modelling all pages in a website.
data Sitemap
= Home
| CatOverview
| CatDetail Int
| Product Int String
deriving (Eq, Show)
(rHome, rCatOverview, rCatDetail, rProduct) = $(deriveRouterTuple ''Sitemap)
-- The router. Specifies how to parse a URL into a Sitemap and back.
sitemap :: Router r (Sitemap :- r)
sitemap = id /
( rHome
<> "categories" . cats
<> rProduct . ("product" / int . "-" . part)
)
where
cats = rCatOverview
<> rCatDetail / int