0
我有以下幾點:無法與匹配類型「PersistEntityBackend(實體)「SqlBackend」
asSqlBackendReader :: ReaderT SqlBackend m a -> ReaderT SqlBackend m a
asSqlBackendReader = id
insertEnt :: (Entity a) -> IO (Key (Entity a))
insertEnt x = runWithDb $ do
insert $ x
where runWithDb = runSqlite "test.db" . asSqlBackendReader
的asSqlBAckendReader
的目的是由於Persistent selectList causing error of "Couldn't match type ‘BaseBackend backend0’ with ‘SqlBackend’"。
我遇到的一個錯誤:
• Couldn't match type ‘PersistEntityBackend (Entity a)’
with ‘SqlBackend’
arising from a use of ‘insert’
• In a stmt of a 'do' block: insert $ x
In the second argument of ‘($)’, namely ‘do { insert $ x }’
In the expression: runWithDb $ do { insert $ x }
哦,對,缺少的約束也應該是簽名的一部分。我會更新一個解釋。 –