on master help sign in
eliminate extraneous constraints to eliminate GHC 8 warning
commit8d3847c7fc40e5092b1439f1cd9a0a881f3e17c4 authorAgentM <agentm@themactionfaction.com> dateFri 9 Dec 2016, 00:18 (10 years ago) parent2407dc8
1 file changed+14−20
src/persistent/Database/Persist/ProjectM36.hs+14−20
src/persistent/Database/Persist/ProjectM36.hs+14−20
@@ -36,7 +36,7 @@ import Web.HttpApiData (ToHttpApiData(..), FromHttpApiData(..), parseUrlPieceWit
3636type ProjectM36Backend = (C.SessionId, C.Connection)
3737
3838--convert a PersistEntity to a RelationTuple
39−recordAsTuple :: forall record. (PersistEntity record, PersistEntityBackend record ~ ProjectM36Backend)
39+recordAsTuple :: forall record. (PersistEntity record)
4040 => Maybe U.UUID -> record -> Either RelationalError RelationTuple
4141recordAsTuple uuid record = do -- if the uuid is passed in, set the idDBName attribute
4242 let entInfo = zip entFields entValues
@@ -46,7 +46,7 @@ recordAsTuple uuid record = do -- if the uuid is passed in, set the idDBName att
4646 atomVec <- recordAsAtoms uuid attrVec record
4747 return $ RelationTuple attrVec atomVec
4848
49−recordAttributes :: forall record. (PersistEntity record, PersistEntityBackend record ~ ProjectM36Backend)
49+recordAttributes :: forall record. (PersistEntity record)
5050 => [(EmbedFieldDef, PersistValue)] -> record -> Either RelationalError Attributes
5151recordAttributes entInfo record = do
5252 let convertAttr = uncurry fieldDefAsAttribute
@@ -86,7 +86,7 @@ atomAsPersistValue (ByteStringAtom i) = PersistByteString i
8686atomAsPersistValue (BoolAtom i) = PersistBool i
8787atomAsPersistValue _ = error "Persist: missing conversion"
8888
89−recordAsAtoms :: forall record. (PersistEntity record, PersistEntityBackend record ~ ProjectM36Backend)
89+recordAsAtoms :: forall record. (PersistEntity record)
9090 => Maybe U.UUID -> Attributes -> record -> Either RelationalError (V.Vector Atom)
9191recordAsAtoms freshUUID _ record = do
9292 let pValues = map toPersistValue $ toPersistFields record
@@ -99,7 +99,7 @@ recordAsAtoms freshUUID _ record = do
9999 Just uuid -> [TextAtom $ T.pack (U.toString uuid)] ++ atoms
100100
101101--used by insert operations
102−recordsAsRelation :: forall record. (PersistEntity record, PersistEntityBackend record ~ ProjectM36Backend) =>
102+recordsAsRelation :: forall record. (PersistEntity record) =>
103103 [(Maybe U.UUID, record)] -> Either RelationalError Relation
104104recordsAsRelation [] = Left EmptyTuplesError
105105recordsAsRelation recordZips = do
@@ -108,16 +108,13 @@ recordsAsRelation recordZips = do
108108 mkRelation (tupleAttributes oneTuple) (RelationTupleSet tupleList)
109109
110110keyFromValuesOrDie :: (Trans.MonadIO m,
111− PersistEntity record,
112− PersistEntityBackend record ~ ProjectM36Backend
113− ) => [PersistValue] -> m (Key record)
111+ PersistEntity record) => [PersistValue] -> m (Key record)
114112keyFromValuesOrDie val = case keyFromValues val of
115113 Right k -> return k
116114 Left _ -> Trans.liftIO $ throwIO $ PersistError "key pooped"
117115
118116insertNewRecords :: (Trans.MonadIO m,
119− PersistEntity record,
120− PersistEntityBackend record ~ ProjectM36Backend) =>
117+ PersistEntity record) =>
121118 [U.UUID] -> [record] -> ReaderT ProjectM36Backend m [Key record]
122119insertNewRecords uuids records = do
123120 let recordsZip = zip (map Just uuids) records
@@ -134,8 +131,7 @@ throwIOPersistError msg = Trans.liftIO $ throwIO $ PersistError (T.pack msg)
134131
135132lookupByKey :: forall record m.
136133 (Trans.MonadIO m,
137− PersistEntity record,
138− PersistEntityBackend record ~ ProjectM36Backend)
134+ PersistEntity record)
139135 => Key record -> ReaderT ProjectM36Backend m (Maybe (Entity record))
140136lookupByKey key = do
141137 (relVarName, restrictionPredicate) <- commonKeyQueryProperties key
@@ -152,8 +148,7 @@ lookupByKey key = do
152148 return $ Just entity
153149
154150fromPersistValuesThrow :: (Trans.MonadIO m,
155− PersistEntity record,
156− PersistEntityBackend record ~ ProjectM36Backend) => EntityDef -> RelationTuple -> m (Entity record)
151+ PersistEntity record) => EntityDef -> RelationTuple -> m (Entity record)
157152fromPersistValuesThrow entDef tuple = do
158153 let body = fromPersistValues $ map getValue (entityFields entDef)
159154 getValue field = case atomForAttributeName (unDBName (fieldDB field)) tuple of
@@ -168,7 +163,7 @@ fromPersistValuesThrow entDef tuple = do
168163 Left err -> throwIOPersistError (show err)
169164 Right body' -> return $ Entity key body'
170165
171−commonKeyQueryProperties :: (Trans.MonadIO m, PersistEntityBackend val ~ ProjectM36Backend, PersistEntity val) => Key val -> ReaderT ProjectM36Backend m (RelVarName, RestrictionPredicateExpr)
166+commonKeyQueryProperties :: (Trans.MonadIO m, PersistEntity val) => Key val -> ReaderT ProjectM36Backend m (RelVarName, RestrictionPredicateExpr)
172167commonKeyQueryProperties key = do
173168 let matchUUID = keyToUUID key
174169 keyAttributeName = unDBName (fieldDB $ entityId entityInfo)
@@ -178,7 +173,7 @@ commonKeyQueryProperties key = do
178173 restrictionPredicate = AttributeEqualityPredicate keyAttributeName (NakedAtomExpr (TextAtom matchUUIDText))
179174 return (relVarName, restrictionPredicate)
180175
181−deleteByKey :: (Trans.MonadIO m, PersistEntityBackend val ~ ProjectM36Backend, PersistEntity val) => Key val -> ReaderT ProjectM36Backend m (Bool)
176+deleteByKey :: (Trans.MonadIO m, PersistEntity val) => Key val -> ReaderT ProjectM36Backend m (Bool)
182177deleteByKey key = do
183178 (relVarName, restrictionPredicate) <- commonKeyQueryProperties key
184179 let query = Delete relVarName restrictionPredicate
@@ -188,7 +183,6 @@ deleteByKey key = do
188183
189184--convert persistent update list to ProjectM36 Update map
190185updatesToUpdateMap :: (Trans.MonadIO m,
191− PersistEntityBackend val ~ ProjectM36Backend,
192186 PersistEntity val) =>
193187 [DP.Update val] -> ReaderT ProjectM36Backend m (M.Map AttributeName AtomExpr)
194188updatesToUpdateMap updates = do
@@ -202,7 +196,7 @@ updatesToUpdateMap updates = do
202196 updateAtomList <- mapM convertMap updates
203197 return $ M.fromList updateAtomList
204198
205−updateByKey :: (Trans.MonadIO m, PersistEntityBackend val ~ ProjectM36Backend, PersistEntity val) => Key val -> [DP.Update val] -> ReaderT ProjectM36Backend m ()
199+updateByKey :: (Trans.MonadIO m, PersistEntity val) => Key val -> [DP.Update val] -> ReaderT ProjectM36Backend m ()
206200updateByKey key updates = do
207201 (relVarName, restrictionPredicate) <- commonKeyQueryProperties key
208202 updateMap <- updatesToUpdateMap updates
@@ -316,7 +310,7 @@ executeDatabaseContextExpr sessionId conn expr = do
316310 Nothing -> return ()
317311 Just err -> throwIO (PersistError $ T.pack (show err))
318312
319−relVarNameFromRecord :: (PersistEntity record, PersistEntityBackend record ~ ProjectM36Backend)
313+relVarNameFromRecord :: (PersistEntity record)
320314 => record -> RelVarName
321315relVarNameFromRecord = unDBName . entityDB . entityDef . Just
322316
@@ -361,12 +355,12 @@ instance PersistConfig C.ConnectionInfo where
361355 --runPool :: (MonadBaseControl IO m, MonadIO m) => c -> PersistConfigBackend c m a -> PersistConfigPool c -> m a
362356 runPool _ r = runReaderT r
363357
364−withProjectM36Conn :: (Monad m, Trans.MonadIO m) => C.ConnectionInfo -> (ProjectM36Backend -> m a) -> m a
358+withProjectM36Conn :: (Trans.MonadIO m) => C.ConnectionInfo -> (ProjectM36Backend -> m a) -> m a
365359withProjectM36Conn conf connReader = do
366360 backend <- Trans.liftIO $ createPoolConfig conf
367361 connReader backend
368362
369−runProjectM36Conn :: (Trans.MonadIO m) => ReaderT ProjectM36Backend m a -> (C.SessionId, C.Connection) -> m a
363+runProjectM36Conn :: ReaderT ProjectM36Backend m a -> (C.SessionId, C.Connection) -> m a
370364runProjectM36Conn m1 (sessionId, conn) = runReaderT m1 (sessionId, conn)
371365
372366instance PathPiece (BackendKey ProjectM36Backend) where