@@ -283,15 +283,18 @@ data DictionaryValue
283283 -- A dictionary which depends on other dictionaries
284284 --
285285 | DependentDictionaryValue (Qualified Ident) [DictionaryValue]
286− deriving (Show, Eq)
286+ deriving (Show, Ord, Eq)
287287
288288-- |
289289-- Check that the current set of type class dictionaries entail the specified type class goal, and, if so,
290290-- return a type class dictionary reference.
291291--
292292entails :: 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))
294294 where
295+ sortedNubBy :: (Ord k) => (v -> k) -> [v] -> [v]
296+ sortedNubBy f vs = M.elems (M.fromList (map (f &&& id) vs))
297+
295298 -- Filter out type dictionaries which are in scope in the current module
296299 filterModule :: TypeClassDictionaryInScope -> Bool
297300 filterModule (TypeClassDictionaryInScope { tcdName = Qualified (Just mn) _ }) | mn == moduleName = True