Skip to content

Instantly share code, notes, and snippets.

@Tarrasch
Created October 2, 2011 09:56
Show Gist options
  • Save Tarrasch/1257291 to your computer and use it in GitHub Desktop.
Save Tarrasch/1257291 to your computer and use it in GitHub Desktop.
{-# LANGUAGE TypeFamilies, QuasiQuotes, OverloadedStrings, MultiParamTypeClasses, TemplateHaskell #-}
{-# LANGUAGE GADTs #-}
import Yesod
import Control.Applicative
import qualified Data.Text as T
import Data.Text (Text)
class YesodSlug site table where
type Slug table
slug :: table -> Text
--------- Example usage
data MySite = MySite
getRootR = defaultLayout $ addHamlet [hamlet| hello |]
mkYesod "MySite" [parseRoutes|
/ RootR GET
|]
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persist|
BlogPost
title Text
slug Text
UniqueSlug slug
|]
instance Yesod MySite where approot _ = ""
main = warpDebug 3000 MySite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment