Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gregwebs
Created June 30, 2011 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregwebs/1056520 to your computer and use it in GitHub Desktop.
Save gregwebs/1056520 to your computer and use it in GitHub Desktop.
{-# 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