Created
July 1, 2011 16:19
-
-
Save alios/1058863 to your computer and use it in GitHub Desktop.
problems with using persistant in a yesod sub site
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 MultiParamTypeClasses, TypeFamilies, GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE QuasiQuotes, TemplateHaskell, OverloadedStrings #-} | |
{-# LANGUAGE DeriveDataTypeable, NoMonomorphismRestriction, FlexibleInstances #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
import Data.Text (Text) | |
import Language.Haskell.TH.Syntax hiding (lift) | |
import Yesod | |
share2 mkPersist (mkMigrate "migrateTest") [persist| | |
Test | |
foo Text | |
|] | |
data TestSite = TestSite | |
mkYesodSub "TestSite" [ ClassP ''YesodPersist [VarT $ mkName "master"] ] | |
[parseRoutes| | |
/insert InsertR POST | |
|] | |
postInsertR :: (YesodPersist master) => GHandler sub master () | |
postInsertR = do | |
runDB $ insert $ Test "bar" | |
return () | |
{- | |
test.hs:26:11: | |
Could not deduce (PersistBackend | |
(YesodDB master (GGHandler sub master IO))) | |
arising from a use of `insert' | |
from the context (YesodPersist master) | |
bound by the type signature for | |
postInsertR :: YesodPersist master => GHandler sub master () | |
at /home/alios/src/test.hs:(25,1)-(31,2) | |
Possible fix: | |
add (PersistBackend | |
(YesodDB master (GGHandler sub master IO))) to the context of | |
the type signature for | |
postInsertR :: YesodPersist master => GHandler sub master () | |
or add an instance declaration for | |
(PersistBackend (YesodDB master (GGHandler sub master IO))) | |
In the expression: insert | |
In the second argument of `($)', namely `insert $ Test "bar"' | |
In a stmt of a 'do' expression: runDB $ insert $ Test "bar" | |
Failed, modules loaded: none. | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Michael Snoyman's suggestion on the haskell-webdevel mailinglist