我正在使用持久性和持久性的mysql。我有一个Monad SqlM
type SqlM a = SqlPersist (ResourceT IO) a)
在我的职能范围内
testFun :: T.Text -> SqlM ()
testFun someId = ...
我可以使用
查询数据库entity <- selectFirst [SomeField ==. someId]
但我想按ID选择实体。我必须将someId转换/打包到Key - Type。我知道这不是这样做的方法,但我试过了:
entity <- get $ Key { unKey = PersistInt64 (read $ T.unpack someId) }
这失败了:
Couldn't match type `PersistEntityBackend
(Entity (DBTableGeneric backend0))'
with `Database.Persist.GenericSql.Raw.SqlBackend'
The type variable `backend0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Expected type: Key (Entity (DBTableGeneric backend0))
Actual type: KeyBackend
Database.Persist.GenericSql.Raw.SqlBackend
(Entity (DBTableGeneric backend0))
In the second argument of `($)', namely
`Key {unKey = PersistInt64 (read $ T.unpack someId)}'
任何想法出了什么问题?