@@ -306,10 +306,12 @@ entails env moduleName context = solve (sortedNubBy canonicalizeDictionary (filt
306306 filterModule _ = False
307307
308308 solve context' (className, tys) trySuperclasses =
309− case chooseSimplestDictionaries (go trySuperclasses className tys) of
310− [] -> throwError . strMsg $ "No instance found for " ++ show className ++ " " ++ unwords (map prettyPrintTypeAtom tys)
311− [dict] -> return (dictionaryValueToValue dict)
312− _ -> throwError . strMsg $ "Overlapping instances found for " ++ show className ++ " " ++ unwords (map prettyPrintTypeAtom tys)
309+ let
310+ dicts = go trySuperclasses className tys
311+ in case sortedNubBy dictTrace (chooseSimplestDictionaries dicts) of
312+ [] -> throwError . strMsg $ "No instance found for " ++ show className ++ " " ++ unwords (map prettyPrintTypeAtom tys)
313+ [_] -> return $ dictionaryValueToValue $ head dicts
314+ _ -> throwError . strMsg $ "Overlapping instances found for " ++ show className ++ " " ++ unwords (map prettyPrintTypeAtom tys)
313315 where
314316 go trySuperclasses' className' tys' =
315317 -- Look for regular type instances
@@ -385,6 +387,14 @@ entails env moduleName context = solve (sortedNubBy canonicalizeDictionary (filt
385387 isSimpleDictionaryValue SubclassDictionaryValue{} = False
386388 isSimpleDictionaryValue (DependentDictionaryValue _ ds) = all isSimpleDictionaryValue ds
387389 isSimpleDictionaryValue _ = True
390+ -- |
391+ -- Get the "trace" of a DictionaryValue - that is, remove all SubclassDictionaryValue
392+ -- data constructors
393+ --
394+ dictTrace :: DictionaryValue -> DictionaryValue
395+ dictTrace (DependentDictionaryValue fnName dicts) = DependentDictionaryValue fnName $ map dictTrace dicts
396+ dictTrace (SubclassDictionaryValue dict _ _) = dict
397+ dictTrace other = other
388398
389399-- |
390400-- Check all values in a list pairwise match a predicate