@@ -348,7 +348,7 @@ entails env moduleName context = solve (sortedNubBy canonicalizeDictionary (filt
348 -- Make sure the types unify with the types in the superclass implication
348 -- Make sure the types unify with the types in the superclass implication
349 , subst <- maybeToList . (>>= verifySubstitution) . fmap concat $ zipWithM (typeHeadsAreEqual moduleName env) tys' suTyArgs
349 , subst <- maybeToList . (>>= verifySubstitution) . fmap concat $ zipWithM (typeHeadsAreEqual moduleName env) tys' suTyArgs
350 -- Finally, satisfy the subclass constraint
350 -- Finally, satisfy the subclass constraint
351− , args' <- maybeToList $ mapM (applySubst subst . TypeVar) args
351+ , args' <- maybeToList $ mapM (flip lookup subst) args
352 , suDict <- go True subclassName args' ]
352 , suDict <- go True subclassName args' ]
354 -- Create dictionaries for subgoals which still need to be solved by calling go recursively
354 -- Create dictionaries for subgoals which still need to be solved by calling go recursively
@@ -379,12 +379,6 @@ entails env moduleName context = solve (sortedNubBy canonicalizeDictionary (filt
379 let grps = groupBy ((==) `on` fst) subst
379 let grps = groupBy ((==) `on` fst) subst
380 guard (all (pairwise (unifiesWith env) . map snd) grps)
380 guard (all (pairwise (unifiesWith env) . map snd) grps)
381 return $ map head grps
381 return $ map head grps
382− -- Apply a substitution to a type
383− applySubst :: [(String, Type)] -> Type -> Maybe Type
384− applySubst subst = everywhereOnTypesM replace
386− replace (TypeVar v) = lookup v subst
387− replace other = Just other
388 -- Choose the simplest DictionaryValues from a list of candidates
382 -- Choose the simplest DictionaryValues from a list of candidates
389 -- The reason for this function is as follows:
383 -- The reason for this function is as follows:
390 -- When considering overlapping instances, we don't want to consider the same dictionary
384 -- When considering overlapping instances, we don't want to consider the same dictionary