Skip to content

@snoyberg /hello-no-qq.hs
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Yesod routing with QuasiQuotes
{-# LANGUAGE TypeFamilies, MultiParamTypeClasses,
TemplateHaskell, OverloadedStrings #-}
import Yesod
import Yesod.Routes.TH
data HelloWorld = HelloWorld
mkYesod "HelloWorld"
[ ResourceLeaf Resource
{ resourceName = "HomeR"
, resourcePieces = []
, resourceDispatch = Methods Nothing ["GET"]
}
, ResourceLeaf Resource
{ resourceName = "FibR"
, resourcePieces =
[ (True, Static "fib")
, (True, Dynamic "Int")
]
, resourceDispatch = Methods Nothing ["GET"]
}
]
instance Yesod HelloWorld
getHomeR :: Handler RepHtml
getHomeR = defaultLayout $ toWidget $ const ("Hello World" :: Html)
fibs :: [Int]
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
getFibR :: Int -> Handler RepHtml
getFibR i = defaultLayout $ toWidget $ const $ toHtml $ fibs !! i
main :: IO ()
main = warpDebug 3000 HelloWorld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.