@@ -76,6 +76,7 @@ addToCalledG n ns = return () -- TODO
7676
7777-- Add a class instance function. Dodgy hack: Put integer instances first in the
7878-- list so they are resolved by default.
79+-- Dodgy hack 2: put constraint chasers (@@) last
7980
8081addInstance :: Bool -> Name -> Name -> Idris ()
8182addInstance int n i
@@ -87,7 +88,15 @@ addInstance int n i
8788 _ -> do let cs = addDef n (CI (MN 0 "none") [] [] [] [i]) (idris_classes ist)
8889 put (ist { idris_classes = cs })
8990 where addI i ins | int = i : ins
90− | otherwise = ins ++ [i]
91+ | chaser n = ins ++ [i]
92+ | otherwise = insI i ins
93+ insI i [] = [i]
94+ insI i (n : ns) | chaser n = i : n : ns
95+ | otherwise = n : insI i ns
96+
97+ chaser (UN ('@':'@':_)) = True
98+ chaser (NS n _) = chaser n
99+ chaser _ = False
91100
92101addClass :: Name -> ClassInfo -> Idris ()
93102addClass n i