@@ -348,7 +348,7 @@ entails env moduleName context = solve (sortedNubBy canonicalizeDictionary (filt
348348 -- Make sure the types unify with the types in the superclass implication
349349 , subst <- maybeToList . (>>= verifySubstitution) . fmap concat $ zipWithM (typeHeadsAreEqual moduleName env) tys' suTyArgs
350350 -- Finally, satisfy the subclass constraint
351− , args' <- maybeToList $ mapM (applySubst subst . TypeVar) args
351+ , args' <- maybeToList $ mapM (flip lookup subst) args
352352 , suDict <- go True subclassName args' ]
353353
354354 -- 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
379379 let grps = groupBy ((==) `on` fst) subst
380380 guard (all (pairwise (unifiesWith env) . map snd) grps)
381381 return $ map head grps
382− -- Apply a substitution to a type
383− applySubst :: [(String, Type)] -> Type -> Maybe Type
384− applySubst subst = everywhereOnTypesM replace
385− where
386− replace (TypeVar v) = lookup v subst
387− replace other = Just other
388382 -- Choose the simplest DictionaryValues from a list of candidates
389383 -- The reason for this function is as follows:
390384 -- When considering overlapping instances, we don't want to consider the same dictionary