@@ -78,8 +78,8 @@ entails env moduleName context = solve
78 unique :: [(a, TypeClassDictionaryInScope)] -> Check (a, TypeClassDictionaryInScope)
78 unique :: [(a, TypeClassDictionaryInScope)] -> Check (a, TypeClassDictionaryInScope)
79 unique [] = throwError . errorMessage $ NoInstanceFound className' tys'
79 unique [] = throwError . errorMessage $ NoInstanceFound className' tys'
80 unique [a] = return a
80 unique [a] = return a
81− unique xs@(x : _) | pairwise overlapping (map snd xs) = throwError . errorMessage $ OverlappingInstances className' tys' (map (tcdName . snd) xs) -- TODO: use simplest instance
81+ unique tcds | pairwise overlapping (map snd tcds) = throwError . errorMessage $ OverlappingInstances className' tys' (map (tcdName . snd) tcds)
82− | otherwise = return x
82+ | otherwise = return (minimumBy (compare `on` length . tcdPath . snd) tcds)
85 -- Check if two dictionaries are overlapping
85 -- Check if two dictionaries are overlapping