@@ -75,10 +75,14 @@ entails env moduleName context = solve
75 go :: Int -> Qualified ProperName -> [Type] -> Check DictionaryValue
75 go :: Int -> Qualified ProperName -> [Type] -> Check DictionaryValue
76 go work className' tys' | work > 1000 = throwError . errorMessage $ PossiblyInfiniteInstance className' tys'
76 go work className' tys' | work > 1000 = throwError . errorMessage $ PossiblyInfiniteInstance className' tys'
77 go work className' tys' = do
77 go work className' tys' = do
78+ -- We need to desugar synonyms here so that forClassName can find the correct modules
79+ -- in types hidden inside the synonyms.
80+ -- TODO: this can go away when synonyms get desugared up front.
81+ tys'' <- mapM expandAllTypeSynonyms tys'
78 let instances = do
82 let instances = do
79− tcd <- forClassName className' tys'
83+ tcd <- forClassName className' tys''
80 -- Make sure the type unifies with the type in the type instance definition
84 -- Make sure the type unifies with the type in the type instance definition
81− subst <- maybeToList . (>>= verifySubstitution) . fmap concat $ zipWithM (typeHeadsAreEqual moduleName env) tys' (tcdInstanceTypes tcd)
85+ subst <- maybeToList . (>>= verifySubstitution) . fmap concat $ zipWithM (typeHeadsAreEqual moduleName env) tys'' (tcdInstanceTypes tcd)
82 return (subst, tcd)
86 return (subst, tcd)
83 (subst, tcd) <- unique instances
87 (subst, tcd) <- unique instances
84 -- Solve any necessary subgoals
88 -- Solve any necessary subgoals