on master help sign in
Compatibility with old ghc
commit19f1e3a372c398b6a5e0071280c7319b997c01cc authorEdwin Brady <eb@cs.st-andrews.ac.uk> dateMon 9 Jan 2012, 22:10 (15 years ago) parentc82f2f4
1 file changed+17−5
src/Idris/AbsSyntax.hs+17−5
src/Idris/AbsSyntax.hs+17−5
@@ -1154,6 +1154,18 @@ dumpDecl (PInstance _ _ cs n _ t ds)
11541154dumpDecl _ = "..."
11551155-- dumpDecl (PImport i) = "import " ++ i
11561156
1157+-- for 6.12/7 compatibility
1158+data EitherErr a b = LeftErr a | RightOK b
1159+
1160+instance Monad (EitherErr a) where
1161+ return = RightOK
1162+
1163+ (LeftErr e) >>= k = LeftErr e
1164+ RightOK v >>= k = k v
1165+
1166+toEither (LeftErr e) = Left e
1167+toEither (RightOK ho) = Right ho
1168+
11571169-- syntactic match of a against b, returning pair of variables in a
11581170-- and what they match. Returns the pair that failed if not a match.
11591171
@@ -1188,9 +1200,9 @@ matchClause x y = checkRpts $ match (fullApp x) (fullApp y) where
11881200 return (concat ms)
11891201 match a@(PAlternative as) b
11901202 = do let ms = zipWith match' as (repeat b)
1191− case (rights ms) of
1203+ case (rights (map toEither ms)) of
11921204 (x: _) -> return x
1193− _ -> Left (a, b)
1205+ _ -> LeftErr (a, b)
11941206 match (PCase _ _ _) _ = return [] -- lifted out
11951207 match (PMetavar _) _ = return [] -- modified
11961208 match (PQuote _) _ = return []
@@ -1215,15 +1227,15 @@ matchClause x y = checkRpts $ match (fullApp x) (fullApp y) where
12151227 match Placeholder _ = return []
12161228 match (PResolveTC _) _ = return []
12171229 match a b | a == b = return []
1218− | otherwise = Left (a, b)
1230+ | otherwise = LeftErr (a, b)
12191231
1220− checkRpts (Right ms) = check ms where
1232+ checkRpts (RightOK ms) = check ms where
12211233 check ((n,t):xs)
12221234 | Just t' <- lookup n xs = if t/=t' then Left (t, t')
12231235 else check xs
12241236 check (_:xs) = check xs
12251237 check [] = Right ms
1226− checkRpts x = x
1238+ checkRpts (LeftErr x) = Left x
12271239
12281240substMatches :: [(Name, PTerm)] -> PTerm -> PTerm
12291241substMatches [] t = t