1
雖然玩弄persistent
,我不知道PersistStoreWrite (BaseBackend b)
約束來自哪裏。我在insert
的簽名上看不到它。PersistStoreWrite(BaseBackend x)約束來自何時使用通用持久?
x :: (
MonadIO m,
PersistStoreRead b,
PersistStoreWrite b,
PersistStoreWrite (BaseBackend b) -- <--- where does this come from?
) => ReaderT b m()
x = do
now <- liftIO getCurrentTime
aTaskId <- insert (TaskItem "Hello" now)
aTask <- get aTaskId
liftIO (print aTask)
以上工作正常,但如果我刪除所提到的約束,編譯器會抱怨(「從使用的insert
引起」)。 我用lts-7.12解析器(GHC 8,持久性2.6)使用堆棧。備案
數據定義:
share [mkPersist sqlSettings{mpsGeneric = True}, mkMigrate "migrateAll"] [persistLowerCase|
TaskItem
name Text
submittedAt UTCTime
deriving Show