Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Demonstrate conversion from standard Yesod to yesod-pure
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
import Yesod
data App = App
mkYesod "App" [parseRoutes|
/ HomeR GET
/fib/#Int FibR GET
|]
instance Yesod App
getHomeR :: Handler RepHtml
getHomeR = defaultLayout $ do
setTitle "Hello World!"
toWidget [whamlet|
<p>Hello World
<a href=@{FibR 5}>Fifth fib
|]
toWidget [lucius|p { color: red }|]
getFibR :: Int -> Handler RepHtml
getFibR i = defaultLayout $ do
setTitle "Fibs"
[whamlet|
<p>Fib for #{i}: #{fib i}
<a href=@{FibR $ i + 1}>Next fib
|]
fib :: Int -> Int
fib i = fibs !! i
fibs :: [Int]
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
main :: IO ()
main = warpDebug 3000 App
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.