Created
June 30, 2011 15:52
-
-
Save gregwebs/1056520 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE QuasiQuotes #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
import Yesod | |
import Database.Persist | |
import Database.Persist.MongoDB | |
import Database.MongoDB.Connection (ConnPool) | |
mkPersist [persist| | |
Person | |
name String | |
age Int | |
|] | |
runMongo :: MongoDBReader t (GGHandler M M IO) a -> GHandler M M a | |
runMongo x = liftIOHandler $ runMongoDBConn x getConnection | |
getConnection :: (ConnPool t, HostName) | |
getConnection = undefined | |
someAction :: Monad m => MongoDBReader t m (Key Person) | |
someAction = insert $ Person "Bob" 20 | |
-- selectList [PersonIdIn [1,2]] [] 0 0 | |
data M = M | |
instance Yesod M where approot _ = "" | |
mkYesod "M" [parseRoutes|/ RootR GET|] | |
getRootR :: GHandler M M RepHtml | |
getRootR = do | |
_ <- runMongo someAction | |
defaultLayout [hamlet|<h1>HELLO WORLD|] | |
main :: IO () | |
main = warpDebug 3000 M |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment