私はひどくばかげたことをしているかもしれませんが、同じ関数でいくつかの Esqueleto を通常の Persistent クエリと組み合わせたいと考えています。
私は機能を持っています:
handleFactionConstruction :: (BaseBackend backend ~ SqlBackend,
PersistStoreWrite backend, PersistQueryRead backend,
PersistUniqueRead backend, MonadIO m) =>
Time -> Entity Faction -> ReaderT backend m ()
handleFactionConstruction date faction = do
planets <- selectList [ PlanetOwnerId ==. Just (entityKey faction)] []
queues <- mapM loadPlanetConstructionQueue $ map entityKey planets
return ()
loadPlanetConstructionQueue には署名があります (これは結合を実行するため、ここでは Esqueleto を使用したいと思います):
loadPlanetConstructionQueue :: (MonadIO m, BackendCompatible SqlBackend backend,
PersistQueryRead backend, PersistUniqueRead backend) =>
Key Planet -> ReaderT backend m (Maybe (Entity Planet), [Entity BuildingConstruction
これは機能せず、次のエラーが発生します。
Could not deduce (BackendCompatible SqlBackend backend)
arising from a use of ‘loadPlanetConstructionQueue’
from the context: (BaseBackend backend ~ SqlBackend,
PersistStoreWrite backend, PersistQueryRead backend,
PersistUniqueRead backend, MonadIO m)
bound by the type signature for:
handleFactionConstruction :: forall backend (m :: * -> *).
(BaseBackend backend ~ SqlBackend,
PersistStoreWrite backend,
PersistQueryRead backend,
PersistUniqueRead backend, MonadIO m) =>
Time -> Entity Faction -> ReaderT backend m ()
「BackendCompatible SqlBackend backend」と「BaseBackend backend ~ SqlBackend」の違いが関係していると思います。
これを機能させる方法はありますか?この場合、selectList の部分を Esqueleto で記述できますが、さらに下の行では、Esqueleto でサポートされていない置換を使用する必要があります (と思います)。
私は Haskell、Persistent、Esqueleto についてあまり知らないので、ここで少し迷っています。