Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (26 sloc) 747 Bytes
{-# 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