Open ghost opened 6 years ago
It looks like this line has a type signature that doesn't belong:
runMigration migrateAll :: IO () Do you want to try PRing a fix?
On Wed, Jul 18, 2018 at 11:23 PM RoelofWobben notifications@github.com wrote:
Hello,
When I run the first code from the persistent page I see this error appear,
- Couldn't match type
BaseBackend backend0' with
SqlBackend' arising from a use ofrunSqlite' The type variable
backend0' is ambiguous
- In the expression: runSqlite ":memory:" In the expression: runSqlite ":memory:" $ do michaelId <- insert $ Person "Michael" $ Just 26 michael <- get michaelId liftIO $ print michael In an equation for `main': main = runSqlite ":memory:" $ do michaelId <- insert $ Person "Michael" $ Just 26 michael <- get michaelId liftIO $ print michael | 24 | main = runSqlite ":memory:" $ do
I can make a PR how to solve this but I need to know where this page can be found.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/yesodweb/yesodweb.com-content/issues/213, or mute the thread https://github.com/notifications/unsubscribe-auth/AADBBzzYNzHJEcpDo5uUWxb4nL-jGtQfks5uH5kjgaJpZM4VVTcI .
Moment, this is the code just before the migration is added. Im talking about this one :
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
import Control.Monad.IO.Class (liftIO)
import Database.Persist
import Database.Persist.Sqlite
import Database.Persist.TH
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
Person
name String
age Int Maybe
deriving Show
|]
main :: IO ()
main = runSqlite ":memory:" $ do
michaelId <- insert $ Person "Michael" $ Just 26
michael <- get michaelId
liftIO $ print michael
and I solved it with a little help of the slack channel this way :
runSqlite' :: (MonadUnliftIO m) => Text -> ReaderT SqlBackend (NoLoggingT (ResourceT m)) a -> m a
runSqlite' = runSqlite
main :: IO ()
main = runSqlite' ":memory:" $ do
michaelId <- insert $ Person "Michael" $ Just 26
michael <- get michaelId
liftIO $ print michael
and yes, I can try to make a PR but as I said earlier have to know which file this exactly is.
The source is available here:
https://github.com/yesodweb/yesodweb.com-content/blob/master/book/asciidoc/persistent.asciidoc
For future reference, each chapter in the book has a (relatively small) link at the top that says "View source on Github".
Hello,
When I run the first code from the persistent page I see this error appear,
I can make a PR how to solve this but I need to know where this page can be found.