@@ -76,6 +76,7 @@ addToCalledG n ns = return () -- TODO
77-- Add a class instance function. Dodgy hack: Put integer instances first in the
77-- Add a class instance function. Dodgy hack: Put integer instances first in the
78-- list so they are resolved by default.
78-- list so they are resolved by default.
79+-- Dodgy hack 2: put constraint chasers (@@) last
80addInstance :: Bool -> Name -> Name -> Idris ()
81addInstance :: Bool -> Name -> Name -> Idris ()
81addInstance int n i
82addInstance int n i
@@ -87,7 +88,15 @@ addInstance int n i
87 _ -> do let cs = addDef n (CI (MN 0 "none") [] [] [] [i]) (idris_classes ist)
88 _ -> do let cs = addDef n (CI (MN 0 "none") [] [] [] [i]) (idris_classes ist)
88 put (ist { idris_classes = cs })
89 put (ist { idris_classes = cs })
89 where addI i ins | int = i : ins
90 where addI i ins | int = i : ins
90− | otherwise = ins ++ [i]
91+ | chaser n = ins ++ [i]
92+ | otherwise = insI i ins
94+ insI i (n : ns) | chaser n = i : n : ns
95+ | otherwise = n : insI i ns
97+ chaser (UN ('@':'@':_)) = True
98+ chaser (NS n _) = chaser n
92addClass :: Name -> ClassInfo -> Idris ()
101addClass :: Name -> ClassInfo -> Idris ()
93addClass n i
102addClass n i