@@ -283,15 +283,18 @@ data DictionaryValue
283 -- A dictionary which depends on other dictionaries
283 -- A dictionary which depends on other dictionaries
285 | DependentDictionaryValue (Qualified Ident) [DictionaryValue]
285 | DependentDictionaryValue (Qualified Ident) [DictionaryValue]
286− deriving (Show, Eq)
286+ deriving (Show, Ord, Eq)
289-- Check that the current set of type class dictionaries entail the specified type class goal, and, if so,
289-- Check that the current set of type class dictionaries entail the specified type class goal, and, if so,
290-- return a type class dictionary reference.
290-- return a type class dictionary reference.
292entails :: Environment -> ModuleName -> [TypeClassDictionaryInScope] -> (Qualified ProperName, [Type]) -> Check Value
292entails :: Environment -> ModuleName -> [TypeClassDictionaryInScope] -> (Qualified ProperName, [Type]) -> Check Value
293−entails env moduleName context = solve (nubBy ((==) `on` canonicalizeDictionary) (filter filterModule context))
293+entails env moduleName context = solve (sortedNubBy canonicalizeDictionary (filter filterModule context))
295+ sortedNubBy :: (Ord k) => (v -> k) -> [v] -> [v]
296+ sortedNubBy f vs = M.elems (M.fromList (map (f &&& id) vs))
295 -- Filter out type dictionaries which are in scope in the current module
298 -- Filter out type dictionaries which are in scope in the current module
296 filterModule :: TypeClassDictionaryInScope -> Bool
299 filterModule :: TypeClassDictionaryInScope -> Bool
297 filterModule (TypeClassDictionaryInScope { tcdName = Qualified (Just mn) _ }) | mn == moduleName = True
300 filterModule (TypeClassDictionaryInScope { tcdName = Qualified (Just mn) _ }) | mn == moduleName = True