@@ -220,15 +220,18 @@ hoistWithKey f (TypeRepMap as bs ans ks) = TypeRepMap as bs newAns ks
220{-# INLINE hoistWithKey #-}
220{-# INLINE hoistWithKey #-}
222-- | The union of two 'TypeRepMap's using a combining function.
222-- | The union of two 'TypeRepMap's using a combining function.
223−unionWith :: (forall x. f x -> f x -> f x) -> TypeRepMap f -> TypeRepMap f -> TypeRepMap f
223+unionWith :: forall f. (forall x. Typeable x => f x -> f x -> f x) -> TypeRepMap f -> TypeRepMap f -> TypeRepMap f
224unionWith f m1 m2 = fromTriples
224unionWith f m1 m2 = fromTriples
225 $ toTripleList
225 $ toTripleList
226 $ Map.unionWith combine
226 $ Map.unionWith combine
227 (fromTripleList $ toTriples m1)
227 (fromTripleList $ toTriples m1)
228 (fromTripleList $ toTriples m2)
228 (fromTripleList $ toTriples m2)
230+ f' :: forall x. TypeRep x -> f x -> f x -> f x
231+ f' tr = withTypeable tr f
230 combine :: (Any, Any) -> (Any, Any) -> (Any, Any)
233 combine :: (Any, Any) -> (Any, Any) -> (Any, Any)
231− combine (av, ak) (bv, _) = (toAny $ f (fromAny av) (fromAny bv), ak)
234+ combine (av, ak) (bv, _) = (toAny $ f' (fromAny ak) (fromAny av) (fromAny bv), ak)
233 fromTripleList :: Ord a => [(a, b, c)] -> Map.Map a (b, c)
236 fromTripleList :: Ord a => [(a, b, c)] -> Map.Map a (b, c)
234 fromTripleList = Map.fromList . map (\(a, b, c) -> (a, (b, c)))
237 fromTripleList = Map.fromList . map (\(a, b, c) -> (a, (b, c)))