summaryrefslogtreecommitdiff
path: root/src/full/Agda/Syntax/Internal/Pattern.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/full/Agda/Syntax/Internal/Pattern.hs')
-rw-r--r--src/full/Agda/Syntax/Internal/Pattern.hs30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/full/Agda/Syntax/Internal/Pattern.hs b/src/full/Agda/Syntax/Internal/Pattern.hs
index 7f9ca74..78da0c4 100644
--- a/src/full/Agda/Syntax/Internal/Pattern.hs
+++ b/src/full/Agda/Syntax/Internal/Pattern.hs
@@ -1,12 +1,14 @@
-{-# LANGUAGE CPP #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
-{-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverlappingInstances #-}
-{-# LANGUAGE TupleSections #-}
-{-# LANGUAGE TypeSynonymInstances #-}
-{-# LANGUAGE UndecidableInstances #-} -- because of func. deps.
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TupleSections #-}
+{-# LANGUAGE UndecidableInstances #-} -- because of func. deps.
+
+#if __GLASGOW_HASKELL__ <= 708
+{-# LANGUAGE OverlappingInstances #-}
+#endif
module Agda.Syntax.Internal.Pattern where
@@ -49,7 +51,12 @@ class FunArity a where
funArity :: a -> Int
-- | Get the number of initial 'Apply' patterns.
+
+#if __GLASGOW_HASKELL__ >= 710
+instance {-# OVERLAPPABLE #-} IsProjP p => FunArity [p] where
+#else
instance IsProjP p => FunArity [p] where
+#endif
funArity = length . takeWhile (isNothing . isProjP)
-- | Get the number of initial 'Apply' patterns in a clause.
@@ -57,7 +64,11 @@ instance FunArity Clause where
funArity = funArity . clausePats
-- | Get the number of common initial 'Apply' patterns in a list of clauses.
+#if __GLASGOW_HASKELL__ >= 710
+instance {-# OVERLAPPING #-} FunArity [Clause] where
+#else
instance FunArity [Clause] where
+#endif
funArity [] = 0
funArity cls = minimum $ map funArity cls
@@ -90,7 +101,8 @@ instance LabelPatVars (Pattern' x) (Pattern' (i,x)) i where
where next = do (x:xs) <- get; put xs; return x
-- | Augment pattern variables with their de Bruijn index.
-{-# SPECIALIZE numberPatVars :: Permutation -> [NamedArg (Pattern' x)] -> [(NamedArg (Pattern' (Int, x)))] #-}
+{-# SPECIALIZE numberPatVars :: Permutation -> [NamedArg (Pattern' x)] -> [NamedArg (Pattern' (Int, x))] #-}
+{-# SPECIALIZE numberPatVars :: Permutation -> [NamedArg Pattern] -> [NamedArg DeBruijnPattern] #-}
numberPatVars :: LabelPatVars a b Int => Permutation -> a -> b
numberPatVars perm ps = evalState (labelPatVars ps) $
permute (invertP __IMPOSSIBLE__ perm) $ downFrom $ size perm