-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A dependently typed functional programming language and proof assistant -- -- Agda is a dependently typed functional programming language: It has -- inductive families, which are similar to Haskell's GADTs, but they can -- be indexed by values and not just types. It also has parameterised -- modules, mixfix operators, Unicode characters, and an interactive -- Emacs interface (the type checker can assist in the development of -- your code). -- -- Agda is also a proof assistant: It is an interactive system for -- writing and checking proofs. Agda is based on intuitionistic type -- theory, a foundational system for constructive mathematics developed -- by the Swedish logician Per Martin-Löf. It has many similarities with -- other proof assistants based on dependent types, such as Coq, Epigram -- and NuPRL. -- -- This package includes both a command-line program (agda) and an Emacs -- mode. If you want to use the Emacs mode you can set it up by running -- agda-mode setup (see the README). -- -- Note that the Agda library does not follow the package versioning -- policy, because it is not intended to be used by third-party packages. @package Agda @version 2.5.1.2 module Agda.Version -- | The version of Agda. version :: String -- | Var field implementation of sets of (small) natural numbers. module Agda.Utils.VarSet type VarSet = IntSet -- | O(n+m). The union of two sets. union :: IntSet -> IntSet -> IntSet -- | The union of a list of sets. unions :: [IntSet] -> IntSet -- | O(min(n,W)). Is the value a member of the set? member :: Key -> IntSet -> Bool -- | O(1). The empty set. empty :: IntSet -- | O(min(n,W)). Delete a value in the set. Returns the original -- set when the value was not present. delete :: Key -> IntSet -> IntSet -- | O(1). A set of one element. singleton :: Key -> IntSet -- | O(n*min(n,W)). Create a set from a list of integers. fromList :: [Key] -> IntSet -- | O(n). Convert the set to a list of elements. Subject to list -- fusion. toList :: IntSet -> [Key] -- | O(n). Convert the set to a descending list of elements. Subject -- to list fusion. toDescList :: IntSet -> [Key] -- | O(n+m). Is this a subset? (s1 isSubsetOf s2) -- tells whether s1 is a subset of s2. isSubsetOf :: IntSet -> IntSet -> Bool -- | O(1). Is the set empty? null :: IntSet -> Bool -- | O(n+m). The intersection of two sets. intersection :: IntSet -> IntSet -> IntSet -- | O(n+m). Difference between two sets. difference :: IntSet -> IntSet -> IntSet subtract :: Int -> VarSet -> VarSet module Agda.Utils.Tuple -- | Bifunctoriality for pairs. (-*-) :: (a -> c) -> (b -> d) -> (a, b) -> (c, d) infix 2 -*- -- |
-- mapFst f = f -*- id --mapFst :: (a -> c) -> (a, b) -> (c, b) -- |
-- mapSnd g = id -*- g --mapSnd :: (b -> d) -> (a, b) -> (a, d) -- | Lifted pairing. (/\) :: (a -> b) -> (a -> c) -> a -> (b, c) infix 3 /\ -- | Swap. (Only in Data.Tuple from base-4.3) swap :: (a, b) -> (b, a) fst3 :: (a, b, c) -> a snd3 :: (a, b, c) -> b thd3 :: (a, b, c) -> c uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d uncurry4 :: (a -> b -> c -> d -> e) -> (a, b, c, d) -> e -- | Monadic version of -*-. mapPairM :: (Applicative m) => (a -> m c) -> (b -> m d) -> (a, b) -> m (c, d) -- | Monadic mapFst. mapFstM :: (Applicative m) => (a -> m c) -> (a, b) -> m (c, b) -- | Monadic mapSnd. mapSndM :: (Applicative m) => (b -> m d) -> (a, b) -> m (a, d) newtype List2 a List2 :: (a, a) -> List2 a [list2] :: List2 a -> (a, a) instance Data.Traversable.Traversable Agda.Utils.Tuple.List2 instance Data.Foldable.Foldable Agda.Utils.Tuple.List2 instance GHC.Base.Functor Agda.Utils.Tuple.List2 instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Utils.Tuple.List2 a) instance GHC.Base.Applicative Agda.Utils.Tuple.List2 module Agda.Utils.Update -- | The Change monad. data Change a -- | The class of change monads. class Monad m => MonadChange m tellDirty :: MonadChange m => m () listenDirty :: MonadChange m => m a -> m (a, Bool) -- | Run a Change computation, returning result plus change flag. runChange :: Change a -> (a, Bool) type Updater a = a -> Change a -- | Replace result of updating with original input if nothing has changed. sharing :: Updater a -> Updater a -- | Blindly run an updater. runUpdater :: Updater a -> a -> (a, Bool) -- | Mark a computation as dirty. dirty :: Updater a ifDirty :: MonadChange m => m a -> (a -> m b) -> (a -> m b) -> m b -- | Like Functor, but preserving sharing. class Traversable f => Updater1 f where updater1 = traverse updates1 f = sharing $ updater1 f update1 f = evalUpdater $ updater1 f updater1 :: Updater1 f => Updater a -> Updater (f a) updates1 :: Updater1 f => Updater a -> Updater (f a) update1 :: Updater1 f => Updater a -> EndoFun (f a) -- | Like Bifunctor, but preserving sharing. class Updater2 f where updates2 f1 f2 = sharing $ updater2 f1 f2 update2 f1 f2 = evalUpdater $ updater2 f1 f2 updater2 :: Updater2 f => Updater a -> Updater b -> Updater (f a b) updates2 :: Updater2 f => Updater a -> Updater b -> Updater (f a b) update2 :: Updater2 f => Updater a -> Updater b -> EndoFun (f a b) instance GHC.Base.Monad Agda.Utils.Update.Change instance GHC.Base.Applicative Agda.Utils.Update.Change instance GHC.Base.Functor Agda.Utils.Update.Change instance Control.Monad.Trans.Class.MonadTrans Agda.Utils.Update.ChangeT instance GHC.Base.Monad m => GHC.Base.Monad (Agda.Utils.Update.ChangeT m) instance GHC.Base.Applicative m => GHC.Base.Applicative (Agda.Utils.Update.ChangeT m) instance GHC.Base.Functor m => GHC.Base.Functor (Agda.Utils.Update.ChangeT m) instance GHC.Base.Monad m => Agda.Utils.Update.MonadChange (Agda.Utils.Update.ChangeT m) instance Agda.Utils.Update.MonadChange Data.Functor.Identity.Identity instance Agda.Utils.Update.MonadChange Agda.Utils.Update.Change instance Agda.Utils.Update.Updater1 GHC.Base.Maybe instance Agda.Utils.Update.Updater1 [] instance Agda.Utils.Update.Updater2 (,) instance Agda.Utils.Update.Updater2 Data.Either.Either -- | Some functions and generators suitable for writing QuickCheck -- properties. module Agda.Utils.TestHelpers -- | Is the operator associative? associative :: Eq a => (a -> a -> a) -> a -> a -> a -> Bool -- | Is the operator commutative? commutative :: Eq a => (a -> a -> a) -> a -> a -> Bool -- | Is the operator idempotent? idempotent :: Eq a => (a -> a -> a) -> a -> Bool -- | Is the element a zero for the operator? isZero :: Eq a => a -> (a -> a -> a) -> a -> Bool -- | Is the element a unit for the operator? identity :: Eq a => a -> (a -> a -> a) -> a -> Bool -- | Does the first operator distribute (from the left) over the second -- one? leftDistributive :: Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Bool -- | Does the first operator distribute (from the right) over the second -- one? rightDistributive :: Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Bool -- | Does the first operator distribute over the second one? distributive :: Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Bool -- | Generates natural numbers. natural :: (Integral i) => Gen i -- | Generates positive numbers. positive :: (Integral i) => Gen i -- | Generates values of Maybe type, using the given generator to -- generate the contents of the Just constructor. maybeGen :: Gen a -> Gen (Maybe a) -- | Coarbitrary "generator" for Maybe. maybeCoGen :: (a -> Gen b -> Gen b) -> (Maybe a -> Gen b -> Gen b) -- | Generates a list of elements picked from a given list. listOfElements :: [a] -> Gen [a] -- | If the given list is non-empty, then an element from the list is -- generated, and otherwise an arbitrary element is generated. elementsUnlessEmpty :: Arbitrary a => [a] -> Gen a -- | Generates two elements. two :: Gen a -> Gen (a, a) -- | Generates three elements. three :: Gen a -> Gen (a, a, a) -- | Runs the tests, and returns True if all tests were successful. runTests :: String -> [IO Bool] -> IO Bool -- | Constructing singleton collections. module Agda.Utils.Singleton class Singleton el coll | coll -> el singleton :: Singleton el coll => el -> coll instance Agda.Utils.Singleton.Singleton a (GHC.Base.Maybe a) instance Agda.Utils.Singleton.Singleton a [a] instance Agda.Utils.Singleton.Singleton a (Data.Sequence.Seq a) instance Agda.Utils.Singleton.Singleton a (Data.Set.Base.Set a) instance Agda.Utils.Singleton.Singleton GHC.Types.Int Data.IntSet.Base.IntSet instance Agda.Utils.Singleton.Singleton (k, a) (Data.Map.Base.Map k a) instance Agda.Utils.Singleton.Singleton (GHC.Types.Int, a) (Data.IntMap.Base.IntMap a) instance Data.Hashable.Class.Hashable a => Agda.Utils.Singleton.Singleton a (Data.HashSet.HashSet a) instance Data.Hashable.Class.Hashable k => Agda.Utils.Singleton.Singleton (k, a) (Data.HashMap.Base.HashMap k a) module Agda.Utils.SemiRing -- | Semirings (https://en.wikipedia.org/wiki/Semiring). class SemiRing a ozero :: SemiRing a => a oone :: SemiRing a => a oplus :: SemiRing a => a -> a -> a otimes :: SemiRing a => a -> a -> a -- | Star semirings -- (https://en.wikipedia.org/wiki/Semiring#Star_semirings). class SemiRing a => StarSemiRing a ostar :: StarSemiRing a => a -> a instance Agda.Utils.SemiRing.SemiRing a => Agda.Utils.SemiRing.SemiRing (GHC.Base.Maybe a) instance Agda.Utils.SemiRing.StarSemiRing a => Agda.Utils.SemiRing.StarSemiRing (GHC.Base.Maybe a) module Agda.Utils.QuickCheck isSuccess :: Result -> Bool quickCheck' :: Testable prop => prop -> IO Bool quickCheckWith' :: Testable prop => Args -> prop -> IO Bool -- | Pretty printing functions. module Agda.Utils.Pretty -- | While Show is for rendering data in Haskell syntax, -- Pretty is for displaying data to the world, i.e., the user and -- the environment. -- -- Atomic data has no inner document structure, so just implement -- pretty as pretty a = text $ ... a .... class Pretty a where pretty = prettyPrec 0 prettyPrec = const pretty pretty :: Pretty a => a -> Doc prettyPrec :: Pretty a => Int -> a -> Doc -- | Use instead of show when printing to world. prettyShow :: Pretty a => a -> String -- | Space separated list of pretty things. prettyList :: Pretty a => [a] -> Doc pwords :: String -> [Doc] fwords :: String -> Doc mparens :: Bool -> Doc -> Doc -- | align max rows lays out the elements of rows in two -- columns, with the second components aligned. The alignment column of -- the second components is at most max characters to the right -- of the left-most column. -- -- Precondition: max > 0. align :: Int -> [(String, Doc)] -> Doc instance Agda.Utils.Pretty.Pretty GHC.Types.Bool instance Agda.Utils.Pretty.Pretty GHC.Types.Int instance Agda.Utils.Pretty.Pretty GHC.Int.Int32 instance Agda.Utils.Pretty.Pretty GHC.Integer.Type.Integer instance Agda.Utils.Pretty.Pretty GHC.Types.Char instance Agda.Utils.Pretty.Pretty Text.PrettyPrint.HughesPJ.Doc instance Agda.Utils.Pretty.Pretty GHC.Base.String module Agda.Utils.Pointer data Ptr a newPtr :: a -> Ptr a derefPtr :: Ptr a -> a setPtr :: a -> Ptr a -> Ptr a updatePtr :: (a -> a) -> Ptr a -> Ptr a -- | If f a contains many copies of a they will all be -- the same pointer in the result. If the function is well-behaved (i.e. -- preserves the implicit equivalence, this shouldn't matter). updatePtrM :: Functor f => (a -> f a) -> Ptr a -> f (Ptr a) instance GHC.Show.Show a => GHC.Show.Show (Agda.Utils.Pointer.Ptr a) instance GHC.Base.Functor Agda.Utils.Pointer.Ptr instance Data.Foldable.Foldable Agda.Utils.Pointer.Ptr instance Data.Traversable.Traversable Agda.Utils.Pointer.Ptr instance GHC.Classes.Eq (Agda.Utils.Pointer.Ptr a) instance GHC.Classes.Ord (Agda.Utils.Pointer.Ptr a) instance Data.Hashable.Class.Hashable (Agda.Utils.Pointer.Ptr a) instance Control.DeepSeq.NFData (Agda.Utils.Pointer.Ptr a) module Agda.Utils.PartialOrd -- | The result of comparing two things (of the same type). data PartialOrdering -- | Less than. POLT :: PartialOrdering -- | Less or equal than. POLE :: PartialOrdering -- | Equal POEQ :: PartialOrdering -- | Greater or equal. POGE :: PartialOrdering -- | Greater than. POGT :: PartialOrdering -- | No information (incomparable). POAny :: PartialOrdering -- | Comparing the information content of two elements of -- PartialOrdering. More precise information is smaller. -- -- Includes equality: x leqPO x == True. leqPO :: PartialOrdering -> PartialOrdering -> Bool -- | Opposites. -- -- related a po b iff related b (oppPO po) a. oppPO :: PartialOrdering -> PartialOrdering -- | Combining two pieces of information (picking the least information). -- Used for the dominance ordering on tuples. -- -- orPO is associative, commutative, and idempotent. -- orPO has dominant element POAny, but no neutral -- element. orPO :: PartialOrdering -> PartialOrdering -> PartialOrdering -- | Chains (transitivity) x R y S z. -- -- seqPO is associative, commutative, and idempotent. -- seqPO has dominant element POAny and neutral element -- (unit) POEQ. seqPO :: PartialOrdering -> PartialOrdering -> PartialOrdering -- | Partial ordering forms a monoid under sequencing. -- | Embed Ordering. fromOrdering :: Ordering -> PartialOrdering -- | Represent a non-empty disjunction of Orderings as -- PartialOrdering. fromOrderings :: [Ordering] -> PartialOrdering -- | A PartialOrdering information is a disjunction of -- Ordering informations. toOrderings :: PartialOrdering -> [Ordering] type Comparable a = a -> a -> PartialOrdering -- | Decidable partial orderings. class PartialOrd a comparable :: PartialOrd a => Comparable a -- | Any Ord is a PartialOrd. comparableOrd :: Ord a => Comparable a -- | Are two elements related in a specific way? -- -- related a o b holds iff comparable a b is contained -- in o. related :: PartialOrd a => a -> PartialOrdering -> a -> Bool -- | Nothing and Just _ are unrelated. -- -- Partial ordering for Maybe a is the same as for Either () -- a. -- | Partial ordering for disjoint sums: Left _ and Right -- _ are unrelated. -- | Pointwise partial ordering for tuples. -- -- related (x1,x2) o (y1,y2) iff related x1 o x2 and -- related y1 o y2. -- | Pointwise comparison wrapper. newtype Pointwise a Pointwise :: a -> Pointwise a [pointwise] :: Pointwise a -> a -- | The pointwise ordering for lists of the same length. -- -- There are other partial orderings for lists, e.g., prefix, sublist, -- subset, lexicographic, simultaneous order. -- | Inclusion comparison wrapper. newtype Inclusion a Inclusion :: a -> Inclusion a [inclusion] :: Inclusion a -> a -- | Sublist for ordered lists. -- | Sets are partially ordered by inclusion. -- | Less is ``less general'' (i.e., more precise). -- | We test our properties on integer sets ordered by inclusion. newtype ISet ISet :: Inclusion (Set Int) -> ISet [iset] :: ISet -> Inclusion (Set Int) -- | Any two elements are related in the way comparable -- computes. prop_comparable_related :: ISet -> ISet -> Bool -- |
-- flip comparable a b == oppPO (comparable a b) --prop_oppPO :: ISet -> ISet -> Bool -- | Auxiliary function: lists to sets = sorted duplicate-free lists. sortUniq :: [Ordering] -> [Ordering] -- | leqPO is inclusion of the associated Ordering sets. prop_leqPO_sound :: PartialOrdering -> PartialOrdering -> Bool -- | orPO amounts to the union of the associated Ordering -- sets. Except that 'orPO POLT POGT == POAny' which should also include -- POEQ. prop_orPO_sound :: PartialOrdering -> PartialOrdering -> Bool -- | orPO is associative. prop_associative_orPO :: PartialOrdering -> PartialOrdering -> PartialOrdering -> Bool -- | orPO is commutative. prop_commutative_orPO :: PartialOrdering -> PartialOrdering -> Bool -- | orPO is idempotent. prop_idempotent_orPO :: PartialOrdering -> Bool -- | The dominant element wrt. orPO is POAny. prop_zero_orPO :: PartialOrdering -> Bool -- | Soundness of seqPO. -- -- As QuickCheck test, this property is inefficient, see -- prop_seqPO. property_seqPO :: ISet -> PartialOrdering -> ISet -> PartialOrdering -> ISet -> Property -- | A more efficient way of stating soundness of seqPO. prop_seqPO :: ISet -> ISet -> ISet -> Bool -- | The unit of seqPO is POEQ. prop_identity_seqPO :: PartialOrdering -> Bool -- | The zero of seqPO is POAny. prop_zero_seqPO :: PartialOrdering -> Bool -- | seqPO is associative. prop_associative_seqPO :: PartialOrdering -> PartialOrdering -> PartialOrdering -> Bool -- | seqPO is also commutative. prop_commutative_seqPO :: PartialOrdering -> PartialOrdering -> Bool -- | seqPO is idempotent. prop_idempotent_seqPO :: PartialOrdering -> Bool -- | seqPO distributes over orPO. prop_distributive_seqPO_orPO :: PartialOrdering -> PartialOrdering -> PartialOrdering -> Bool -- | The result of toOrderings is a sorted list without duplicates. prop_sorted_toOrderings :: PartialOrdering -> Bool -- | From Ordering to PartialOrdering and back is the -- identity. prop_toOrderings_after_fromOrdering :: Ordering -> Bool -- | From PartialOrdering to Orderings and back is the -- identity. prop_fromOrderings_after_toOrderings :: PartialOrdering -> Bool -- | From Orderings to PartialOrdering and back is the -- identity. Except for [LT,GT] which is a non-canonical -- representative of POAny. prop_toOrderings_after_fromOrderings :: NonEmptyList Ordering -> Bool -- | Pairs are related iff both components are related. prop_related_pair :: ISet -> ISet -> ISet -> ISet -> PartialOrdering -> Bool -- | Comparing PartialOrderings amounts to compare their -- representation as Ordering sets. prop_comparable_PartialOrdering :: PartialOrdering -> PartialOrdering -> Bool -- | All tests as collected by quickCheckAll. -- -- Using quickCheckAll is convenient and superior to the manual -- enumeration of tests, since the name of the property is added -- automatically. tests :: IO Bool instance GHC.Show.Show Agda.Utils.PartialOrd.ISet instance Agda.Utils.PartialOrd.PartialOrd Agda.Utils.PartialOrd.ISet instance GHC.Classes.Ord Agda.Utils.PartialOrd.ISet instance GHC.Classes.Eq Agda.Utils.PartialOrd.ISet instance GHC.Base.Functor Agda.Utils.PartialOrd.Inclusion instance GHC.Show.Show a => GHC.Show.Show (Agda.Utils.PartialOrd.Inclusion a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Agda.Utils.PartialOrd.Inclusion a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Utils.PartialOrd.Inclusion a) instance GHC.Base.Functor Agda.Utils.PartialOrd.Pointwise instance GHC.Show.Show a => GHC.Show.Show (Agda.Utils.PartialOrd.Pointwise a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Utils.PartialOrd.Pointwise a) instance GHC.Enum.Bounded Agda.Utils.PartialOrd.PartialOrdering instance GHC.Enum.Enum Agda.Utils.PartialOrd.PartialOrdering instance GHC.Show.Show Agda.Utils.PartialOrd.PartialOrdering instance GHC.Classes.Eq Agda.Utils.PartialOrd.PartialOrdering instance GHC.Base.Monoid Agda.Utils.PartialOrd.PartialOrdering instance Agda.Utils.PartialOrd.PartialOrd GHC.Types.Int instance Agda.Utils.PartialOrd.PartialOrd GHC.Integer.Type.Integer instance Agda.Utils.PartialOrd.PartialOrd () instance Agda.Utils.PartialOrd.PartialOrd a => Agda.Utils.PartialOrd.PartialOrd (GHC.Base.Maybe a) instance (Agda.Utils.PartialOrd.PartialOrd a, Agda.Utils.PartialOrd.PartialOrd b) => Agda.Utils.PartialOrd.PartialOrd (Data.Either.Either a b) instance (Agda.Utils.PartialOrd.PartialOrd a, Agda.Utils.PartialOrd.PartialOrd b) => Agda.Utils.PartialOrd.PartialOrd (a, b) instance Agda.Utils.PartialOrd.PartialOrd a => Agda.Utils.PartialOrd.PartialOrd (Agda.Utils.PartialOrd.Pointwise [a]) instance GHC.Classes.Ord a => Agda.Utils.PartialOrd.PartialOrd (Agda.Utils.PartialOrd.Inclusion [a]) instance GHC.Classes.Ord a => Agda.Utils.PartialOrd.PartialOrd (Agda.Utils.PartialOrd.Inclusion (Data.Set.Base.Set a)) instance Agda.Utils.PartialOrd.PartialOrd Agda.Utils.PartialOrd.PartialOrdering instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Utils.PartialOrd.PartialOrdering instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Utils.PartialOrd.ISet module Agda.Utils.Parser.ReadP data ReadP t a -- | Consumes and returns the next character. Fails if there is no input -- left. get :: ReadP t t -- | Look-ahead: returns the part of the input that is left, without -- consuming it. look :: ReadP t [t] -- | Symmetric choice. (+++) :: ReadP t a -> ReadP t a -> ReadP t a infixr 5 +++ -- | Local, exclusive, left-biased choice: If left parser locally produces -- any result at all, then right parser is not used. (<++) :: ReadP t a -> ReadP t a -> ReadP t a infixr 5 <++ -- | Transforms a parser into one that does the same, but in addition -- returns the exact characters read. IMPORTANT NOTE: gather gives -- a runtime error if its first argument is built using any occurrences -- of readS_to_P. gather :: ReadP t a -> ReadP t ([t], a) -- | Run a parser on a list of tokens. Returns the list of complete -- matches. parse :: ReadP t a -> [t] -> [a] parse' :: ReadP t a -> [t] -> Either a [t] -- | Always fails. pfail :: ReadP t a -- | Consumes and returns the next character, if it satisfies the specified -- predicate. satisfy :: (t -> Bool) -> ReadP t t -- | Parses and returns the specified character. char :: Eq t => t -> ReadP t t -- | Parses and returns the specified string. string :: Eq t => [t] -> ReadP t [t] -- | Parses the first zero or more characters satisfying the predicate. munch :: (t -> Bool) -> ReadP t [t] -- | Parses the first one or more characters satisfying the predicate. munch1 :: (t -> Bool) -> ReadP t [t] -- | Skips all whitespace. skipSpaces :: ReadP Char () -- | Combines all parsers in the specified list. choice :: [ReadP t a] -> ReadP t a -- | count n p parses n occurrences of p in -- sequence. A list of results is returned. count :: Int -> ReadP t a -> ReadP t [a] -- | between open close p parses open, followed by -- p and finally close. Only the value of p is -- returned. between :: ReadP t open -> ReadP t close -> ReadP t a -> ReadP t a -- | option x p will either parse p or return x -- without consuming any input. option :: a -> ReadP t a -> ReadP t a -- | optional p optionally parses p and always returns -- (). optional :: ReadP t a -> ReadP t () -- | Parses zero or more occurrences of the given parser. many :: ReadP t a -> ReadP t [a] -- | Parses one or more occurrences of the given parser. many1 :: ReadP t a -> ReadP t [a] -- | Like many, but discards the result. skipMany :: ReadP t a -> ReadP t () -- | Like many1, but discards the result. skipMany1 :: ReadP t a -> ReadP t () -- | sepBy p sep parses zero or more occurrences of p, -- separated by sep. Returns a list of values returned by -- p. sepBy :: ReadP t a -> ReadP t sep -> ReadP t [a] -- | sepBy1 p sep parses one or more occurrences of p, -- separated by sep. Returns a list of values returned by -- p. sepBy1 :: ReadP t a -> ReadP t sep -> ReadP t [a] -- | endBy p sep parses zero or more occurrences of p, -- separated and ended by sep. endBy :: ReadP t a -> ReadP t sep -> ReadP t [a] -- | endBy p sep parses one or more occurrences of p, -- separated and ended by sep. endBy1 :: ReadP t a -> ReadP t sep -> ReadP t [a] -- | chainr p op x parses zero or more occurrences of p, -- separated by op. Returns a value produced by a right -- associative application of all functions returned by op. If -- there are no occurrences of p, x is returned. chainr :: ReadP t a -> ReadP t (a -> a -> a) -> a -> ReadP t a -- | chainl p op x parses zero or more occurrences of p, -- separated by op. Returns a value produced by a left -- associative application of all functions returned by op. If -- there are no occurrences of p, x is returned. chainl :: ReadP t a -> ReadP t (a -> a -> a) -> a -> ReadP t a -- | Like chainl, but parses one or more occurrences of p. chainl1 :: ReadP t a -> ReadP t (a -> a -> a) -> ReadP t a -- | Like chainr, but parses one or more occurrences of p. chainr1 :: ReadP t a -> ReadP t (a -> a -> a) -> ReadP t a -- | manyTill p end parses zero or more occurrences of p, -- until end succeeds. Returns a list of values returned by -- p. manyTill :: ReadP t a -> ReadP t end -> ReadP t [a] instance GHC.Base.Functor (Agda.Utils.Parser.ReadP.P t) instance GHC.Base.Applicative (Agda.Utils.Parser.ReadP.P t) instance GHC.Base.Monad (Agda.Utils.Parser.ReadP.P t) instance GHC.Base.Alternative (Agda.Utils.Parser.ReadP.P t) instance GHC.Base.MonadPlus (Agda.Utils.Parser.ReadP.P t) instance GHC.Base.Functor (Agda.Utils.Parser.ReadP.ReadP t) instance GHC.Base.Applicative (Agda.Utils.Parser.ReadP.ReadP t) instance GHC.Base.Monad (Agda.Utils.Parser.ReadP.ReadP t) instance GHC.Base.Alternative (Agda.Utils.Parser.ReadP.ReadP t) instance GHC.Base.MonadPlus (Agda.Utils.Parser.ReadP.ReadP t) -- | An interface for reporting "impossible" errors module Agda.Utils.Impossible -- | "Impossible" errors, annotated with a file name and a line number -- corresponding to the source code location of the error. data Impossible Impossible :: String -> Integer -> Impossible -- | Abort by throwing an "impossible" error. You should not use this -- function directly. Instead use the macro in undefined.h. throwImpossible :: Impossible -> a -- | Catch an "impossible" error, if possible. catchImpossible :: IO a -> (Impossible -> IO a) -> IO a instance GHC.Show.Show Agda.Utils.Impossible.Impossible instance GHC.Exception.Exception Agda.Utils.Impossible.Impossible module Agda.Utils.Map data EitherOrBoth a b L :: a -> EitherOrBoth a b B :: a -> b -> EitherOrBoth a b R :: b -> EitherOrBoth a b -- | Not very efficient (goes via a list), but it'll do. unionWithM :: (Ord k, Monad m) => (a -> a -> m a) -> Map k a -> Map k a -> m (Map k a) insertWithKeyM :: (Ord k, Monad m) => (k -> a -> a -> m a) -> k -> a -> Map k a -> m (Map k a) -- | Big conjunction over a map. allWithKey :: (k -> a -> Bool) -> Map k a -> Bool -- | Filter a map based on the keys. filterKeys :: (k -> Bool) -> Map k a -> Map k a -- | Unzip a map. unzip :: Map k (a, b) -> (Map k a, Map k b) unzip3 :: Map k (a, b, c) -> (Map k a, Map k b, Map k c) -- | Extend Maybe by common operations for the Maybe type. -- -- Note: since this module is usually imported unqualified, we do not use -- short names, but all names contain Maybe, Just, or -- 'Nothing. module Agda.Utils.Maybe -- | unionWith for collections of size <= 1. unionMaybeWith :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a -- | Unzipping a list of length <= 1. unzipMaybe :: Maybe (a, b) -> (Maybe a, Maybe b) -- | Filtering a singleton list. -- --
-- filterMaybe p a = listToMaybe (filter p [a]) --filterMaybe :: (a -> Bool) -> a -> Maybe a -- | Version of mapMaybe with different argument ordering. forMaybe :: [a] -> (a -> Maybe b) -> [b] -- | Version of maybe with different argument ordering. Often, we -- want to case on a Maybe, do something interesting in the -- Just case, but only a default action in the Nothing -- case. Then, the argument ordering of caseMaybe is preferable. -- --
-- caseMaybe m d f = flip (maybe d) m f --caseMaybe :: Maybe a -> b -> (a -> b) -> b -- | Monadic version of maybe. maybeM :: Monad m => m b -> (a -> m b) -> m (Maybe a) -> m b -- | Monadic version of fromMaybe. fromMaybeM :: Monad m => m a -> m (Maybe a) -> m a -- | Monadic version of caseMaybe. That is, maybeM with a -- different argument ordering. caseMaybeM :: Monad m => m (Maybe a) -> m b -> (a -> m b) -> m b -- | caseMaybeM with flipped branches. ifJustM :: Monad m => m (Maybe a) -> (a -> m b) -> m b -> m b -- | A more telling name for forM_ for the Maybe collection -- type. Or: caseMaybe without the Nothing case. whenJust :: Monad m => Maybe a -> (a -> m ()) -> m () -- | caseMaybe without the Just case. whenNothing :: Monad m => Maybe a -> m () -> m () -- | caseMaybeM without the Nothing case. whenJustM :: Monad m => m (Maybe a) -> (a -> m ()) -> m () -- | caseMaybeM without the Just case. whenNothingM :: Monad m => m (Maybe a) -> m () -> m () -- | Lazy version of allJust . sequence. (allJust = -- mapM for the Maybe monad.) Only executes monadic effect -- while isJust. allJustM :: Monad m => [m (Maybe a)] -> m (Maybe [a]) -- | Precondition: list not empty. allJustsOrNothings [Nothing, -- Nothing] = Just Nothing allJustsOrNothings [Just 0, Just 1] = Just $ -- Just [0,1] allJustsOrNothings [Just 0, Nothing] = Nothing allJustsOrNothings :: [Maybe a] -> Maybe (Maybe [a]) -- | ListT done right, see -- https://www.haskell.org/haskellwiki/ListT_done_right_alternative -- -- There is also the list-t package on hackage (Nikita Volkov) -- but it again depends on other packages we do not use yet, so we rather -- implement the few bits we need afresh. module Agda.Utils.ListT -- | Lazy monadic computation of a list of results. newtype ListT m a ListT :: m (Maybe (a, ListT m a)) -> ListT m a [runListT] :: ListT m a -> m (Maybe (a, ListT m a)) -- | The empty lazy list. nilListT :: Monad m => ListT m a -- | Consing a value to a lazy list. consListT :: Monad m => a -> ListT m a -> ListT m a -- | Singleton lazy list. sgListT :: Monad m => a -> ListT m a -- | Case distinction over lazy list. caseListT :: Monad m => ListT m a -> m b -> (a -> ListT m a -> m b) -> m b -- | Folding a lazy list, effects left-to-right. foldListT :: Monad m => (a -> m b -> m b) -> m b -> ListT m a -> m b -- | The join operation of the ListT m monad. concatListT :: Monad m => ListT m (ListT m a) -> ListT m a -- | We can `run' a computation of a ListT as it is monadic -- itself. runMListT :: Monad m => m (ListT m a) -> ListT m a -- | Monadic cons. consMListT :: Monad m => m a -> ListT m a -> ListT m a -- | Monadic singleton. sgMListT :: Monad m => m a -> ListT m a -- | Extending a monadic function to ListT. mapMListT :: (Monad m) => (a -> m b) -> ListT m a -> ListT m b -- | Alternative implementation using foldListT. mapMListT_alt :: (Monad m) => (a -> m b) -> ListT m a -> ListT m b -- | Change from one monad to another liftListT :: (Monad m, Monad m') => (forall a. m a -> m' a) -> ListT m a -> ListT m' a instance GHC.Base.Functor m => GHC.Base.Functor (Agda.Utils.ListT.ListT m) instance GHC.Base.Monad m => GHC.Base.Monoid (Agda.Utils.ListT.ListT m a) instance (GHC.Base.Functor m, GHC.Base.Applicative m, GHC.Base.Monad m) => GHC.Base.Alternative (Agda.Utils.ListT.ListT m) instance (GHC.Base.Functor m, GHC.Base.Applicative m, GHC.Base.Monad m) => GHC.Base.MonadPlus (Agda.Utils.ListT.ListT m) instance (GHC.Base.Functor m, GHC.Base.Applicative m, GHC.Base.Monad m) => GHC.Base.Applicative (Agda.Utils.ListT.ListT m) instance (GHC.Base.Functor m, GHC.Base.Applicative m, GHC.Base.Monad m) => GHC.Base.Monad (Agda.Utils.ListT.ListT m) instance Control.Monad.Trans.Class.MonadTrans Agda.Utils.ListT.ListT instance (GHC.Base.Applicative m, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Agda.Utils.ListT.ListT m) instance (GHC.Base.Applicative m, Control.Monad.Reader.Class.MonadReader r m) => Control.Monad.Reader.Class.MonadReader r (Agda.Utils.ListT.ListT m) instance (GHC.Base.Applicative m, Control.Monad.State.Class.MonadState s m) => Control.Monad.State.Class.MonadState s (Agda.Utils.ListT.ListT m) -- | Quickcheck properties for ListT. module Agda.Utils.ListT.Tests -- | All tests as collected by quickCheckAll. tests :: IO Bool -- | Utilities for Data.IORef. module Agda.Utils.IORef -- | Read IORef, modify it strictly, and return old value. readModifyIORef' :: IORef a -> (a -> a) -> IO a -- | Text IO using the UTF8 character encoding. module Agda.Utils.IO.UTF8 -- | Reads a UTF8-encoded text file and converts all Unicode line endings -- into '\n'. readTextFile :: FilePath -> IO String -- | Writes UTF8-encoded text to the handle, which should be opened for -- writing and in text mode. The native convention for line endings is -- used. -- -- The handle's text encoding is not necessarily preserved, it is changed -- to UTF8. hPutStr :: Handle -> String -> IO () -- | Writes a UTF8-encoded text file. The native convention for line -- endings is used. writeFile :: FilePath -> String -> IO () module Agda.Utils.IO.Directory copyDirContent :: FilePath -> FilePath -> IO () -- | Binary IO. module Agda.Utils.IO.Binary -- | Returns a close function for the file together with the contents. readBinaryFile' :: FilePath -> IO (ByteString, IO ()) module Agda.Utils.HashMap -- | Utilities for functors. module Agda.Utils.Functor ($>) :: Functor f => f a -> b -> f b infixr 4 $> -- | Composition: pure function after functorial (monadic) function. (<.>) :: Functor m => (b -> c) -> (a -> m b) -> a -> m c infixr 9 <.> -- | The true pure for loop. for is a misnomer, it should -- be forA. for :: Functor m => m a -> (a -> b) -> m b -- | Infix version of for. (<&>) :: Functor m => m a -> (a -> b) -> m b infix 4 <&> -- | A decoration is a functor that is traversable into any functor. -- -- The Functor superclass is given because of the limitations of -- the Haskell class system. traverseF actually implies -- functoriality. -- -- Minimal complete definition: traverseF or -- distributeF. class Functor t => Decoration t where traverseF f = distributeF . fmap f distributeF = traverseF id -- | traverseF is the defining property. traverseF :: (Decoration t, Functor m) => (a -> m b) -> t a -> m (t b) -- | Decorations commute into any functor. distributeF :: (Decoration t, Functor m) => t (m a) -> m (t a) -- | Any decoration is traversable with traverse = traverseF. Just -- like any Traversable is a functor, so is any decoration, given -- by just traverseF, a functor. dmap :: Decoration t => (a -> b) -> t a -> t b -- | Any decoration is a lens. set is a special case of -- dmap. dget :: Decoration t => t a -> a -- | The identity functor is a decoration. -- | Decorations compose. (Thus, they form a category.) -- | A typical decoration is pairing with some stuff. -- | An infix synonym for fmap. -- -- The name of this operator is an allusion to $. Note the -- similarities between their types: -- --
-- ($) :: (a -> b) -> a -> b -- (<$>) :: Functor f => (a -> b) -> f a -> f b ---- -- Whereas $ is function application, <$> is -- function application lifted over a Functor. -- --
-- >>> show <$> Nothing -- Nothing -- -- >>> show <$> Just 3 -- Just "3" ---- -- Convert from an Either Int Int to -- an Either Int String using -- show: -- --
-- >>> show <$> Left 17 -- Left 17 -- -- >>> show <$> Right 17 -- Right "17" ---- -- Double each element of a list: -- --
-- >>> (*2) <$> [1,2,3] -- [2,4,6] ---- -- Apply even to the second element of a pair: -- --
-- >>> even <$> (2,2) -- (2,True) --(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 <$> instance Agda.Utils.Functor.Decoration Data.Functor.Identity.Identity instance (Agda.Utils.Functor.Decoration d, Agda.Utils.Functor.Decoration t) => Agda.Utils.Functor.Decoration (Data.Functor.Compose.Compose d t) instance Agda.Utils.Functor.Decoration ((,) a) -- | A cut-down implementation of lenses, with names taken from Edward -- Kmett's lens package. module Agda.Utils.Lens -- | Van Laarhoven style homogeneous lenses. Mnemoic: "Lens inner outer". type Lens' i o = forall f. Functor f => (i -> f i) -> o -> f o -- | Get inner part i of structure o as designated by -- Lens' i o. (^.) :: o -> Lens' i o -> i infixl 8 ^. -- | Set inner part i of structure o as designated by -- Lens' i o. set :: Lens' i o -> i -> o -> o -- | Modify inner part i of structure o using a function -- i -> i. over :: Lens' i o -> (i -> i) -> o -> o -- | Read a part of the state. use :: MonadState o m => Lens' i o -> m i -- | Write a part of the state. (.=) :: MonadState o m => Lens' i o -> i -> m () infix 4 .= -- | Modify a part of the state. (%=) :: MonadState o m => Lens' i o -> (i -> i) -> m () infix 4 %= -- | Modify a part of the state monadically. (%==) :: MonadState o m => Lens' i o -> (i -> m i) -> m () infix 4 %== -- | Modify a part of the state monadically, and return some result. (%%=) :: MonadState o m => Lens' i o -> (i -> m (i, r)) -> m r infix 4 %%= -- | Ask for part of read-only state. view :: MonadReader o m => Lens' i o -> m i -- | Modify a part of the state in a subcomputation. locally :: MonadReader o m => Lens' i o -> (i -> i) -> m a -> m a key :: Ord k => k -> Lens' (Maybe v) (Map k v) -- | Infix version of for. (<&>) :: Functor m => m a -> (a -> b) -> m b infix 4 <&> module Agda.Utils.Memo -- | Simple, non-reentrant memoisation. memo :: MonadState s m => Lens' (Maybe a) s -> m a -> m a -- | Recursive memoisation, second argument is the value you get on -- recursive calls. memoRec :: MonadState s m => Lens' (Maybe a) s -> a -> m a -> m a -- | Examples how to use Agda.Utils.Lens. module Agda.Utils.Lens.Examples data Record a b Record :: a -> b -> Record a b [field1] :: Record a b -> a [field2] :: Record a b -> b -- | (View source:) This is how you implement a lens for a record field. lensField1 :: Lens' a (Record a b) lensField2 :: Lens' b (Record a b) module Agda.Utils.Function -- | Repeat a state transition f :: a -> (b, a) with output -- b while condition cond on the output is true. Return -- all intermediate results and the final result where cond is -- False. -- -- Postconditions (when it terminates): fst (last (iterWhile cond f -- a)) == False. all fst (init (interWhile cond f a)). iterWhile :: (b -> Bool) -> (a -> (b, a)) -> a -> [(b, a)] -- | Repeat something while a condition on some state is true. Return the -- last state (including the changes of the last transition, even if the -- condition became false then). repeatWhile :: (a -> (Bool, a)) -> a -> a -- | Monadic version of repeatWhile. repeatWhileM :: (Monad m) => (a -> m (Bool, a)) -> a -> m a -- | A version of the trampoline function. -- -- The usual function iterates f :: a -> Maybe a as long as -- Just{} is returned, and returns the last value of a -- upon Nothing. -- -- usualTrampoline f = trampolineWhile $ a -> maybe (False,a) -- (True,) (f a). -- -- trampolineWhile is very similar to repeatWhile, only -- that it discards the state on which the condition went False, -- and returns the last state on which the condition was True. trampolineWhile :: (a -> (Bool, a)) -> a -> a -- | Monadic version of trampolineWhile. trampolineWhileM :: (Monad m) => (a -> m (Bool, a)) -> a -> m a -- | More general trampoline, which allows some final computation from -- iteration state a into result type b. trampoline :: (a -> Either b a) -> a -> b -- | Monadic version of trampoline. trampolineM :: Monad m => (a -> m (Either b a)) -> a -> m b -- | Iteration to fixed-point. -- -- iterateUntil r f a0 iterates endofunction f, -- starting with a0, until r relates its result to its -- input, i.e., f a r a. -- -- This is the generic pattern behind saturation algorithms. -- -- If f is monotone with regard to r, meaning a -- r b implies f a r f b, and -- f-chains starting with a0 are finite then iteration -- is guaranteed to terminate. -- -- A typical instance will work on sets, and r could be set -- inclusion, and a0 the empty set, and f the step -- function of a saturation algorithm. iterateUntil :: (a -> a -> Bool) -> (a -> a) -> a -> a -- | Monadic version of iterateUntil. iterateUntilM :: Monad m => (a -> a -> Bool) -> (a -> m a) -> a -> m a -- | iterate' n f x applies f to x -- n times and returns the result. -- -- The applications are calculated strictly. iterate' :: Integral i => i -> (a -> a) -> a -> a -- | applyWhen b f a applies f to a when -- b. applyWhen :: Bool -> (a -> a) -> a -> a -- | applyUnless b f a applies f to a unless -- b. applyUnless :: Bool -> (a -> a) -> a -> a -- | Monadic version of applyWhen applyWhenM :: (Monad m) => m Bool -> (m a -> m a) -> m a -> m a -- | Monadic version of applyUnless applyUnlessM :: (Monad m) => m Bool -> (m a -> m a) -> m a -> m a module Agda.Utils.Suffix -- | Is the character one of the subscripts '₀'-'₉'? isSubscriptDigit :: Char -> Bool -- | Converts '0'-'9' to '₀'-'₉'. -- -- Precondition: The digit needs to be in range. toSubscriptDigit :: Char -> Char -- | Converts '₀'-'₉' to '0'-'9'. -- -- Precondition: The digit needs to be in range. fromSubscriptDigit :: Char -> Char -- | Classification of identifier variants. data Suffix NoSuffix :: Suffix -- | Identifier ends in Int many primes. Prime :: Int -> Suffix -- | Identifier ends in number Int (ordinary digits). Index :: Int -> Suffix -- | Identifier ends in number Int (subscript digits). Subscript :: Int -> Suffix -- | Increase the suffix by one. If no suffix yet, put a subscript -- 1. nextSuffix :: Suffix -> Suffix -- | Parse suffix. suffixView :: String -> (String, Suffix) -- | Print suffix. addSuffix :: String -> Suffix -> String -- | Add first available Suffix to a name. nameVariant :: (String -> Bool) -> String -> String -- | Operations on file names. module Agda.Utils.FileName -- | Paths which are known to be absolute. -- -- Note that the Eq and Ord instances do not check if -- different paths point to the same files or directories. data AbsolutePath -- | Extract the AbsolutePath to be used as FilePath. filePath :: AbsolutePath -> FilePath -- | maps blablablafoo.bar.xxx to foo.bar. rootName :: AbsolutePath -> String -- | Constructs AbsolutePaths. -- -- Precondition: The path must be absolute and valid. mkAbsolute :: FilePath -> AbsolutePath -- | Makes the path absolute. -- -- This function may raise an __IMPOSSIBLE__ error if -- canonicalizePath does not return an absolute path. absolute :: FilePath -> IO AbsolutePath -- | Tries to establish if the two file paths point to the same file (or -- directory). (===) :: AbsolutePath -> AbsolutePath -> Bool infix 4 === -- | Case-sensitive doesFileExist for Windows. This is case-sensitive only -- on the file name part, not on the directory part. (Ideally, path -- components coming from module name components should be checked -- case-sensitively and the other path components should be checked case -- insenstively.) doesFileExistCaseSensitive :: FilePath -> IO Bool tests :: IO Bool instance Data.Hashable.Class.Hashable Agda.Utils.FileName.AbsolutePath instance GHC.Classes.Ord Agda.Utils.FileName.AbsolutePath instance GHC.Classes.Eq Agda.Utils.FileName.AbsolutePath instance GHC.Show.Show Agda.Utils.FileName.AbsolutePath instance Agda.Utils.Pretty.Pretty Agda.Utils.FileName.AbsolutePath instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Utils.FileName.AbsolutePath instance Test.QuickCheck.Arbitrary.CoArbitrary Agda.Utils.FileName.AbsolutePath -- | Instead of checking time-stamps we compute a hash of the module source -- and store it in the interface file. This module contains the functions -- to do that. module Agda.Utils.Hash type Hash = Word64 hashByteString :: ByteString -> Hash hashFile :: AbsolutePath -> IO Hash combineHashes :: [Hash] -> Hash -- | Hashing a module name for unique identifiers. hashString :: String -> Integer -- | Wrapper for Control.Monad.Except from the mtl package module Agda.Utils.Except class Error a where noMsg = strMsg "" strMsg _ = noMsg noMsg :: Error a => a strMsg :: Error a => String -> a -- | A monad transformer that adds exceptions to other monads. -- -- ExceptT constructs a monad parameterized over two things: -- --
-- do { action1; action2; action3 } `catchError` handler ---- -- where the action functions can call throwError. Note -- that handler and the do-block must have the same return type. catchError :: MonadError e m => m a -> (e -> m a) -> m a -- | The inverse of ExceptT. runExceptT :: ExceptT e m a -> m (Either e a) -- | Map the unwrapped computation using the given function. -- --
runExceptT (mapExceptT f m) = f -- (runExceptT m)
-- allRight xs == -- if all isRight xs then -- Just (map ((Right x) -> x) xs) -- else -- Nothing --allRight :: [Either a b] -> Maybe [b] tests :: IO Bool -- | Create clusters of non-overlapping things. module Agda.Utils.Cluster -- | Given a function f :: a -> (C,[C]) which returns a -- non-empty list of characteristics C of a, partition -- a list of as into groups such that each element in a group -- shares at least one characteristic with at least one other element of -- the group. cluster :: (a -> (C, [C])) -> [a] -> [[a]] -- | Partition a list of as paired with a non-empty list of -- characteristics $C$ into groups such that each element in a group -- shares at least one characteristic with at least one other element of -- the group. cluster' :: [(a, (C, [C]))] -> [[a]] tests :: IO Bool module Agda.Utils.Char -- | Convert a character in '0'..'9' into the corresponding digit -- 0..9. decDigit :: Char -> Int -- | Convert a character in '0'..'9','A'..'F','a'..'f' into the -- corresponding digit 0..15. hexDigit :: Char -> Int -- | Convert a character in '0'..'7' into the corresponding digit -- 0..7. octDigit :: Char -> Int -- | Unicode characters are divided into letters, numbers, marks, -- punctuation, symbols, separators (including spaces) and others -- (including control characters). -- -- These are the tests that Char offers data UnicodeTest IsControl :: UnicodeTest IsSpace :: UnicodeTest IsLower :: UnicodeTest IsUpper :: UnicodeTest IsAlpha :: UnicodeTest IsAlphaNum :: UnicodeTest IsPrint :: UnicodeTest IsDigit :: UnicodeTest IsOctDigit :: UnicodeTest IsHexDigit :: UnicodeTest IsLetter :: UnicodeTest IsMark :: UnicodeTest IsNumber :: UnicodeTest IsPunctuation :: UnicodeTest IsSymbol :: UnicodeTest IsSeparator :: UnicodeTest -- | Test names paired with their implementation. unicodeTests :: [(UnicodeTest, Char -> Bool)] -- | Find out which tests a character satisfies. testChar :: Char -> [UnicodeTest] instance GHC.Show.Show Agda.Utils.Char.UnicodeTest instance GHC.Classes.Ord Agda.Utils.Char.UnicodeTest instance GHC.Classes.Eq Agda.Utils.Char.UnicodeTest -- | Finite bijections (implemented as a pair of maps). module Agda.Utils.BiMap -- | Finite bijective map from a to b. There, and back -- again. data BiMap a b BiMap :: Map a b -> Map b a -> BiMap a b [biMapThere] :: BiMap a b -> Map a b [biMapBack] :: BiMap a b -> Map b a -- | Lookup. O(log n). lookup :: Ord a => a -> BiMap a b -> Maybe b -- | Inverse lookup. O(log n). invLookup :: Ord b => b -> BiMap a b -> Maybe a -- | Empty bimap. O(1). empty :: BiMap a b -- | Singleton bimap. O(1). singleton :: a -> b -> BiMap a b -- | Insert. Overwrites existing value if present. insert :: (Ord a, Ord b) => a -> b -> BiMap a b -> BiMap a b -- | Left-biased Union. O(Map.union). union :: (Ord a, Ord b) => BiMap a b -> BiMap a b -> BiMap a b -- | Construct from a list of pairs. -- -- Does not check for actual bijectivity of constructed finite map. fromList :: (Ord a, Ord b) => [(a, b)] -> BiMap a b -- | Turn into list, sorted ascendingly by first value. toList :: BiMap a b -> [(a, b)] prop_BiMap_invariant :: (Ord a, Ord b) => BiMap a b -> Bool tests :: IO Bool instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Eq (Agda.Utils.BiMap.BiMap a b) instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Agda.Utils.BiMap.BiMap a b) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Agda.Utils.BiMap.BiMap a b) instance (GHC.Classes.Ord a, GHC.Classes.Ord b, Test.QuickCheck.Arbitrary.Arbitrary a, Test.QuickCheck.Arbitrary.Arbitrary b) => Test.QuickCheck.Arbitrary.Arbitrary (Agda.Utils.BiMap.BiMap a b) -- | A simple overlay over Data.Map to manage unordered sets with -- duplicates. module Agda.Utils.Bag -- | A set with duplicates. Faithfully stores elements which are equal with -- regard to (==). newtype Bag a Bag :: Map a [a] -> Bag a [bag] :: Bag a -> Map a [a] null :: Bag a -> Bool size :: Bag a -> Int -- | bag ! a finds all elements equal to a. (!) :: Ord a => Bag a -> a -> [a] member :: Ord a => a -> Bag a -> Bool notMember :: Ord a => a -> Bag a -> Bool -- | Return the multiplicity of the given element. count :: Ord a => a -> Bag a -> Int empty :: Bag a singleton :: a -> Bag a union :: Ord a => Bag a -> Bag a -> Bag a unions :: Ord a => [Bag a] -> Bag a -- |
-- insert a b = union b (singleton a) --insert :: Ord a => a -> Bag a -> Bag a -- |
-- fromList = unions . map singleton --fromList :: Ord a => [a] -> Bag a -- | Returns the elements of the bag, grouped by equality (==). groups :: Bag a -> [[a]] -- | Returns the bag, with duplicates. toList :: Bag a -> [a] -- | Returns the bag without duplicates. keys :: Bag a -> [a] -- | Returns the bag, with duplicates. elems :: Bag a -> [a] toAscList :: Bag a -> [a] map :: Ord b => (a -> b) -> Bag a -> Bag b traverse' :: forall a b m. (Applicative m, Ord b) => (a -> m b) -> Bag a -> m (Bag b) prop_count_empty :: Ord a => a -> Bool prop_count_singleton :: Ord a => a -> Bool prop_count_insert :: Ord a => a -> Bag a -> Bool prop_size_union :: Ord a => Bag a -> Bag a -> Bool prop_size_fromList :: Ord a => [a] -> Bool prop_fromList_toList :: Ord a => Bag a -> Bool prop_toList_fromList :: Ord a => [a] -> Bool prop_keys_fromList :: Ord a => [a] -> Bool prop_nonempty_groups :: Bag a -> Bool prop_map_id :: Ord a => Bag a -> Bool prop_map_compose :: (Ord b, Ord c) => (b -> c) -> (a -> b) -> Bag a -> Bool prop_traverse_id :: Ord a => Bag a -> Bool -- | All tests as collected by quickCheckAll. -- -- Using quickCheckAll is convenient and superior to the manual -- enumeration of tests, since the name of the property is added -- automatically. tests :: IO Bool instance GHC.Classes.Ord a => GHC.Classes.Ord (Agda.Utils.Bag.Bag a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Utils.Bag.Bag a) instance GHC.Show.Show a => GHC.Show.Show (Agda.Utils.Bag.Bag a) instance GHC.Classes.Ord a => GHC.Base.Monoid (Agda.Utils.Bag.Bag a) instance Data.Foldable.Foldable Agda.Utils.Bag.Bag instance (GHC.Classes.Ord a, Test.QuickCheck.Arbitrary.Arbitrary a) => Test.QuickCheck.Arbitrary.Arbitrary (Agda.Utils.Bag.Bag a) -- | Utitlity functions on lists. module Agda.Utils.List -- | Case distinction for lists, with list first. Cf. ifNull. caseList :: [a] -> b -> (a -> [a] -> b) -> b -- | Case distinction for lists, with list last. listCase :: b -> (a -> [a] -> b) -> [a] -> b -- | Head function (safe). headMaybe :: [a] -> Maybe a -- | Head function (safe). Returns a value on empty lists. -- --
-- headWithDefault 42 [] = 42 -- headWithDefault 42 [1,2,3] = 1 --headWithDefault :: a -> [a] -> a -- | Last element (safe). lastMaybe :: [a] -> Maybe a -- | Opposite of cons (:), safe. uncons :: [a] -> Maybe (a, [a]) -- | Maybe cons. mcons ma as = maybeToList ma ++ as mcons :: Maybe a -> [a] -> [a] -- | init and last in one go, safe. initLast :: [a] -> Maybe ([a], a) -- | Lookup function (partially safe). (!!!) :: [a] -> Int -> Maybe a -- | downFrom n = [n-1,..1,0] downFrom :: Integral a => a -> [a] -- | Update the first element of a list, if it exists. updateHead :: (a -> a) -> [a] -> [a] spec_updateHead :: (a -> a) -> [a] -> [a] prop_updateHead :: Eq a => (a -> a) -> [a] -> Bool -- | Update the last element of a list, if it exists. updateLast :: (a -> a) -> [a] -> [a] spec_updateLast :: (a -> a) -> [a] -> [a] prop_updateLast :: Eq a => (a -> a) -> [a] -> Bool -- | Update nth element of a list, if it exists. Precondition: the index is -- >= 0. updateAt :: Int -> (a -> a) -> [a] -> [a] spec_updateAt :: Int -> (a -> a) -> [a] -> [a] prop_updateAt :: Eq a => NonNegative Int -> (a -> a) -> [a] -> Bool -- | A generalized version of partition. (Cf. mapMaybe -- vs. filter). mapEither :: (a -> Either b c) -> [a] -> ([b], [c]) deal :: (a -> Either b c) -> a -> ([b], [c]) -> ([b], [c]) -- | A generalized version of takeWhile. (Cf. mapMaybe -- vs. filter). takeWhileJust :: (a -> Maybe b) -> [a] -> [b] -- | A generalized version of span. spanJust :: (a -> Maybe b) -> [a] -> ([b], [a]) -- | Partition a list into Nothings and Justs. -- mapMaybe f = snd . partitionMaybe f. partitionMaybe :: (a -> Maybe b) -> [a] -> ([a], [b]) -- | Sublist relation. isSublistOf :: Eq a => [a] -> [a] -> Bool type Prefix a = [a] type Suffix a = [a] -- | Check if a list has a given prefix. If so, return the list minus the -- prefix. maybePrefixMatch :: Eq a => Prefix a -> [a] -> Maybe (Suffix a) -- | Result of preOrSuffix. data PreOrSuffix a -- | First list is prefix of second. IsPrefix :: a -> [a] -> PreOrSuffix a -- | First list is suffix of second. IsSuffix :: a -> [a] -> PreOrSuffix a -- | The lists are equal. IsBothfix :: PreOrSuffix a -- | The lists are incomparable. IsNofix :: PreOrSuffix a -- | Compare lists with respect to prefix partial order. preOrSuffix :: Eq a => [a] -> [a] -> PreOrSuffix a -- | Split a list into sublists. Generalisation of the prelude function -- words. -- --
-- words xs == wordsBy isSpace xs --wordsBy :: (a -> Bool) -> [a] -> [[a]] -- | Chop up a list in chunks of a given length. chop :: Int -> [a] -> [[a]] -- | Chop a list at the positions when the predicate holds. Contrary to -- wordsBy, consecutive separator elements will result in an empty -- segment in the result. > intercalate [x] (chopWhen (== x) xs) == xs chopWhen :: (a -> Bool) -> [a] -> [[a]] prop_chop_intercalate :: Property -- | All ways of removing one element from a list. holes :: [a] -> [(a, [a])] -- | Check whether a list is sorted. -- -- Assumes that the Ord instance implements a partial order. sorted :: Ord a => [a] -> Bool -- | Check whether all elements in a list are distinct from each other. -- Assumes that the Eq instance stands for an equivalence -- relation. distinct :: Eq a => [a] -> Bool -- | An optimised version of distinct. -- -- Precondition: The list's length must fit in an Int. fastDistinct :: Ord a => [a] -> Bool prop_distinct_fastDistinct :: [Integer] -> Bool -- | Checks if all the elements in the list are equal. Assumes that the -- Eq instance stands for an equivalence relation. allEqual :: Eq a => [a] -> Bool -- | Returns an (arbitrary) representative for each list element that -- occurs more than once. duplicates :: Ord a => [a] -> [a] -- | A variant of groupBy which applies the predicate to consecutive -- pairs. groupBy' :: (a -> a -> Bool) -> [a] -> [[a]] prop_groupBy' :: (Bool -> Bool -> Bool) -> [Bool] -> Property -- | groupOn f = groupBy ((==) `on` f) . -- sortBy (compare `on` f). groupOn :: Ord b => (a -> b) -> [a] -> [[a]] -- | splitExactlyAt n xs = Just (ys, zs) iff xs = ys ++ -- zs and genericLength ys = n. splitExactlyAt :: Integral n => n -> [a] -> Maybe ([a], [a]) -- | extractNthElement n xs gives the n-th element -- in xs (counting from 0), plus the remaining elements -- (preserving order). extractNthElement' :: Integral i => i -> [a] -> ([a], a, [a]) extractNthElement :: Integral i => i -> [a] -> (a, [a]) prop_extractNthElement :: Integer -> [Integer] -> Property -- | A generalised variant of elemIndex. genericElemIndex :: (Eq a, Integral i) => a -> [a] -> Maybe i prop_genericElemIndex :: Integer -> [Integer] -> Property -- | Requires both lists to have the same length. zipWith' :: (a -> b -> c) -> [a] -> [b] -> [c] prop_zipWith' :: (Integer -> Integer -> Integer) -> Property -- | Efficient variant of nubBy for finite lists. -- -- Specification: -- --
-- nubOn f xs == 'nubBy' ((==) `'on'` f) xs. --nubOn :: Ord b => (a -> b) -> [a] -> [a] prop_nubOn :: (Integer -> Integer) -> [Integer] -> Bool -- | Efficient variant of nubBy for finite lists. -- -- Specification: For each list xs there is a list ys -- which is a permutation of xs such that -- --
-- uniqOn f xs == 'nubBy' ((==) `'on'` f) ys. ---- -- Furthermore -- --
-- sortBy (compare `on` f) (uniqOn f xs) == uniqOn f xs. --uniqOn :: Ord b => (a -> b) -> [a] -> [a] prop_uniqOn1 :: (Integer -> Integer) -> [Integer] -> Bool prop_uniqOn2 :: (Integer -> Integer) -> [Integer] -> Bool -- | Compute the common suffix of two lists. commonSuffix :: Eq a => [a] -> [a] -> [a] -- | Compute the common prefix of two lists. commonPrefix :: Eq a => [a] -> [a] -> [a] prop_commonPrefix :: [Integer] -> [Integer] -> [Integer] -> Bool prop_commonSuffix :: [Integer] -> [Integer] -> [Integer] -> Bool editDistanceSpec :: Eq a => [a] -> [a] -> Int editDistance :: Eq a => [a] -> [a] -> Int prop_editDistance :: Property tests :: IO Bool module Agda.Utils.Monad -- | Binary bind. (==<<) :: Monad m => (a -> b -> m c) -> (m a, m b) -> m c -- | when_ is just Control.Monad.when with a more general -- type. when_ :: Monad m => Bool -> m a -> m () -- | unless_ is just Control.Monad.unless with a more -- general type. unless_ :: Monad m => Bool -> m a -> m () whenM :: Monad m => m Bool -> m a -> m () unlessM :: Monad m => m Bool -> m a -> m () -- | Monadic if-then-else. ifM :: Monad m => m Bool -> m a -> m a -> m a -- |
-- ifNotM mc = ifM (not $ mc) --ifNotM :: Monad m => m Bool -> m a -> m a -> m a -- | Lazy monadic conjunction. and2M :: Monad m => m Bool -> m Bool -> m Bool andM :: (Foldable f, Monad m) => f (m Bool) -> m Bool allM :: (Functor f, Foldable f, Monad m) => f a -> (a -> m Bool) -> m Bool -- | Lazy monadic disjunction. or2M :: Monad m => m Bool -> m Bool -> m Bool orM :: (Foldable f, Monad m) => f (m Bool) -> m Bool anyM :: (Functor f, Foldable f, Monad m) => f a -> (a -> m Bool) -> m Bool -- | Lazy monadic disjunction with Either truth values. altM1 :: Monad m => (a -> m (Either err b)) -> [a] -> m (Either err b) -- | Generalized version of mapM_ :: Monad m => (a -> m ()) -> -- [a] -> m () Executes effects and collects results in -- left-to-right order. Works best with left-associative monoids. -- -- Note that there is an alternative -- --
-- mapM' f t = foldr mappend mempty $ mapM f t ---- -- that collects results in right-to-left order (effects still -- left-to-right). It might be preferable for right associative monoids. mapM' :: (Foldable t, Monad m, Monoid b) => (a -> m b) -> t a -> m b -- | Generalized version of forM_ :: Monad m => [a] -> (a -> m -- ()) -> m () forM' :: (Foldable t, Monad m, Monoid b) => t a -> (a -> m b) -> m b type Cont r a = (a -> r) -> r -- | mapM for the continuation monad. Terribly useful. thread :: (a -> Cont r b) -> [a] -> Cont r [b] -- | Requires both lists to have the same lengths. zipWithM' :: Monad m => (a -> b -> m c) -> [a] -> [b] -> m [c] -- | A monadic version of mapMaybe :: (a -> Maybe b) -> -- [a] -> [b]. mapMaybeM :: Monad m => (a -> m (Maybe b)) -> [a] -> m [b] -- | The for version of mapMaybeM. forMaybeM :: Monad m => [a] -> (a -> m (Maybe b)) -> m [b] -- | A monadic version of dropWhile :: (a -> Bool) -> [a] -- -> [a]. dropWhileM :: Monad m => (a -> m Bool) -> [a] -> m [a] -- | Finally for the Error class. Errors in the finally part take -- precedence over prior errors. finally :: MonadError e m => m a -> m b -> m a -- | Bracket without failure. Typically used to preserve state. bracket_ :: Monad m => m a -> (a -> m c) -> m b -> m b -- | Restore state after computation. localState :: MonadState s m => m a -> m a readM :: (Error e, MonadError e m, Read a) => String -> m a -- | Conditional execution of Applicative expressions. For example, -- --
-- when debug (putStrLn "Debugging") ---- -- will output the string Debugging if the Boolean value -- debug is True, and otherwise do nothing. when :: Applicative f => Bool -> f () -> f () -- | The reverse of when. unless :: Applicative f => Bool -> f () -> f () -- | Monads that also support choice and failure. class (Alternative m, Monad m) => MonadPlus (m :: * -> *) -- | the identity of mplus. It should also satisfy the equations -- --
-- mzero >>= f = mzero -- v >> mzero = mzero --mzero :: MonadPlus m => m a -- | an associative operation mplus :: MonadPlus m => m a -> m a -> m a -- | An infix synonym for fmap. -- -- The name of this operator is an allusion to $. Note the -- similarities between their types: -- --
-- ($) :: (a -> b) -> a -> b -- (<$>) :: Functor f => (a -> b) -> f a -> f b ---- -- Whereas $ is function application, <$> is -- function application lifted over a Functor. -- --
-- >>> show <$> Nothing -- Nothing -- -- >>> show <$> Just 3 -- Just "3" ---- -- Convert from an Either Int Int to -- an Either Int String using -- show: -- --
-- >>> show <$> Left 17 -- Left 17 -- -- >>> show <$> Right 17 -- Right "17" ---- -- Double each element of a list: -- --
-- >>> (*2) <$> [1,2,3] -- [2,4,6] ---- -- Apply even to the second element of a pair: -- --
-- >>> even <$> (2,2) -- (2,True) --(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 <$> -- | Sequential application. (<*>) :: Applicative f => forall a b. f (a -> b) -> f a -> f b -- | Replace all locations in the input with the same value. The default -- definition is fmap . const, but this may be -- overridden with a more efficient version. (<$) :: Functor f => forall a b. a -> f b -> f a -- | A variant of modify in which the computation is strict in the -- new state. modify' :: MonadState s m => (s -> s) -> m () -- | Parser combinators with support for left recursion, following -- Johnson's "Memoization in Top-Down Parsing". -- -- This implementation is based on an implementation due to Atkey -- (attached to an edlambda-members mailing list message from 2011-02-15 -- titled 'Slides for "Introduction to Parser Combinators"'). -- -- Note that non-memoised left recursion is not guaranteed to work. -- -- The code contains an important deviation from Johnson's paper: the -- check for subsumed results is not included. This means that one can -- get the same result multiple times when parsing using ambiguous -- grammars. As an example, parsing the empty string using S ∷= ε | -- ε succeeds twice. This change also means that parsing fails to -- terminate for some cyclic grammars that would otherwise be handled -- successfully, such as S ∷= S | ε. However, the library is not -- intended to handle infinitely ambiguous grammars. (It is unclear to -- the author of this module whether the change leads to more -- non-termination for grammars that are not cyclic.) module Agda.Utils.Parser.MemoisedCPS -- | The parser type. -- -- The parameters of the type Parser k r tok a have the -- following meanings: -- --
-- > putStrLn $ show "\x2200" -- "\8704" -- > putStrLn $ quote "\x2200" -- "∀" ---- -- (The code examples above have been tested using version 4.2.0.0 of the -- base library.) quote :: String -> String -- | Shows a non-negative integer using the characters ₀-₉ instead of 0-9. showIndex :: (Show i, Integral i) => i -> String -- | Adds a final newline if there is not already one. addFinalNewLine :: String -> String -- | Indents every line the given number of steps. indent :: Integral i => i -> String -> String newtype Str Str :: String -> Str [unStr] :: Str -> String -- | Show a number using comma to separate powers of 1,000. showThousandSep :: Show a => a -> String -- | Remove leading whitespace. ltrim :: String -> String -- | Remove trailing whitespace. rtrim :: String -> String -- | Remove leading and trailing whitesapce. trim :: String -> String instance GHC.Classes.Eq Agda.Utils.String.Str instance GHC.Show.Show Agda.Utils.String.Str -- | Time-related utilities. module Agda.Utils.Time -- | Timestamps. type ClockTime = UTCTime -- | The current time. getClockTime :: IO ClockTime getCPUTime :: MonadIO m => m CPUTime -- | Measure the time of a computation. Of course, does not work with -- exceptions. measureTime :: MonadIO m => m a -> m (a, CPUTime) -- | CPU time in pico (10^-12) seconds. newtype CPUTime CPUTime :: Integer -> CPUTime instance GHC.Real.Integral Agda.Utils.Time.CPUTime instance GHC.Enum.Enum Agda.Utils.Time.CPUTime instance GHC.Real.Real Agda.Utils.Time.CPUTime instance GHC.Num.Num Agda.Utils.Time.CPUTime instance GHC.Classes.Ord Agda.Utils.Time.CPUTime instance GHC.Show.Show Agda.Utils.Time.CPUTime instance GHC.Classes.Eq Agda.Utils.Time.CPUTime instance Agda.Utils.Pretty.Pretty Agda.Utils.Time.CPUTime -- | Overloaded null and empty for collections and -- sequences. module Agda.Utils.Null class Null a where null = (== empty) empty :: Null a => a -- | Satisfying null empty == True. null :: Null a => a -> Bool -- | Satisfying null empty == True. null :: (Null a, Eq a) => a -> Bool -- | A Maybe is null when it corresponds to the empty list. ifNull :: (Null a) => a -> b -> (a -> b) -> b ifNullM :: (Monad m, Null a) => m a -> m b -> (a -> m b) -> m b whenNull :: (Monad m, Null a) => a -> m () -> m () unlessNull :: (Monad m, Null a) => a -> (a -> m ()) -> m () whenNullM :: (Monad m, Null a) => m a -> m () -> m () unlessNullM :: (Monad m, Null a) => m a -> (a -> m ()) -> m () instance Agda.Utils.Null.Null () instance (Agda.Utils.Null.Null a, Agda.Utils.Null.Null b) => Agda.Utils.Null.Null (a, b) instance Agda.Utils.Null.Null Data.ByteString.Internal.ByteString instance Agda.Utils.Null.Null [a] instance Agda.Utils.Null.Null (Agda.Utils.Bag.Bag a) instance Agda.Utils.Null.Null (Data.IntMap.Base.IntMap a) instance Agda.Utils.Null.Null Data.IntSet.Base.IntSet instance Agda.Utils.Null.Null (Data.Map.Base.Map k a) instance Agda.Utils.Null.Null (Data.HashMap.Base.HashMap k a) instance Agda.Utils.Null.Null (Data.HashSet.HashSet a) instance Agda.Utils.Null.Null (Data.Sequence.Seq a) instance Agda.Utils.Null.Null (Data.Set.Base.Set a) instance Agda.Utils.Null.Null (GHC.Base.Maybe a) instance Agda.Utils.Null.Null Text.PrettyPrint.HughesPJ.Doc -- | Maintaining a list of favorites of some partially ordered type. Only -- the best elements are kept. -- -- To avoid name clashes, import this module qualified, as in import -- Agda.Utils.Favorites (Favorites) import qualified Agda.Utils.Favorites -- as Fav module Agda.Utils.Favorites -- | A list of incomparable favorites. newtype Favorites a Favorites :: [a] -> Favorites a [toList] :: Favorites a -> [a] -- | Equality checking is a bit expensive, since we need to sort! Maybe use -- a Set of favorites in the first place? -- | Result of comparing a candidate with the current favorites. data CompareResult a -- | Great, you are dominating a possibly (empty list of favorites) but -- there is also a rest that is not dominated. If null -- dominated, then notDominated is necessarily the complete -- list of favorites. Dominates :: [a] -> [a] -> CompareResult a [dominated] :: CompareResult a -> [a] [notDominated] :: CompareResult a -> [a] -- | Sorry, but you are dominated by that favorite. IsDominated :: a -> CompareResult a [dominator] :: CompareResult a -> a -- | Gosh, got some pretty a here, compare with my current -- favorites! Discard it if there is already one that is better or equal. -- (Skewed conservatively: faithful to the old favorites.) If there is no -- match for it, add it, and dispose of all that are worse than -- a. -- -- We require a partial ordering. Less is better! (Maybe paradoxically.) compareWithFavorites :: PartialOrd a => a -> Favorites a -> CompareResult a -- | Compare a new set of favorites to an old one and discard the new -- favorites that are dominated by the old ones and vice verse. (Skewed -- conservatively: faithful to the old favorites.) -- --
-- compareFavorites new old = (new', old') --compareFavorites :: PartialOrd a => Favorites a -> Favorites a -> (Favorites a, Favorites a) unionCompared :: (Favorites a, Favorites a) -> Favorites a -- | After comparing, do the actual insertion. insertCompared :: a -> Favorites a -> CompareResult a -> Favorites a -- | Compare, then insert accordingly. insert a l = insertCompared a l -- (compareWithFavorites a l) insert :: PartialOrd a => a -> Favorites a -> Favorites a -- | Insert all the favorites from the first list into the second. union :: PartialOrd a => Favorites a -> Favorites a -> Favorites a -- | Construct favorites from elements of a partial order. The result -- depends on the order of the list if it contains equal elements, since -- earlier seen elements are favored over later seen equals. The first -- element of the list is seen first. fromList :: PartialOrd a => [a] -> Favorites a -- | Favorites forms a Monoid under empty and 'union. property_null_empty :: Bool property_not_null_singleton :: forall a. a -> Bool prop_compareWithFavorites :: ISet -> Favorites ISet -> Bool prop_fromList_after_toList :: Favorites ISet -> Bool -- | A second way to compute the union is to use -- compareFavorites. prop_union_union2 :: Favorites ISet -> Favorites ISet -> Bool -- | All tests as collected by quickCheckAll. -- -- Using quickCheckAll is convenient and superior to the manual -- enumeration of tests, since the name of the property is added -- automatically. tests :: IO Bool instance Agda.Utils.Singleton.Singleton a (Agda.Utils.Favorites.Favorites a) instance Agda.Utils.Null.Null (Agda.Utils.Favorites.Favorites a) instance Test.QuickCheck.Arbitrary.CoArbitrary a => Test.QuickCheck.Arbitrary.CoArbitrary (Agda.Utils.Favorites.Favorites a) instance GHC.Show.Show a => GHC.Show.Show (Agda.Utils.Favorites.Favorites a) instance Data.Foldable.Foldable Agda.Utils.Favorites.Favorites instance GHC.Classes.Ord a => GHC.Classes.Eq (Agda.Utils.Favorites.Favorites a) instance Agda.Utils.PartialOrd.PartialOrd a => GHC.Base.Monoid (Agda.Utils.Favorites.Favorites a) instance (Agda.Utils.PartialOrd.PartialOrd a, Test.QuickCheck.Arbitrary.Arbitrary a) => Test.QuickCheck.Arbitrary.Arbitrary (Agda.Utils.Favorites.Favorites a) -- | Directed graphs (can of course simulate undirected graphs). -- -- Represented as adjacency maps in direction from source to target. -- -- Each source node maps to a adjacency map of outgoing edges, which is a -- map from target nodes to edges. -- -- This allows to get outgoing edges in O(log n) time where n is -- the number of nodes in the graph. -- -- However, the set of incoming edges can only be obtained in O(n log -- n) or O(e) where e is the total number of -- edges. module Agda.Utils.Graph.AdjacencyMap.Unidirectional -- | Graph s t e is a directed graph with source nodes in -- s target nodes in t and edges in e. -- -- Admits at most one edge between any two nodes. Several edges can be -- modeled by using a collection type for e. -- -- Represented as "adjacency list", or rather, adjacency map. This allows -- to get all outgoing edges for a node in O(log n) time where -- n is the number of nodes of the graph. -- -- Incoming edges can only be computed in O(n + e) time where -- e is the number of edges. newtype Graph s t e Graph :: Map s (Map t e) -> Graph s t e -- | Forward edges. [graph] :: Graph s t e -> Map s (Map t e) data Edge s t e Edge :: s -> t -> e -> Edge s t e -- | Outgoing node. [source] :: Edge s t e -> s -- | Incoming node. [target] :: Edge s t e -> t -- | Edge label (weight). [label] :: Edge s t e -> e -- | Reverse an edge. transposeEdge :: Edge s t e -> Edge t s e -- | Turn a graph into a list of edges. O(n + e) edges :: Graph s t e -> [Edge s t e] -- | All edges originating in the given nodes. (I.e., all outgoing edges -- for the given nodes.) -- -- Roughly linear in the length of the result list O(result). edgesFrom :: Ord s => Graph s t e -> [s] -> [Edge s t e] -- | All edges ending in the given nodes. (I.e., all incoming edges for the -- given nodes.) -- -- Expensive: O(n * |ts| * log n). edgesTo :: Ord t => Graph s t e -> [t] -> [Edge s t e] -- | Get all self-loops. diagonal :: (Ord n) => Graph n n e -> [Edge n n e] -- | Lookup label of an edge. lookup :: (Ord s, Ord t) => s -> t -> Graph s t e -> Maybe e -- | Get a list of outgoing edges with target. neighbours :: Ord s => s -> Graph s t e -> [(t, e)] -- | Get a list of outgoing edges with target. neighboursMap :: Ord s => s -> Graph s t e -> Map t e -- | Returns all the nodes with outgoing edges. O(n). sourceNodes :: Graph s t e -> Set s -- | Returns all the nodes with incoming edges. Expensive! O(e). targetNodes :: Ord t => Graph s t e -> Set t -- | For homogeneous graphs, (s = t) we can compute a set of all -- nodes. -- -- Structure Nodes is for computing all nodes but also -- remembering which were incoming and which outgoing. This is mostly for -- efficiency reasons, to avoid recomputation when all three sets are -- needed. data Nodes n Nodes :: Set n -> Set n -> Set n -> Nodes n [srcNodes] :: Nodes n -> Set n [tgtNodes] :: Nodes n -> Set n [allNodes] :: Nodes n -> Set n computeNodes :: (Ord n) => Graph n n e -> Nodes n -- | The set of all nodes (outgoing and incoming). nodes :: (Ord n) => Graph n n e -> Set n -- | Constructs a completely disconnected graph containing the given nodes. -- O(n). fromNodes :: Ord n => [n] -> Graph n n e -- | Constructs a graph from a list of edges. O(e log n) -- -- Later edges overwrite earlier edges. fromList :: (Ord s, Ord t) => [Edge s t e] -> Graph s t e -- | Constructs a graph from a list of edges. O(e log n) -- -- Later edges are combined with earlier edges using the supplied -- function. fromListWith :: (Ord s, Ord t) => (e -> e -> e) -> [Edge s t e] -> Graph s t e -- | Convert a graph into a list of edges. O(e) toList :: Graph s t e -> [Edge s t e] -- | Check whether the graph is discrete (no edges). This could be seen as -- an empty graph. Worst-case (is discrete): O(e). discrete :: Null e => Graph s t e -> Bool -- | Removes Null edges (and empty Maps). clean :: Null e => Graph s t e -> Graph s t e -- | Empty graph (no nodes, no edges). empty :: Graph s t e -- | A graph with two nodes and a single connecting edge. singleton :: s -> t -> e -> Graph s t e -- | Insert an edge into the graph. insert :: (Ord s, Ord t) => s -> t -> e -> Graph s t e -> Graph s t e -- | Insert an edge, possibly combining old edge weight with -- new weight by given function f into f new -- old. insertWith :: (Ord s, Ord t) => (e -> e -> e) -> s -> t -> e -> Graph s t e -> Graph s t e insertEdge :: (Ord s, Ord t) => Edge s t e -> Graph s t e -> Graph s t e insertEdgeWith :: (Ord s, Ord t) => (e -> e -> e) -> Edge s t e -> Graph s t e -> Graph s t e -- | Left-biased union. union :: (Ord s, Ord t) => Graph s t e -> Graph s t e -> Graph s t e unionWith :: (Ord s, Ord t) => (e -> e -> e) -> Graph s t e -> Graph s t e -> Graph s t e unions :: (Ord s, Ord t) => [Graph s t e] -> Graph s t e unionsWith :: (Ord s, Ord t) => (e -> e -> e) -> [Graph s t e] -> Graph s t e -- | Removes the given node, be it source or target, and all corresponding -- edges, from the graph. -- -- Expensive! O(n log n). removeNode :: Ord n => n -> Graph n n e -> Graph n n e -- | removeEdge s t g removes the edge going from s to -- t, if any. -- -- O((log n)^2). removeEdge :: (Ord s, Ord t) => s -> t -> Graph s t e -> Graph s t e -- | Keep only the edges that satisfy the predicate. O(e). filterEdges :: (e -> Bool) -> Graph s t e -> Graph s t e -- | Unzipping a graph (naive implementation using fmap). unzip :: Graph s t (e, e') -> (Graph s t e, Graph s t e') -- | Maps over a graph under availability of positional information, like -- mapWithKey. mapWithEdge :: (Edge s t e -> e') -> Graph s t e -> Graph s t e' -- | The graph's strongly connected components, in reverse topological -- order. sccs' :: Ord n => Graph n n e -> [SCC n] -- | The graph's strongly connected components, in reverse topological -- order. sccs :: Ord n => Graph n n e -> [[n]] -- | SCC DAGs. -- -- The maps map SCC indices to and from SCCs/nodes. data DAG n DAG :: Graph -> IntMap (SCC n) -> Map n Int -> DAG n [dagGraph] :: DAG n -> Graph [dagComponentMap] :: DAG n -> IntMap (SCC n) [dagNodeMap] :: DAG n -> Map n Int -- | DAG invariant. dagInvariant :: Ord n => DAG n -> Bool -- | The opposite DAG. oppositeDAG :: DAG n -> DAG n -- | The nodes reachable from the given SCC. reachable :: Ord n => DAG n -> SCC n -> [n] -- | Constructs a DAG containing the graph's strongly connected components. sccDAG' :: forall n e. Ord n => Graph n n e -> [SCC n] -> DAG n -- | Constructs a DAG containing the graph's strongly connected components. sccDAG :: Ord n => Graph n n e -> DAG n -- | Returns True iff the graph is acyclic. acyclic :: Ord n => Graph n n e -> Bool -- | reachableFrom g n is a map containing all nodes reachable -- from n in g. For each node a simple path to the node -- is given, along with its length (the number of edges). The paths are -- as short as possible (in terms of the number of edges). -- -- Precondition: n must be a node in g. The number of -- nodes in the graph must not be larger than maxBound :: -- Int. -- -- Amortised time complexity (assuming that comparisons take constant -- time): O(e log n), if the lists are not inspected. Inspection -- of a prefix of a list is linear in the length of the prefix. reachableFrom :: Ord n => Graph n n e -> n -> Map n (Int, [Edge n n e]) -- | walkSatisfying every some g from to determines if there is a -- walk from from to to in g, in which every -- edge satisfies the predicate every, and some edge satisfies -- the predicate some. If there are several such walks, then a -- shortest one (in terms of the number of edges) is returned. -- -- Precondition: from and to must be nodes in -- g. The number of nodes in the graph must not be larger than -- maxBound :: Int. -- -- Amortised time complexity (assuming that comparisons and the -- predicates take constant time to compute): O(e log n). walkSatisfying :: Ord n => (e -> Bool) -> (e -> Bool) -> Graph n n e -> n -> n -> Maybe [Edge n n e] -- | composeWith times plus g g' finds all edges s --c_i--> -- t_i --d_i--> u and constructs the result graph from -- edge(s,u) = sum_i (c_i times d_i). -- -- Complexity: for each edge s --> t in g we lookup -- up all edges starting in with t in g'. composeWith :: (Ord t, Ord u) => (c -> d -> e) -> (e -> e -> e) -> Graph s t c -> Graph t u d -> Graph s u e -- | Transitive closure ported from Agda.Termination.CallGraph. -- -- Relatively efficient, see Issue 1560. complete :: (Eq e, Null e, SemiRing e, Ord n) => Graph n n e -> Graph n n e -- | Computes the transitive closure of the graph. -- -- Uses the Gauss-Jordan-Floyd-Warshall-McNaughton-Yamada algorithm (as -- described by Russell O'Connor in "A Very General Method of Computing -- Shortest Paths" http://r6.ca/blog/20110808T035622Z.html), -- implemented using matrices. -- -- The resulting graph does not contain any zero edges. -- -- This algorithm should be seen as a reference implementation. In -- practice gaussJordanFloydWarshallMcNaughtonYamada is likely to -- be more efficient. gaussJordanFloydWarshallMcNaughtonYamadaReference :: forall n e. (Ord n, Eq e, StarSemiRing e) => Graph n n e -> Graph n n e -- | Computes the transitive closure of the graph. -- -- Uses the Gauss-Jordan-Floyd-Warshall-McNaughton-Yamada algorithm (as -- described by Russell O'Connor in "A Very General Method of Computing -- Shortest Paths" http://r6.ca/blog/20110808T035622Z.html), -- implemented using Graph, and with some shortcuts: -- --
-- filterMaybe p a = listToMaybe (filter p [a]) --filterMaybe :: (a -> Bool) -> a -> Maybe a -- | Version of mapMaybe with different argument ordering. forMaybe :: [a] -> (a -> Maybe b) -> [b] -- | Version of maybe with different argument ordering. Often, we -- want to case on a Maybe, do something interesting in the -- Just case, but only a default action in the Nothing -- case. Then, the argument ordering of caseMaybe is preferable. -- --
-- caseMaybe m err f = flip (maybe err) m f --caseMaybe :: Maybe a -> b -> (a -> b) -> b -- | Monadic version of maybe. maybeM :: Monad m => m b -> (a -> m b) -> m (Maybe a) -> m b -- | Monadic version of fromMaybe. fromMaybeM :: Monad m => m a -> m (Maybe a) -> m a -- | Monadic version of caseMaybe. That is, maybeM with a -- different argument ordering. caseMaybeM :: Monad m => m (Maybe a) -> m b -> (a -> m b) -> m b -- | caseMaybeM with flipped branches. ifJustM :: Monad m => m (Maybe a) -> (a -> m b) -> m b -> m b -- | A more telling name for forM for the Maybe collection -- type. Or: caseMaybe without the Nothing case. whenJust :: Monad m => Maybe a -> (a -> m ()) -> m () -- | caseMaybeM without the Nothing case. whenJustM :: Monad m => m (Maybe a) -> (a -> m ()) -> m () instance Data.Data.Data a => Data.Data.Data (Data.Strict.Maybe.Maybe a) instance GHC.Generics.Generic (Data.Strict.Maybe.Maybe a) instance Agda.Utils.Null.Null (Data.Strict.Maybe.Maybe a) instance GHC.Base.Monoid a => GHC.Base.Monoid (Data.Strict.Maybe.Maybe a) instance Data.Foldable.Foldable Data.Strict.Maybe.Maybe instance Data.Traversable.Traversable Data.Strict.Maybe.Maybe instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Data.Strict.Maybe.Maybe a) instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Data.Strict.Maybe.Maybe a) instance Test.QuickCheck.Arbitrary.Arbitrary a => Test.QuickCheck.Arbitrary.Arbitrary (Data.Strict.Maybe.Maybe a) instance Test.QuickCheck.Arbitrary.CoArbitrary a => Test.QuickCheck.Arbitrary.CoArbitrary (Data.Strict.Maybe.Maybe a) -- | Collection size. -- -- For TermSize see Agda.Syntax.Internal. module Agda.Utils.Size -- | The size of a collection (i.e., its length). -- -- Should fit into an Int. TODO: change to Int. class Sized a size :: (Sized a, Integral n) => a -> n -- | Thing decorated with its size. The thing should fit into main memory, -- thus, the size is an Int. data SizedThing a SizedThing :: !Int -> a -> SizedThing a [theSize] :: SizedThing a -> !Int [sizedThing] :: SizedThing a -> a -- | Cache the size of an object. sizeThing :: Sized a => a -> SizedThing a instance Agda.Utils.Size.Sized [a] instance Agda.Utils.Size.Sized (Data.IntMap.Base.IntMap a) instance Agda.Utils.Size.Sized Data.IntSet.Base.IntSet instance Agda.Utils.Size.Sized (Data.Map.Base.Map k a) instance Agda.Utils.Size.Sized (Data.Set.Base.Set a) instance Agda.Utils.Size.Sized (Data.HashMap.Base.HashMap k a) instance Agda.Utils.Size.Sized (Data.HashSet.HashSet a) instance Agda.Utils.Size.Sized (Data.Sequence.Seq a) instance Agda.Utils.Size.Sized (Agda.Utils.Size.SizedThing a) instance Agda.Utils.Null.Null a => Agda.Utils.Null.Null (Agda.Utils.Size.SizedThing a) -- | Strict tries (based on Data.Map.Strict and -- Agda.Utils.Maybe.Strict). module Agda.Utils.Trie -- | Finite map from [k] to v. -- -- With the strict Maybe type, Trie is also strict in -- v. data Trie k v empty :: Null a => a -- | Singleton trie. singleton :: [k] -> v -> Trie k v -- | everyPrefix k v is a trie where every prefix of k -- (including k itself) is mapped to v. everyPrefix :: [k] -> v -> Trie k v -- | Insert. Overwrites existing value if present. -- --
-- insert = insertWith ( new old -> new) --insert :: (Ord k) => [k] -> v -> Trie k v -> Trie k v -- | Insert with function merging new value with old value. insertWith :: (Ord k) => (v -> v -> v) -> [k] -> v -> Trie k v -> Trie k v -- | Left biased union. -- -- union = unionWith ( new old -> new). union :: (Ord k) => Trie k v -> Trie k v -> Trie k v -- | Pointwise union with merge function for values. unionWith :: (Ord k) => (v -> v -> v) -> Trie k v -> Trie k v -> Trie k v -- | Adjust value at key, leave subtree intact. adjust :: Ord k => [k] -> (Maybe v -> Maybe v) -> Trie k v -> Trie k v -- | Delete value at key, but leave subtree intact. delete :: Ord k => [k] -> Trie k v -> Trie k v -- | Convert to ascending list. toList :: Ord k => Trie k v -> [([k], v)] -- | Convert to ascending list. toAscList :: Ord k => Trie k v -> [([k], v)] -- | Returns the value associated with the given key, if any. lookup :: Ord k => [k] -> Trie k v -> Maybe v -- | Is the given key present in the trie? member :: Ord k => [k] -> Trie k v -> Bool -- | Collect all values along a given path. lookupPath :: Ord k => [k] -> Trie k v -> [v] -- | All tests. tests :: IO Bool instance GHC.Show.Show Agda.Utils.Trie.Model instance GHC.Classes.Eq Agda.Utils.Trie.Model instance GHC.Classes.Eq Agda.Utils.Trie.Val instance GHC.Classes.Ord Agda.Utils.Trie.Key instance GHC.Classes.Eq Agda.Utils.Trie.Key instance (GHC.Classes.Eq k, GHC.Classes.Eq v) => GHC.Classes.Eq (Agda.Utils.Trie.Trie k v) instance (GHC.Show.Show k, GHC.Show.Show v) => GHC.Show.Show (Agda.Utils.Trie.Trie k v) instance Agda.Utils.Null.Null (Agda.Utils.Trie.Trie k v) instance GHC.Show.Show Agda.Utils.Trie.Key instance GHC.Show.Show Agda.Utils.Trie.Val instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Utils.Trie.Key instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Utils.Trie.Val instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Utils.Trie.Model -- | Tools for benchmarking and accumulating results. Nothing Agda-specific -- in here. module Agda.Utils.Benchmark -- | Account we can bill computation time to. type Account a = [a] -- | Record when we started billing the current account. type CurrentAccount a = Maybe (Account a, CPUTime) type Timings a = Trie a CPUTime -- | Benchmark structure is a trie, mapping accounts (phases and subphases) -- to CPU time spent on their performance. data Benchmark a Benchmark :: !Bool -> !(CurrentAccount a) -> !(Timings a) -> Benchmark a -- | Are we benchmarking at all? [benchmarkOn] :: Benchmark a -> !Bool -- | What are we billing to currently? [currentAccount] :: Benchmark a -> !(CurrentAccount a) -- | The accounts and their accumulated timing bill. [timings] :: Benchmark a -> !(Timings a) -- | Initial benchmark structure (empty). -- | Semantic editor combinator. mapBenchmarkOn :: (Bool -> Bool) -> Benchmark a -> Benchmark a -- | Semantic editor combinator. mapCurrentAccount :: (CurrentAccount a -> CurrentAccount a) -> Benchmark a -> Benchmark a -- | Semantic editor combinator. mapTimings :: (Timings a -> Timings a) -> Benchmark a -> Benchmark a -- | Add to specified CPU time account. addCPUTime :: Ord a => Account a -> CPUTime -> Benchmark a -> Benchmark a -- | Print benchmark as two-column table with totals. -- | Monad with access to benchmarking data. class (Ord a, Functor m, MonadIO m) => MonadBench a m | m -> a where getsBenchmark f = f <$> getBenchmark putBenchmark b = modifyBenchmark $ const b modifyBenchmark f = do { b <- getBenchmark; putBenchmark $! f b } getBenchmark :: MonadBench a m => m (Benchmark a) getsBenchmark :: MonadBench a m => (Benchmark a -> c) -> m c putBenchmark :: MonadBench a m => Benchmark a -> m () modifyBenchmark :: MonadBench a m => (Benchmark a -> Benchmark a) -> m () -- | We need to be able to terminate benchmarking in case of an exception. finally :: MonadBench a m => m b -> m c -> m b -- | Turn benchmarking on/off. setBenchmarking :: MonadBench a m => Bool -> m () -- | Bill current account with time up to now. Switch to new account. -- Return old account (if any). switchBenchmarking :: MonadBench a m => Maybe (Account a) -> m (Maybe (Account a)) -- | Resets the account and the timing information. reset :: MonadBench a m => m () -- | Bill a computation to a specific account. Works even if the -- computation is aborted by an exception. billTo :: MonadBench a m => Account a -> m c -> m c -- | Bill a pure computation to a specific account. billPureTo :: MonadBench a m => Account a -> c -> m c instance Agda.Utils.Null.Null (Agda.Utils.Benchmark.Benchmark a) instance (GHC.Classes.Ord a, Agda.Utils.Pretty.Pretty a) => Agda.Utils.Pretty.Pretty (Agda.Utils.Benchmark.Benchmark a) instance Agda.Utils.Benchmark.MonadBench a m => Agda.Utils.Benchmark.MonadBench a (Control.Monad.Trans.Reader.ReaderT r m) instance Agda.Utils.Benchmark.MonadBench a m => Agda.Utils.Benchmark.MonadBench a (Control.Monad.Trans.State.Lazy.StateT r m) -- | Additional functions for association lists. module Agda.Utils.AssocList -- | A finite map, represented as a set of pairs. -- -- Invariant: at most one value per key. type AssocList k v = [(k, v)] -- | O(n). Reexport lookup. lookup :: Eq k => k -> AssocList k v -> Maybe v -- | O(n). Get the domain (list of keys) of the finite map. keys :: AssocList k v -> [k] -- | O(1). Add a new binding. Assumes the binding is not yet in the list. insert :: k -> v -> AssocList k v -> AssocList k v -- | O(n). Update the value at a key. The key must be in the domain of the -- finite map. Otherwise, an internal error is raised. update :: Eq k => k -> v -> AssocList k v -> AssocList k v -- | O(n). Update the value at a key with a certain function. The key must -- be in the domain of the finite map. Otherwise, an internal error is -- raised. updateAt :: Eq k => k -> (v -> v) -> AssocList k v -> AssocList k v -- | O(n). Map over an association list, preserving the order. mapWithKey :: (k -> v -> v) -> AssocList k v -> AssocList k v -- | O(n). If called with a effect-producing function, violation of the -- invariant could matter here (duplicating effects). mapWithKeyM :: Applicative m => (k -> v -> m v) -> AssocList k v -> m (AssocList k v) -- | O(n). Named in analogy to mapKeysMonotonic. To preserve the -- invariant, it is sufficient that the key transformation is injective -- (rather than monotonic). mapKeysMonotonic :: (k -> k') -> AssocList k v -> AssocList k' v module Agda.TypeChecking.SizedTypes.Utils debug :: Bool trace :: String -> a -> a traceM :: Applicative f => String -> f () class Eq a => Top a where isTop = (== top) top :: Top a => a isTop :: Top a => a -> Bool class Plus a b c plus :: Plus a b c => a -> b -> c class MeetSemiLattice a meet :: MeetSemiLattice a => a -> a -> a -- | Semiring with idempotent + == dioid class (MeetSemiLattice a, Top a) => Dioid a compose :: Dioid a => a -> a -> a unitCompose :: Dioid a => a instance Agda.TypeChecking.SizedTypes.Utils.Plus GHC.Types.Int GHC.Types.Int GHC.Types.Int -- | Syntax of size expressions and constraints. module Agda.TypeChecking.SizedTypes.Syntax -- | Constant finite sizes n >= 0. newtype Offset O :: Int -> Offset -- | Fixed size variables i. newtype Rigid RigidId :: String -> Rigid [rigidId] :: Rigid -> String -- | Size meta variables X to solve for. newtype Flex FlexId :: String -> Flex [flexId] :: Flex -> String -- | Size expressions appearing in constraints. data SizeExpr' rigid flex -- | Constant number n. Const :: Offset -> SizeExpr' rigid flex [offset] :: SizeExpr' rigid flex -> Offset -- | Variable plus offset i + n. Rigid :: rigid -> Offset -> SizeExpr' rigid flex [rigid] :: SizeExpr' rigid flex -> rigid [offset] :: SizeExpr' rigid flex -> Offset -- | Infinity ∞. Infty :: SizeExpr' rigid flex -- | Meta variable X + n. Flex :: flex -> Offset -> SizeExpr' rigid flex [flex] :: SizeExpr' rigid flex -> flex [offset] :: SizeExpr' rigid flex -> Offset type SizeExpr = SizeExpr' Rigid Flex -- | Comparison operator, e.g. for size expression. data Cmp -- | <. Lt :: Cmp -- | ≤. Le :: Cmp -- | Comparison operator is ordered Lt < Le. -- | Constraint: an inequation between size expressions, e.g. X < -- ∞ or i + 3 ≤ j. data Constraint' rigid flex Constraint :: SizeExpr' rigid flex -> Cmp -> SizeExpr' rigid flex -> Constraint' rigid flex [leftExpr] :: Constraint' rigid flex -> SizeExpr' rigid flex [cmp] :: Constraint' rigid flex -> Cmp [rightExpr] :: Constraint' rigid flex -> SizeExpr' rigid flex type Constraint = Constraint' Rigid Flex -- | What type of solution are we looking for? data Polarity Least :: Polarity Greatest :: Polarity -- | Assigning a polarity to a flexible variable. data PolarityAssignment flex PolarityAssignment :: Polarity -> flex -> PolarityAssignment flex -- | Type of solution wanted for each flexible. type Polarities flex = Map flex Polarity emptyPolarities :: Polarities flex polaritiesFromAssignments :: Ord flex => [PolarityAssignment flex] -> Polarities flex -- | Default polarity is Least. getPolarity :: Ord flex => Polarities flex -> flex -> Polarity -- | Partial substitution from flexible variables to size expression. type Solution rigid flex = Map flex (SizeExpr' rigid flex) -- | Executing a substitution. class Substitute r f a subst :: Substitute r f a => Solution r f -> a -> a -- | Add offset to size expression. type CTrans r f = Constraint' r f -> Either String [Constraint' r f] -- | Returns Nothing if we have a contradictory constraint. simplify1 :: (Show f, Show r, Eq r) => CTrans r f -> CTrans r f -- | Le acts as True, Lt as False. ifLe :: Cmp -> a -> a -> a -- | Interpret Cmp as relation on Offset. compareOffset :: Offset -> Cmp -> Offset -> Bool -- | Offsets + n must be non-negative class ValidOffset a validOffset :: ValidOffset a => a -> Bool -- | Make offsets non-negative by rounding up. class TruncateOffset a truncateOffset :: TruncateOffset a => a -> a -- | The rigid variables contained in a pice of syntax. class Rigids r a rigids :: Rigids r a => a -> Set r -- | The flexibe variables contained in a pice of syntax. class Flexs flex a | a -> flex flexs :: Flexs flex a => a -> Set flex instance GHC.Classes.Ord Agda.TypeChecking.SizedTypes.Syntax.Polarity instance GHC.Classes.Eq Agda.TypeChecking.SizedTypes.Syntax.Polarity instance Data.Traversable.Traversable (Agda.TypeChecking.SizedTypes.Syntax.Constraint' rigid) instance Data.Foldable.Foldable (Agda.TypeChecking.SizedTypes.Syntax.Constraint' rigid) instance GHC.Base.Functor (Agda.TypeChecking.SizedTypes.Syntax.Constraint' rigid) instance GHC.Enum.Enum Agda.TypeChecking.SizedTypes.Syntax.Cmp instance GHC.Enum.Bounded Agda.TypeChecking.SizedTypes.Syntax.Cmp instance GHC.Classes.Eq Agda.TypeChecking.SizedTypes.Syntax.Cmp instance Data.Traversable.Traversable (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' rigid) instance Data.Foldable.Foldable (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' rigid) instance GHC.Base.Functor (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' rigid) instance (GHC.Classes.Ord flex, GHC.Classes.Ord rigid) => GHC.Classes.Ord (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' rigid flex) instance (GHC.Classes.Eq flex, GHC.Classes.Eq rigid) => GHC.Classes.Eq (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' rigid flex) instance GHC.Classes.Ord Agda.TypeChecking.SizedTypes.Syntax.Flex instance GHC.Classes.Eq Agda.TypeChecking.SizedTypes.Syntax.Flex instance GHC.Classes.Ord Agda.TypeChecking.SizedTypes.Syntax.Rigid instance GHC.Classes.Eq Agda.TypeChecking.SizedTypes.Syntax.Rigid instance GHC.Enum.Enum Agda.TypeChecking.SizedTypes.Syntax.Offset instance GHC.Num.Num Agda.TypeChecking.SizedTypes.Syntax.Offset instance GHC.Classes.Ord Agda.TypeChecking.SizedTypes.Syntax.Offset instance GHC.Classes.Eq Agda.TypeChecking.SizedTypes.Syntax.Offset instance GHC.Show.Show Agda.TypeChecking.SizedTypes.Syntax.Offset instance Agda.TypeChecking.SizedTypes.Utils.MeetSemiLattice Agda.TypeChecking.SizedTypes.Syntax.Offset instance Agda.TypeChecking.SizedTypes.Utils.Plus Agda.TypeChecking.SizedTypes.Syntax.Offset Agda.TypeChecking.SizedTypes.Syntax.Offset Agda.TypeChecking.SizedTypes.Syntax.Offset instance Test.QuickCheck.Arbitrary.Arbitrary Agda.TypeChecking.SizedTypes.Syntax.Offset instance GHC.Show.Show Agda.TypeChecking.SizedTypes.Syntax.Rigid instance GHC.Show.Show Agda.TypeChecking.SizedTypes.Syntax.Flex instance Agda.TypeChecking.SizedTypes.Utils.Dioid Agda.TypeChecking.SizedTypes.Syntax.Cmp instance GHC.Classes.Ord Agda.TypeChecking.SizedTypes.Syntax.Cmp instance Agda.TypeChecking.SizedTypes.Utils.MeetSemiLattice Agda.TypeChecking.SizedTypes.Syntax.Cmp instance Agda.TypeChecking.SizedTypes.Utils.Top Agda.TypeChecking.SizedTypes.Syntax.Cmp instance Test.QuickCheck.Arbitrary.Arbitrary Agda.TypeChecking.SizedTypes.Syntax.Cmp instance GHC.Classes.Ord f => Agda.TypeChecking.SizedTypes.Syntax.Substitute r f (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' r f) instance GHC.Classes.Ord f => Agda.TypeChecking.SizedTypes.Syntax.Substitute r f (Agda.TypeChecking.SizedTypes.Syntax.Constraint' r f) instance Agda.TypeChecking.SizedTypes.Syntax.Substitute r f a => Agda.TypeChecking.SizedTypes.Syntax.Substitute r f [a] instance Agda.TypeChecking.SizedTypes.Utils.Plus (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' r f) Agda.TypeChecking.SizedTypes.Syntax.Offset (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' r f) instance (GHC.Show.Show r, GHC.Show.Show f) => GHC.Show.Show (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' r f) instance GHC.Show.Show Agda.TypeChecking.SizedTypes.Syntax.Polarity instance GHC.Show.Show flex => GHC.Show.Show (Agda.TypeChecking.SizedTypes.Syntax.PolarityAssignment flex) instance GHC.Show.Show Agda.TypeChecking.SizedTypes.Syntax.Cmp instance (GHC.Show.Show r, GHC.Show.Show f) => GHC.Show.Show (Agda.TypeChecking.SizedTypes.Syntax.Constraint' r f) instance Agda.TypeChecking.SizedTypes.Syntax.ValidOffset Agda.TypeChecking.SizedTypes.Syntax.Offset instance Agda.TypeChecking.SizedTypes.Syntax.ValidOffset (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' r f) instance Agda.TypeChecking.SizedTypes.Syntax.TruncateOffset Agda.TypeChecking.SizedTypes.Syntax.Offset instance Agda.TypeChecking.SizedTypes.Syntax.TruncateOffset (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' r f) instance (GHC.Classes.Ord r, Agda.TypeChecking.SizedTypes.Syntax.Rigids r a) => Agda.TypeChecking.SizedTypes.Syntax.Rigids r [a] instance Agda.TypeChecking.SizedTypes.Syntax.Rigids r (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' r f) instance GHC.Classes.Ord r => Agda.TypeChecking.SizedTypes.Syntax.Rigids r (Agda.TypeChecking.SizedTypes.Syntax.Constraint' r f) instance (GHC.Classes.Ord flex, Agda.TypeChecking.SizedTypes.Syntax.Flexs flex a) => Agda.TypeChecking.SizedTypes.Syntax.Flexs flex [a] instance Agda.TypeChecking.SizedTypes.Syntax.Flexs flex (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' rigid flex) instance GHC.Classes.Ord flex => Agda.TypeChecking.SizedTypes.Syntax.Flexs flex (Agda.TypeChecking.SizedTypes.Syntax.Constraint' rigid flex) module Agda.TypeChecking.SizedTypes.WarshallSolver type Graph r f a = Graph (Node r f) (Node r f) a type Edge' r f a = Edge (Node r f) (Node r f) a type Key r f = Edge' r f () type Nodes r f = Nodes (Node r f) type LabelledEdge r f = Edge' r f Label src :: Edge s t e -> s dest :: Edge s t e -> t lookupEdge :: (Ord s, Ord t) => Graph s t e -> s -> t -> Maybe e graphToList :: Graph s t e -> [Edge s t e] graphFromList :: (Ord s, Ord t) => [Edge s t e] -> Graph s t e insertEdge :: (Ord s, Ord t, MeetSemiLattice e, Top e) => Edge s t e -> Graph s t e -> Graph s t e -- | Compute list of edges that start in a given node. outgoing :: (Ord r, Ord f) => Graph r f a -> Node r f -> [Edge' r f a] -- | Compute list of edges that target a given node. -- -- Note: expensive for unidirectional graph representations. incoming :: (Ord r, Ord f) => Graph r f a -> Node r f -> [Edge' r f a] -- | Set.foldl does not exist in legacy versions of the -- containers package. setFoldl :: (b -> a -> b) -> b -> Set a -> b -- | Floyd-Warshall algorithm. transClos :: forall n a. (Ord n, Dioid a) => Graph n n a -> Graph n n a data Weight Offset :: Offset -> Weight Infinity :: Weight -- | Partial implementation of Num. -- | Test for negativity, used to detect negative cycles. class Negative a negative :: Negative a => a -> Bool -- | Going from Lt to Le is pred, going from -- Le to Lt is succ. -- -- X --(R,n)--> Y means X (R) Y + n. [ ... if -- n positive and X + (-n) (R) Y if n -- negative. ] data Label Label :: Cmp -> Offset -> Label [lcmp] :: Label -> Cmp [loffset] :: Label -> Offset -- | Nodes not connected. LInf :: Label -- | Convert a label to a weight, decrementing in case of Lt. toWeight :: Label -> Weight data Node rigid flex NodeZero :: Node rigid flex NodeInfty :: Node rigid flex NodeRigid :: rigid -> Node rigid flex NodeFlex :: flex -> Node rigid flex isFlexNode :: Node rigid flex -> Maybe flex isZeroNode :: Node rigid flex -> Bool isInftyNode :: Node rigid flex -> Bool nodeToSizeExpr :: Node rigid flex -> SizeExpr' rigid flex -- | An edge is negative if its label is. -- | A graph forest. type Graphs r f a = [Graph r f a] emptyGraphs :: Graphs r f a -- | Split a list of graphs gs into those that mention node -- n and those that do not. If n is zero or infinity, -- we regard it as "not mentioned". mentions :: (Ord r, Ord f) => Node r f -> Graphs r f a -> (Graphs r f a, Graphs r f a) -- | Add an edge to a graph forest. Graphs that share a node with the edge -- are joined. addEdge :: (Ord r, Ord f, MeetSemiLattice a, Top a) => Edge' r f a -> Graphs r f a -> Graphs r f a -- | Reflexive closure. Add edges 0 -> n -> n -> oo for -- all nodes n. reflClos :: (Ord r, Ord f, Dioid a) => Set (Node r f) -> Graph r f a -> Graph r f a -- | A graph is negative if it contains a negative loop (diagonal -- edge). Makes sense on transitive graphs. -- | h implies g if any edge in g between rigids -- and constants is implied by a corresponding edge in h, which -- means that the edge in g carries at most the information of -- the one in h. -- -- Application: Constraint implication: Constraints are compatible with -- hypotheses. implies :: (Ord r, Ord f, Show r, Show f, Show a, Top a, Ord a, Negative a) => Graph r f a -> Graph r f a -> Bool nodeFromSizeExpr :: SizeExpr' rigid flex -> (Node rigid flex, Offset) edgeFromConstraint :: Constraint' rigid flex -> LabelledEdge rigid flex -- | Build a graph from list of simplified constraints. graphFromConstraints :: (Ord rigid, Ord flex) => [Constraint' rigid flex] -> Graph rigid flex Label -- | Build a graph from list of simplified constraints. graphsFromConstraints :: (Ord rigid, Ord flex) => [Constraint' rigid flex] -> Graphs rigid flex Label type Hyp = Constraint type Hyp' = Constraint' type HypGraph r f = Graph r f Label hypGraph :: (Ord rigid, Ord flex, Show rigid, Show flex) => Set rigid -> [Hyp' rigid flex] -> Either String (HypGraph rigid flex) hypConn :: (Ord r, Ord f) => HypGraph r f -> Node r f -> Node r f -> Label simplifyWithHypotheses :: (Ord rigid, Ord flex, Show rigid, Show flex) => HypGraph rigid flex -> [Constraint' rigid flex] -> Either String [Constraint' rigid flex] type ConGraph r f = Graph r f Label constraintGraph :: (Ord r, Ord f, Show r, Show f) => [Constraint' r f] -> HypGraph r f -> Either String (ConGraph r f) type ConGraphs r f = Graphs r f Label constraintGraphs :: (Ord r, Ord f, Show r, Show f) => [Constraint' r f] -> HypGraph r f -> Either String ([f], ConGraphs r f) -- | If we have an edge X + n <= X (with n >= 0), we must -- set X = oo. infinityFlexs :: (Ord r, Ord f) => ConGraph r f -> ([f], ConGraph r f) class SetToInfty f a setToInfty :: SetToInfty f a => [f] -> a -> a -- | Lower or upper bound for a flexible variable type Bound r f = Map f (Set (SizeExpr' r f)) emptyBound :: Bound r f data Bounds r f Bounds :: Bound r f -> Bound r f -> Set f -> Bounds r f [lowerBounds] :: Bounds r f -> Bound r f [upperBounds] :: Bounds r f -> Bound r f [mustBeFinite] :: Bounds r f -> Set f -- | Compute a lower bound for a flexible from an edge. edgeToLowerBound :: LabelledEdge r f -> Maybe (f, SizeExpr' r f) -- | Compute an upper bound for a flexible from an edge. edgeToUpperBound :: LabelledEdge r f -> Maybe (f, Cmp, SizeExpr' r f) -- | Compute the lower bounds for all flexibles in a graph. graphToLowerBounds :: (Ord r, Ord f) => [LabelledEdge r f] -> Bound r f -- | Compute the upper bounds for all flexibles in a graph. graphToUpperBounds :: (Ord r, Ord f) => [LabelledEdge r f] -> (Bound r f, Set f) -- | Compute the bounds for all flexibles in a graph. bounds :: (Ord r, Ord f) => ConGraph r f -> Bounds r f -- | Compute the relative minima in a set of nodes (those that do not have -- a predecessor in the set). smallest :: (Ord r, Ord f) => HypGraph r f -> [Node r f] -> [Node r f] -- | Compute the relative maxima in a set of nodes (those that do not have -- a successor in the set). largest :: (Ord r, Ord f) => HypGraph r f -> [Node r f] -> [Node r f] -- | Given source nodes n1,n2,... find all target nodes m1,m2, such that -- for all j, there are edges n_i --l_ij--> m_j for all i. Return -- these edges as a map from target notes to a list of edges. We assume -- the graph is reflexive-transitive. commonSuccs :: (Ord r, Ord f) => Graph r f a -> [Node r f] -> Map (Node r f) [Edge' r f a] -- | Given target nodes m1,m2,... find all source nodes n1,n2, such that -- for all j, there are edges n_i --l_ij--> m_j for all i. Return -- these edges as a map from target notes to a list of edges. We assume -- the graph is reflexive-transitive. commonPreds :: (Ord r, Ord f) => Graph r f a -> [Node r f] -> Map (Node r f) [Edge' r f a] -- | Compute the sup of two different rigids or a rigid and a constant. lub' :: forall r f. (Ord r, Ord f, Show r, Show f) => HypGraph r f -> (Node r f, Offset) -> (Node r f, Offset) -> Maybe (SizeExpr' r f) -- | Compute the inf of two different rigids or a rigid and a constant. glb' :: forall r f. (Ord r, Ord f, Show r, Show f) => HypGraph r f -> (Node r f, Offset) -> (Node r f, Offset) -> Maybe (SizeExpr' r f) -- | Compute the least upper bound (sup). lub :: (Ord r, Ord f, Show r, Show f) => HypGraph r f -> (SizeExpr' r f) -> (SizeExpr' r f) -> Maybe (SizeExpr' r f) -- | Compute the greatest lower bound (inf) of size expressions relative to -- a hypotheses graph. glb :: (Ord r, Ord f, Show r, Show f) => HypGraph r f -> (SizeExpr' r f) -> (SizeExpr' r f) -> Maybe (SizeExpr' r f) findRigidBelow :: (Ord r, Ord f) => HypGraph r f -> (SizeExpr' r f) -> Maybe (SizeExpr' r f) solveGraph :: (Ord r, Ord f, Show r, Show f) => Polarities f -> HypGraph r f -> ConGraph r f -> Either String (Solution r f) -- | Solve a forest of constraint graphs relative to a hypotheses graph. -- Concatenate individual solutions. solveGraphs :: (Ord r, Ord f, Show r, Show f) => Polarities f -> HypGraph r f -> ConGraphs r f -> Either String (Solution r f) -- | Check that after substitution of the solution, constraints are implied -- by hypotheses. verifySolution :: (Ord r, Ord f, Show r, Show f) => HypGraph r f -> [Constraint' r f] -> Solution r f -> Either String () testSuccs :: Ord f => Map (Node [Char] f) [Edge' [Char] f Label] testLub :: (Show f, Ord f) => Maybe (SizeExpr' [Char] f) instance (GHC.Classes.Ord flex, GHC.Classes.Ord rigid) => GHC.Classes.Ord (Agda.TypeChecking.SizedTypes.WarshallSolver.Node rigid flex) instance (GHC.Classes.Eq flex, GHC.Classes.Eq rigid) => GHC.Classes.Eq (Agda.TypeChecking.SizedTypes.WarshallSolver.Node rigid flex) instance GHC.Classes.Eq Agda.TypeChecking.SizedTypes.WarshallSolver.Weight instance GHC.Show.Show Agda.TypeChecking.SizedTypes.WarshallSolver.Weight instance GHC.Classes.Ord Agda.TypeChecking.SizedTypes.WarshallSolver.Weight instance Agda.TypeChecking.SizedTypes.Utils.MeetSemiLattice Agda.TypeChecking.SizedTypes.WarshallSolver.Weight instance Agda.TypeChecking.SizedTypes.Utils.Top Agda.TypeChecking.SizedTypes.WarshallSolver.Weight instance GHC.Enum.Enum Agda.TypeChecking.SizedTypes.WarshallSolver.Weight instance GHC.Num.Num Agda.TypeChecking.SizedTypes.WarshallSolver.Weight instance Agda.TypeChecking.SizedTypes.Utils.Plus Agda.TypeChecking.SizedTypes.WarshallSolver.Weight Agda.TypeChecking.SizedTypes.Syntax.Offset Agda.TypeChecking.SizedTypes.WarshallSolver.Weight instance Test.QuickCheck.Arbitrary.Arbitrary Agda.TypeChecking.SizedTypes.WarshallSolver.Weight instance Agda.TypeChecking.SizedTypes.WarshallSolver.Negative GHC.Types.Int instance Agda.TypeChecking.SizedTypes.WarshallSolver.Negative Agda.TypeChecking.SizedTypes.Syntax.Offset instance Agda.TypeChecking.SizedTypes.WarshallSolver.Negative Agda.TypeChecking.SizedTypes.WarshallSolver.Weight instance Agda.TypeChecking.SizedTypes.WarshallSolver.Negative Agda.TypeChecking.SizedTypes.WarshallSolver.Label instance GHC.Classes.Eq Agda.TypeChecking.SizedTypes.WarshallSolver.Label instance GHC.Classes.Ord Agda.TypeChecking.SizedTypes.WarshallSolver.Label instance GHC.Show.Show Agda.TypeChecking.SizedTypes.WarshallSolver.Label instance Agda.TypeChecking.SizedTypes.Utils.MeetSemiLattice Agda.TypeChecking.SizedTypes.WarshallSolver.Label instance Agda.TypeChecking.SizedTypes.Utils.Top Agda.TypeChecking.SizedTypes.WarshallSolver.Label instance Test.QuickCheck.Arbitrary.Arbitrary Agda.TypeChecking.SizedTypes.WarshallSolver.Label instance Agda.TypeChecking.SizedTypes.Utils.Dioid Agda.TypeChecking.SizedTypes.WarshallSolver.Weight instance Agda.TypeChecking.SizedTypes.Utils.Dioid Agda.TypeChecking.SizedTypes.WarshallSolver.Label instance (GHC.Show.Show rigid, GHC.Show.Show flex) => GHC.Show.Show (Agda.TypeChecking.SizedTypes.WarshallSolver.Node rigid flex) instance Agda.TypeChecking.SizedTypes.WarshallSolver.Negative a => Agda.TypeChecking.SizedTypes.WarshallSolver.Negative (Agda.TypeChecking.SizedTypes.WarshallSolver.Edge' r f a) instance (GHC.Classes.Ord r, GHC.Classes.Ord f, Agda.TypeChecking.SizedTypes.Utils.MeetSemiLattice a) => Agda.TypeChecking.SizedTypes.Utils.MeetSemiLattice (Agda.TypeChecking.SizedTypes.WarshallSolver.Edge' r f a) instance (GHC.Classes.Ord r, GHC.Classes.Ord f, Agda.TypeChecking.SizedTypes.Utils.Top a) => Agda.TypeChecking.SizedTypes.Utils.Top (Agda.TypeChecking.SizedTypes.WarshallSolver.Edge' r f a) instance (GHC.Classes.Ord r, GHC.Classes.Ord f, Agda.TypeChecking.SizedTypes.Utils.Dioid a) => Agda.TypeChecking.SizedTypes.Utils.Dioid (Agda.TypeChecking.SizedTypes.WarshallSolver.Edge' r f a) instance (GHC.Classes.Ord r, GHC.Classes.Ord f, Agda.TypeChecking.SizedTypes.WarshallSolver.Negative a) => Agda.TypeChecking.SizedTypes.WarshallSolver.Negative (Agda.TypeChecking.SizedTypes.WarshallSolver.Graph r f a) instance (GHC.Classes.Ord r, GHC.Classes.Ord f, Agda.TypeChecking.SizedTypes.WarshallSolver.Negative a) => Agda.TypeChecking.SizedTypes.WarshallSolver.Negative (Agda.TypeChecking.SizedTypes.WarshallSolver.Graphs r f a) instance GHC.Classes.Eq f => Agda.TypeChecking.SizedTypes.WarshallSolver.SetToInfty f (Agda.TypeChecking.SizedTypes.WarshallSolver.Node r f) instance GHC.Classes.Eq f => Agda.TypeChecking.SizedTypes.WarshallSolver.SetToInfty f (Agda.TypeChecking.SizedTypes.WarshallSolver.Edge' r f a) instance (GHC.Classes.Ord r, GHC.Classes.Ord f) => Agda.TypeChecking.SizedTypes.WarshallSolver.SetToInfty f (Agda.TypeChecking.SizedTypes.WarshallSolver.ConGraph r f) instance Agda.TypeChecking.SizedTypes.Utils.Plus Agda.TypeChecking.SizedTypes.Syntax.Offset Agda.TypeChecking.SizedTypes.WarshallSolver.Weight Agda.TypeChecking.SizedTypes.WarshallSolver.Weight instance Agda.TypeChecking.SizedTypes.Utils.Plus (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' r f) Agda.TypeChecking.SizedTypes.WarshallSolver.Weight (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' r f) instance Agda.TypeChecking.SizedTypes.Utils.Plus (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' r f) Agda.TypeChecking.SizedTypes.WarshallSolver.Label (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' r f) module Agda.TypeChecking.SizedTypes.Tests type Relation a = a -> a -> Bool class AsWeightRelation b eval :: AsWeightRelation b => b -> Relation Weight prop_MeetSound :: Label -> Label -> Weight -> Weight -> Property prop_MeetComplete :: Label -> Label -> Weight -> Weight -> Property prop_ComposeSound :: Label -> Label -> Weight -> Weight -> Weight -> Property prop_ComposeComplete :: Label -> Label -> Offset -> Weight -> Property propCommutative :: Eq b => (a -> a -> b) -> a -> a -> Bool propAssociative :: Eq a => (a -> a -> a) -> a -> a -> a -> Bool propIdempotent :: Eq a => (a -> a -> a) -> a -> Bool propUnit :: Eq a => (a -> a -> a) -> a -> a -> Bool propZero :: Eq a => (a -> a -> a) -> a -> a -> Bool propDistL :: Eq b => (a -> b -> b) -> (b -> b -> b) -> a -> b -> b -> Bool propDistR :: Eq a => (a -> b -> a) -> (a -> a -> a) -> a -> a -> b -> Bool propDistributive :: Eq a => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Bool propSemiLattice :: Eq a => (a -> a -> a) -> a -> a -> a -> Bool propBoundedSemiLattice :: Eq a => (a -> a -> a) -> a -> a -> a -> a -> Bool propMonoid :: Eq a => (a -> a -> a) -> a -> a -> a -> a -> Bool propDioid :: Eq a => (a -> a -> a) -> a -> (a -> a -> a) -> a -> a -> a -> a -> Bool -- | Properties of Dioid class. propDioid_Gen :: Dioid a => a -> a -> a -> Bool -- | Weight instance. prop_Dioid_Weight :: Weight -> Weight -> Weight -> Bool -- | Label instance. prop_SemiLattice_Label :: Label -> Label -> Label -> Bool prop_Unit_Label :: Label -> Bool prop_BoundedSemiLattice_Label :: Label -> Label -> Label -> Bool prop_Monoid_Label :: Label -> Label -> Label -> Bool prop_DistL_Label :: Label -> Label -> Label -> Bool prop_DistR_Label :: Label -> Label -> Label -> Bool prop_Dist_Label :: Label -> Label -> Label -> Bool prop_Zero_Label :: Label -> Bool prop_Dioid_Label :: Label -> Label -> Label -> Bool -- | Runs all tests starting with "prop_" in this file. tests :: IO Bool instance Agda.TypeChecking.SizedTypes.Tests.AsWeightRelation Agda.TypeChecking.SizedTypes.Syntax.Cmp instance Agda.TypeChecking.SizedTypes.Tests.AsWeightRelation Agda.TypeChecking.SizedTypes.WarshallSolver.Label -- | Semirings. module Agda.Termination.Semiring -- | HasZero is needed for sparse matrices, to tell which is the -- element that does not have to be stored. It is a cut-down version of -- SemiRing which is definable without the implicit -- ?cutoff. class Eq a => HasZero a zeroElement :: HasZero a => a -- | SemiRing type class. Additive monoid with multiplication operation. -- Inherit addition and zero from Monoid. class (Eq a, Monoid a) => SemiRing a multiply :: SemiRing a => a -> a -> a -- | Semirings. data Semiring a Semiring :: (a -> a -> a) -> (a -> a -> a) -> a -> Semiring a -- | Addition. [add] :: Semiring a -> a -> a -> a -- | Multiplication. [mul] :: Semiring a -> a -> a -> a -- | Zero. The one is never used in matrix multiplication , one :: a -- ^ -- One. [zero] :: Semiring a -> a -- | Semiring invariant. semiringInvariant :: Eq a => Semiring a -> a -> a -> a -> Bool integerSemiring :: Semiring Integer intSemiring :: Semiring Int -- | The standard semiring on Bools. boolSemiring :: Semiring Bool tests :: IO Bool instance Agda.Termination.Semiring.HasZero GHC.Integer.Type.Integer instance Agda.Termination.Semiring.HasZero GHC.Types.Int -- | Sparse matrices. -- -- We assume the matrices to be very sparse, so we just implement them as -- sorted association lists. -- -- Most operations are linear in the number of non-zero elements. -- -- An exception is transposition, which needs to sort the association -- list again; it has the complexity of sorting: n log n where -- n is the number of non-zero elements. -- -- Another exception is matrix multiplication, of course. module Agda.Termination.SparseMatrix -- | Type of matrices, parameterised on the type of values. -- -- Sparse matrices are implemented as an ordered association list, -- mapping coordinates to values. data Matrix i b -- | Matrix indices are lexicographically sorted with no duplicates. All -- indices must be within bounds. matrixInvariant :: (Num i, Ix i, HasZero b) => Matrix i b -> Bool -- | Size of a matrix. data Size i Size :: i -> i -> Size i -- | Number of rows, >= 0. [rows] :: Size i -> i -- | Number of columns, >= 0. [cols] :: Size i -> i -- | Size invariant: dimensions are non-negative. sizeInvariant :: (Ord i, Num i) => Size i -> Bool -- | Type of matrix indices (row, column). data MIx i MIx :: i -> i -> MIx i -- | Row index, 1 <= row <= rows. [row] :: MIx i -> i -- | Column index 1 <= col <= cols. [col] :: MIx i -> i -- | Indices must be positive, >= 1. mIxInvariant :: (Ord i, Num i) => MIx i -> Bool -- | fromLists sz rs constructs a matrix from a list of -- lists of values (a list of rows). O(size) where size = -- rows × cols. -- -- Precondition: length rs == rows sz and -- all ((cols sz ==) . length) rs. fromLists :: (Ord i, Num i, Enum i, HasZero b) => Size i -> [[b]] -> Matrix i b -- | Constructs a matrix from a list of (index, value)-pairs. -- O(n) where n is size of the list. -- -- Precondition: indices are unique. fromIndexList :: (Ord i, HasZero b) => Size i -> [(MIx i, b)] -> Matrix i b -- | Converts a matrix to a list of row lists. O(size) where -- size = rows × cols. toLists :: (Integral i, HasZero b) => Matrix i b -> [[b]] -- | Generates a matrix of the given size. matrix :: (Integral i, Arbitrary b, HasZero b) => Size i -> Gen (Matrix i b) -- | Generates a matrix of the given size, using the given generator to -- generate the rows. matrixUsingRowGen :: (Integral i, HasZero b) => Size i -> (i -> Gen [b]) -> Gen (Matrix i b) -- | Dimensions of the matrix. size :: Matrix i b -> Size i -- | True iff the matrix is square. square :: Ix i => Matrix i b -> Bool -- | Returns True iff the matrix is empty. isEmpty :: (Num i, Ix i) => Matrix i b -> Bool -- | Returns 'Just b' iff it is a 1x1 matrix with just one entry -- b. O(1). isSingleton :: (Eq i, Num i, HasZero b) => Matrix i b -> Maybe b -- | General pointwise combination function for sparse matrices. O(n1 + -- n2). zipMatrices :: forall a b c i. (Ord i) => (a -> c) -> (b -> c) -> (a -> b -> c) -> (c -> Bool) -> Matrix i a -> Matrix i b -> Matrix i c -- | add (+) m1 m2 adds m1 and m2, using -- (+) to add values. O(n1 + n2). -- -- Returns a matrix of size supSize m1 m2. add :: (Ord i, HasZero a) => (a -> a -> a) -> Matrix i a -> Matrix i a -> Matrix i a -- | intersectWith f m1 m2 build the pointwise conjunction -- m1 and m2. Uses f to combine non-zero -- values. O(n1 + n2). -- -- Returns a matrix of size infSize m1 m2. intersectWith :: (Ord i) => (a -> a -> a) -> Matrix i a -> Matrix i a -> Matrix i a -- | mul semiring m1 m2 multiplies matrices m1 and -- m2. Uses the operations of the semiring semiring to -- perform the multiplication. -- -- O(n1 + n2 log n2 + Σ(i <= r1) Σ(j <= c2) d(i,j)) where -- r1 is the number of non-empty rows in m1 and -- c2 is the number of non-empty columns in m2 and -- d(i,j) is the bigger one of the following two quantifies: the -- length of sparse row i in m1 and the length of -- sparse column j in m2. -- -- Given dimensions m1 : r1 × c1 and m2 : r2 × c2, a -- matrix of size r1 × c2 is returned. It is not necessary that -- c1 == r2, the matrices are implicitly patched with zeros to -- match up for multiplication. For sparse matrices, this patching is a -- no-op. mul :: (Ix i, Eq a) => Semiring a -> Matrix i a -> Matrix i a -> Matrix i a transpose :: Transpose a => a -> a -- | diagonal m extracts the diagonal of m. -- -- For non-square matrices, the length of the diagonal is the minimum of -- the dimensions of the matrix. class Diagonal m e | m -> e diagonal :: Diagonal m e => m -> [e] -- | addRow x m adds a new row to m, after the -- rows already existing in the matrix. All elements in the new row get -- set to x. addRow :: (Num i, HasZero b) => b -> Matrix i b -> Matrix i b -- | addColumn x m adds a new column to m, after -- the columns already existing in the matrix. All elements in the new -- column get set to x. addColumn :: (Num i, HasZero b) => b -> Matrix i b -> Matrix i b tests :: IO Bool instance Data.Traversable.Traversable (Agda.Termination.SparseMatrix.Matrix i) instance Data.Foldable.Foldable (Agda.Termination.SparseMatrix.Matrix i) instance GHC.Base.Functor (Agda.Termination.SparseMatrix.Matrix i) instance (GHC.Classes.Ord b, GHC.Classes.Ord i) => GHC.Classes.Ord (Agda.Termination.SparseMatrix.Matrix i b) instance (GHC.Classes.Eq b, GHC.Classes.Eq i) => GHC.Classes.Eq (Agda.Termination.SparseMatrix.Matrix i b) instance GHC.Arr.Ix i => GHC.Arr.Ix (Agda.Termination.SparseMatrix.MIx i) instance GHC.Show.Show i => GHC.Show.Show (Agda.Termination.SparseMatrix.MIx i) instance GHC.Classes.Ord i => GHC.Classes.Ord (Agda.Termination.SparseMatrix.MIx i) instance GHC.Classes.Eq i => GHC.Classes.Eq (Agda.Termination.SparseMatrix.MIx i) instance GHC.Show.Show i => GHC.Show.Show (Agda.Termination.SparseMatrix.Size i) instance GHC.Classes.Ord i => GHC.Classes.Ord (Agda.Termination.SparseMatrix.Size i) instance GHC.Classes.Eq i => GHC.Classes.Eq (Agda.Termination.SparseMatrix.Size i) instance (GHC.Real.Integral i, Agda.Termination.Semiring.HasZero b) => Agda.Termination.SparseMatrix.Diagonal (Agda.Termination.SparseMatrix.Matrix i b) b instance Agda.Termination.SparseMatrix.Transpose (Agda.Termination.SparseMatrix.Size i) instance Agda.Termination.SparseMatrix.Transpose (Agda.Termination.SparseMatrix.MIx i) instance GHC.Classes.Ord i => Agda.Termination.SparseMatrix.Transpose (Agda.Termination.SparseMatrix.Matrix i b) instance (GHC.Classes.Ord i, Agda.Utils.PartialOrd.PartialOrd a) => Agda.Utils.PartialOrd.PartialOrd (Agda.Termination.SparseMatrix.Matrix i a) instance (GHC.Real.Integral i, Agda.Termination.Semiring.HasZero b, GHC.Show.Show i, GHC.Show.Show b) => GHC.Show.Show (Agda.Termination.SparseMatrix.Matrix i b) instance (GHC.Real.Integral i, Agda.Termination.Semiring.HasZero b, Agda.Utils.Pretty.Pretty b) => Agda.Utils.Pretty.Pretty (Agda.Termination.SparseMatrix.Matrix i b) instance GHC.Real.Integral i => Test.QuickCheck.Arbitrary.Arbitrary (Agda.Termination.SparseMatrix.Size i) instance Test.QuickCheck.Arbitrary.CoArbitrary i => Test.QuickCheck.Arbitrary.CoArbitrary (Agda.Termination.SparseMatrix.Size i) instance GHC.Real.Integral i => Test.QuickCheck.Arbitrary.Arbitrary (Agda.Termination.SparseMatrix.MIx i) instance Test.QuickCheck.Arbitrary.CoArbitrary i => Test.QuickCheck.Arbitrary.CoArbitrary (Agda.Termination.SparseMatrix.MIx i) instance (GHC.Real.Integral i, Test.QuickCheck.Arbitrary.Arbitrary b, Agda.Termination.Semiring.HasZero b) => Test.QuickCheck.Arbitrary.Arbitrary (Agda.Termination.SparseMatrix.Matrix i b) instance (GHC.Real.Integral i, Test.QuickCheck.Arbitrary.CoArbitrary b, Agda.Termination.Semiring.HasZero b) => Test.QuickCheck.Arbitrary.CoArbitrary (Agda.Termination.SparseMatrix.Matrix i b) -- | Defines CutOff type which is used in -- Agda.Interaction.Options. This module's purpose is to eliminate -- the dependency of Agda.TypeChecking.Monad.Base on the -- termination checker and everything it imports. module Agda.Termination.CutOff -- | Cut off structural order comparison at some depth in termination -- checker? data CutOff -- | c >= 0 means: record decrease up to including -- c+1. CutOff :: Int -> CutOff DontCutOff :: CutOff instance GHC.Classes.Ord Agda.Termination.CutOff.CutOff instance GHC.Classes.Eq Agda.Termination.CutOff.CutOff instance GHC.Show.Show Agda.Termination.CutOff.CutOff -- | An Abstract domain of relative sizes, i.e., differences between size -- of formal function parameter and function argument in recursive call; -- used in the termination checker. module Agda.Termination.Order -- | In the paper referred to above, there is an order R with -- Unknown <= Le <= -- Lt. -- -- This is generalized to Unknown <= 'Decr k' -- where Decr 1 replaces Lt and Decr 0 -- replaces Le. A negative decrease means an increase. The -- generalization allows the termination checker to record an increase by -- 1 which can be compensated by a following decrease by 2 which results -- in an overall decrease. -- -- However, the termination checker of the paper itself terminates -- because there are only finitely many different call-matrices. To -- maintain termination of the terminator we set a cutoff point -- which determines how high the termination checker can count. This -- value should be set by a global or file-wise option. -- -- See Call for more information. -- -- TODO: document orders which are call-matrices themselves. data Order -- | Matrix-shaped order, currently UNUSED. Mat :: {-# UNPACK #-} !(Matrix Int Order) -> Order -- | Smart constructor for Decr k :: Order which cuts off too big -- values. -- -- Possible values for k: - ?cutoff <= k -- <= ?cutoff + 1. decr :: (?cutoff :: CutOff) => Int -> Order -- | Raw increase which does not cut off. increase :: Int -> Order -> Order -- | Raw decrease which does not cut off. decrease :: Int -> Order -> Order -- | Multiplication of Orders. (Corresponds to sequential -- composition.) (.*.) :: (?cutoff :: CutOff) => Order -> Order -> Order -- | The supremum of a (possibly empty) list of Orders. More -- information (i.e., more decrease) is bigger. Unknown is no -- information, thus, smallest. supremum :: (?cutoff :: CutOff) => [Order] -> Order -- | The infimum of a (non empty) list of Orders. Unknown is -- the least element, thus, dominant. infimum :: (?cutoff :: CutOff) => [Order] -> Order orderSemiring :: (?cutoff :: CutOff) => Semiring Order -- | le, lt, decreasing, unknown: for -- backwards compatibility, and for external use. le :: Order lt :: Order unknown :: Order -- | Smart constructor for matrix shaped orders, avoiding empty and -- singleton matrices. orderMat :: Matrix Int Order -> Order collapseO :: (?cutoff :: CutOff) => Order -> Order nonIncreasing :: Order -> Bool decreasing :: Order -> Bool -- | Matrix-shaped order is decreasing if any diagonal element is -- decreasing. isDecr :: Order -> Bool -- | A partial order, aimed at deciding whether a call graph gets worse -- during the completion. class NotWorse a notWorse :: NotWorse a => a -> a -> Bool tests :: IO Bool instance GHC.Classes.Ord Agda.Termination.Order.Order instance GHC.Classes.Eq Agda.Termination.Order.Order instance GHC.Show.Show Agda.Termination.Order.Order instance Agda.Termination.Semiring.HasZero Agda.Termination.Order.Order instance Agda.Utils.PartialOrd.PartialOrd Agda.Termination.Order.Order instance Agda.Termination.Order.NotWorse Agda.Termination.Order.Order instance GHC.Classes.Ord i => Agda.Termination.Order.NotWorse (Agda.Termination.SparseMatrix.Matrix i Agda.Termination.Order.Order) instance Agda.Utils.Pretty.Pretty Agda.Termination.Order.Order instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Termination.Order.Order instance Test.QuickCheck.Arbitrary.CoArbitrary Agda.Termination.Order.Order module Agda.Termination.CallMatrix -- | Call matrix indices = function argument indices. -- -- Machine integer Int is sufficient, since we cannot index more -- arguments than we have addresses on our machine. type ArgumentIndex = Int -- | Call matrices. -- -- A call matrix for a call f --> g has dimensions ar(g) -- × ar(f). -- -- Each column corresponds to one formal argument of caller f. -- Each row corresponds to one argument in the call to g. -- -- In the presence of dot patterns, a call argument can be related to -- several different formal arguments of f. -- -- See e.g. testsucceedDotPatternTermination.agda: -- --
-- data D : Nat -> Set where -- cz : D zero -- c1 : forall n -> D n -> D (suc n) -- c2 : forall n -> D n -> D n -- -- f : forall n -> D n -> Nat -- f .zero cz = zero -- f .(suc n) (c1 n d) = f n (c2 n d) -- f n (c2 .n d) = f n d -- ---- -- Call matrices (without guardedness) are -- --
-- -1 -1 n < suc n and n < c1 n d -- ? = c2 n d <= c1 n d -- -- = -1 n <= n and n < c2 n d -- ? -1 d < c2 n d -- ---- -- Here is a part of the original documentation for call matrices (kept -- for historical reasons): -- -- This datatype encodes information about a single recursive function -- application. The columns of the call matrix stand for source -- function arguments (patterns). The rows of the matrix stand for -- target function arguments. Element (i, j) in the -- matrix should be computed as follows: -- --
-- movePosByString = foldl' movePos --movePosByString :: Position' a -> String -> Position' a -- | Backup the position by one character. -- -- Precondition: The character must not be '\n'. backupPos :: Position' a -> Position' a type Interval = Interval' SrcFile type IntervalWithoutFile = Interval' () -- | An interval. The iEnd position is not included in the -- interval. -- -- Note the invariant which intervals have to satisfy: -- intervalInvariant. data Interval' a Interval :: !(Position' a) -> Interval' a [iStart, iEnd] :: Interval' a -> !(Position' a) intervalInvariant :: Ord a => Interval' a -> Bool -- | Converts a file name and two positions to an interval. posToInterval :: a -> PositionWithoutFile -> PositionWithoutFile -> Interval' a -- | Extracts the interval corresponding to the given string, assuming that -- the string starts at the beginning of the given interval. -- -- Precondition: The string must not be too long for the interval. takeI :: String -> Interval' a -> Interval' a -- | Removes the interval corresponding to the given string from the given -- interval, assuming that the string starts at the beginning of the -- interval. -- -- Precondition: The string must not be too long for the interval. dropI :: String -> Interval' a -> Interval' a type Range = Range' SrcFile -- | A range is a file name, plus a sequence of intervals, assumed to point -- to the given file. The intervals should be consecutive and separated. -- -- Note the invariant which ranges have to satisfy: -- rangeInvariant. data Range' a -- | Range invariant. rangeInvariant :: Ord a => Range' a -> Bool -- | Are the intervals consecutive and separated, do they all point to the -- same file, and do they satisfy the interval invariant? consecutiveAndSeparated :: Ord a => [Interval' a] -> Bool -- | Turns a file name plus a list of intervals into a range. -- -- Precondition: consecutiveAndSeparated. intervalsToRange :: a -> [IntervalWithoutFile] -> Range' a -- | The intervals that make up the range. The intervals are consecutive -- and separated (consecutiveAndSeparated). rangeIntervals :: Range' a -> [IntervalWithoutFile] -- | The file the range is pointing to. rangeFile :: Range -> SrcFile -- | Conflate a range to its right margin. rightMargin :: Range -> Range -- | Ranges between two unknown positions noRange :: Range' a -- | Converts two positions to a range. -- -- Precondition: The positions have to point to the same file. posToRange :: Position' a -> Position' a -> Range' a -- | Converts a file name and two positions to a range. posToRange' :: a -> PositionWithoutFile -> PositionWithoutFile -> Range' a -- | The initial position in the range, if any. rStart :: Range' a -> Maybe (Position' a) -- | The initial position in the range, if any. rStart' :: Range' a -> Maybe PositionWithoutFile -- | The position after the final position in the range, if any. rEnd :: Range' a -> Maybe (Position' a) -- | The position after the final position in the range, if any. rEnd' :: Range' a -> Maybe PositionWithoutFile -- | Converts a range to an interval, if possible. Note that the -- information about the source file is lost. rangeToInterval :: Range' a -> Maybe IntervalWithoutFile -- | Returns the shortest continuous range containing the given one. continuous :: Range' a -> Range' a -- | Removes gaps between intervals on the same line. continuousPerLine :: Ord a => Range' a -> Range' a -- | Wrapper to indicate that range should be printed. newtype PrintRange a PrintRange :: a -> PrintRange a -- | Things that have a range are instances of this class. class HasRange t getRange :: HasRange t => t -> Range -- | If it is also possible to set the range, this is the class. -- -- Instances should satisfy getRange (setRange r x) == -- r. class HasRange t => SetRange t setRange :: SetRange t => Range -> t -> t -- | Killing the range of an object sets all range information to -- noRange. class KillRange a killRange :: KillRange a => KillRangeT a type KillRangeT a = a -> a -- | Remove ranges in keys and values of a map. killRangeMap :: (KillRange k, KillRange v) => KillRangeT (Map k v) killRange1 :: KillRange a => (a -> b) -> a -> b killRange2 :: (KillRange a, KillRange b) => (a -> b -> c) -> a -> b -> c killRange3 :: (KillRange a, KillRange b, KillRange c) => (a -> b -> c -> d) -> a -> b -> c -> d killRange4 :: (KillRange a, KillRange b, KillRange c, KillRange d) => (a -> b -> c -> d -> e) -> a -> b -> c -> d -> e killRange5 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e) => (a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> f killRange6 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f) => (a -> b -> c -> d -> e -> f -> g) -> a -> b -> c -> d -> e -> f -> g killRange7 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f, KillRange g) => (a -> b -> c -> d -> e -> f -> g -> h) -> a -> b -> c -> d -> e -> f -> g -> h killRange8 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f, KillRange g, KillRange h) => (a -> b -> c -> d -> e -> f -> g -> h -> i) -> a -> b -> c -> d -> e -> f -> g -> h -> i killRange9 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f, KillRange g, KillRange h, KillRange i) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j killRange10 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f, KillRange g, KillRange h, KillRange i, KillRange j) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k killRange11 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f, KillRange g, KillRange h, KillRange i, KillRange j, KillRange k) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l killRange12 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f, KillRange g, KillRange h, KillRange i, KillRange j, KillRange k, KillRange l) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m killRange13 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f, KillRange g, KillRange h, KillRange i, KillRange j, KillRange k, KillRange l, KillRange m) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n killRange14 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f, KillRange g, KillRange h, KillRange i, KillRange j, KillRange k, KillRange l, KillRange m, KillRange n) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o killRange15 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f, KillRange g, KillRange h, KillRange i, KillRange j, KillRange k, KillRange l, KillRange m, KillRange n, KillRange o) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p killRange16 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f, KillRange g, KillRange h, KillRange i, KillRange j, KillRange k, KillRange l, KillRange m, KillRange n, KillRange o, KillRange p) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q killRange17 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f, KillRange g, KillRange h, KillRange i, KillRange j, KillRange k, KillRange l, KillRange m, KillRange n, KillRange o, KillRange p, KillRange q) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r killRange18 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f, KillRange g, KillRange h, KillRange i, KillRange j, KillRange k, KillRange l, KillRange m, KillRange n, KillRange o, KillRange p, KillRange q, KillRange r) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s killRange19 :: (KillRange a, KillRange b, KillRange c, KillRange d, KillRange e, KillRange f, KillRange g, KillRange h, KillRange i, KillRange j, KillRange k, KillRange l, KillRange m, KillRange n, KillRange o, KillRange p, KillRange q, KillRange r, KillRange s) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p -> q -> r -> s -> t -- | x `withRangeOf` y sets the range of x to the range -- of y. withRangeOf :: (SetRange t, HasRange u) => t -> u -> t -- | Precondition: The ranges must point to the same file (or be empty). fuseRange :: (HasRange u, HasRange t) => u -> t -> Range -- | fuseRanges r r' unions the ranges r and r'. -- -- Meaning it finds the least range r0 that covers r -- and r'. -- -- Precondition: The ranges must point to the same file (or be empty). fuseRanges :: (Ord a) => Range' a -> Range' a -> Range' a -- | beginningOf r is an empty range (a single, empty interval) -- positioned at the beginning of r. If r does not have -- a beginning, then noRange is returned. beginningOf :: Range -> Range -- | beginningOfFile r is an empty range (a single, empty -- interval) at the beginning of r's starting position's file. -- If there is no such position, then an empty range is returned. beginningOfFile :: Range -> Range -- | Test suite. tests :: IO Bool instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Syntax.Position.PrintRange a) instance Agda.Syntax.Position.SetRange a => Agda.Syntax.Position.SetRange (Agda.Syntax.Position.PrintRange a) instance Agda.Syntax.Position.HasRange a => Agda.Syntax.Position.HasRange (Agda.Syntax.Position.PrintRange a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Agda.Syntax.Position.PrintRange a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Syntax.Position.PrintRange a) instance GHC.Generics.Generic (Agda.Syntax.Position.Range' a) instance Data.Traversable.Traversable Agda.Syntax.Position.Range' instance Data.Foldable.Foldable Agda.Syntax.Position.Range' instance GHC.Base.Functor Agda.Syntax.Position.Range' instance GHC.Classes.Ord a => GHC.Classes.Ord (Agda.Syntax.Position.Range' a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Syntax.Position.Range' a) instance GHC.Generics.Generic (Agda.Syntax.Position.Interval' a) instance Data.Traversable.Traversable Agda.Syntax.Position.Interval' instance Data.Foldable.Foldable Agda.Syntax.Position.Interval' instance GHC.Base.Functor Agda.Syntax.Position.Interval' instance GHC.Classes.Ord a => GHC.Classes.Ord (Agda.Syntax.Position.Interval' a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Syntax.Position.Interval' a) instance GHC.Generics.Generic (Agda.Syntax.Position.Position' a) instance Data.Traversable.Traversable Agda.Syntax.Position.Position' instance Data.Foldable.Foldable Agda.Syntax.Position.Position' instance GHC.Base.Functor Agda.Syntax.Position.Position' instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Syntax.Position.Position' a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Agda.Syntax.Position.Position' a) instance Agda.Utils.Null.Null (Agda.Syntax.Position.Range' a) instance Agda.Syntax.Position.HasRange Agda.Syntax.Position.Interval instance Agda.Syntax.Position.HasRange Agda.Syntax.Position.Range instance Agda.Syntax.Position.HasRange GHC.Types.Bool instance Agda.Syntax.Position.HasRange a => Agda.Syntax.Position.HasRange [a] instance (Agda.Syntax.Position.HasRange a, Agda.Syntax.Position.HasRange b) => Agda.Syntax.Position.HasRange (a, b) instance (Agda.Syntax.Position.HasRange a, Agda.Syntax.Position.HasRange b, Agda.Syntax.Position.HasRange c) => Agda.Syntax.Position.HasRange (a, b, c) instance (Agda.Syntax.Position.HasRange a, Agda.Syntax.Position.HasRange b, Agda.Syntax.Position.HasRange c, Agda.Syntax.Position.HasRange d) => Agda.Syntax.Position.HasRange (a, b, c, d) instance (Agda.Syntax.Position.HasRange a, Agda.Syntax.Position.HasRange b, Agda.Syntax.Position.HasRange c, Agda.Syntax.Position.HasRange d, Agda.Syntax.Position.HasRange e) => Agda.Syntax.Position.HasRange (a, b, c, d, e) instance (Agda.Syntax.Position.HasRange a, Agda.Syntax.Position.HasRange b, Agda.Syntax.Position.HasRange c, Agda.Syntax.Position.HasRange d, Agda.Syntax.Position.HasRange e, Agda.Syntax.Position.HasRange f) => Agda.Syntax.Position.HasRange (a, b, c, d, e, f) instance (Agda.Syntax.Position.HasRange a, Agda.Syntax.Position.HasRange b, Agda.Syntax.Position.HasRange c, Agda.Syntax.Position.HasRange d, Agda.Syntax.Position.HasRange e, Agda.Syntax.Position.HasRange f, Agda.Syntax.Position.HasRange g) => Agda.Syntax.Position.HasRange (a, b, c, d, e, f, g) instance Agda.Syntax.Position.HasRange a => Agda.Syntax.Position.HasRange (GHC.Base.Maybe a) instance (Agda.Syntax.Position.HasRange a, Agda.Syntax.Position.HasRange b) => Agda.Syntax.Position.HasRange (Data.Either.Either a b) instance Agda.Syntax.Position.SetRange Agda.Syntax.Position.Range instance Agda.Syntax.Position.SetRange a => Agda.Syntax.Position.SetRange [a] instance Agda.Syntax.Position.KillRange Agda.Syntax.Position.Range instance Agda.Syntax.Position.KillRange Data.Void.Void instance Agda.Syntax.Position.KillRange () instance Agda.Syntax.Position.KillRange GHC.Types.Bool instance Agda.Syntax.Position.KillRange GHC.Types.Int instance Agda.Syntax.Position.KillRange GHC.Integer.Type.Integer instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange [a] instance Agda.Syntax.Position.KillRange GHC.Base.String instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Data.Map.Base.Map k a) instance (GHC.Classes.Ord a, Agda.Syntax.Position.KillRange a) => Agda.Syntax.Position.KillRange (Data.Set.Base.Set a) instance (Agda.Syntax.Position.KillRange a, Agda.Syntax.Position.KillRange b) => Agda.Syntax.Position.KillRange (a, b) instance (Agda.Syntax.Position.KillRange a, Agda.Syntax.Position.KillRange b, Agda.Syntax.Position.KillRange c) => Agda.Syntax.Position.KillRange (a, b, c) instance (Agda.Syntax.Position.KillRange a, Agda.Syntax.Position.KillRange b, Agda.Syntax.Position.KillRange c, Agda.Syntax.Position.KillRange d) => Agda.Syntax.Position.KillRange (a, b, c, d) instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (GHC.Base.Maybe a) instance (Agda.Syntax.Position.KillRange a, Agda.Syntax.Position.KillRange b) => Agda.Syntax.Position.KillRange (Data.Either.Either a b) instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Position.Position' (Data.Strict.Maybe.Maybe a)) instance GHC.Show.Show Agda.Syntax.Position.PositionWithoutFile instance GHC.Show.Show Agda.Syntax.Position.IntervalWithoutFile instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Position.Interval' (Data.Strict.Maybe.Maybe a)) instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Position.Range' (Data.Strict.Maybe.Maybe a)) instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Position.Range' (GHC.Base.Maybe a)) instance Agda.Utils.Pretty.Pretty a => Agda.Utils.Pretty.Pretty (Agda.Syntax.Position.Position' (Data.Strict.Maybe.Maybe a)) instance Agda.Utils.Pretty.Pretty Agda.Syntax.Position.PositionWithoutFile instance Agda.Utils.Pretty.Pretty Agda.Syntax.Position.IntervalWithoutFile instance Agda.Utils.Pretty.Pretty a => Agda.Utils.Pretty.Pretty (Agda.Syntax.Position.Interval' (Data.Strict.Maybe.Maybe a)) instance Agda.Utils.Pretty.Pretty a => Agda.Utils.Pretty.Pretty (Agda.Syntax.Position.Range' (Data.Strict.Maybe.Maybe a)) instance (Agda.Utils.Pretty.Pretty a, Agda.Syntax.Position.HasRange a) => Agda.Utils.Pretty.Pretty (Agda.Syntax.Position.PrintRange a) instance Test.QuickCheck.Arbitrary.Arbitrary a => Test.QuickCheck.Arbitrary.Arbitrary (Agda.Syntax.Position.Position' a) instance (Test.QuickCheck.Arbitrary.Arbitrary a, GHC.Classes.Ord a) => Test.QuickCheck.Arbitrary.Arbitrary (Agda.Syntax.Position.Interval' a) instance (GHC.Classes.Ord a, Test.QuickCheck.Arbitrary.Arbitrary a) => Test.QuickCheck.Arbitrary.Arbitrary (Agda.Syntax.Position.Range' a) instance Test.QuickCheck.Arbitrary.CoArbitrary a => Test.QuickCheck.Arbitrary.CoArbitrary (Agda.Syntax.Position.Position' a) instance Test.QuickCheck.Arbitrary.CoArbitrary a => Test.QuickCheck.Arbitrary.CoArbitrary (Agda.Syntax.Position.Interval' a) instance Test.QuickCheck.Arbitrary.CoArbitrary a => Test.QuickCheck.Arbitrary.CoArbitrary (Agda.Syntax.Position.Range' a) instance GHC.Show.Show (Agda.Syntax.Position.Position' GHC.Integer.Type.Integer) instance GHC.Show.Show (Agda.Syntax.Position.Interval' GHC.Integer.Type.Integer) instance GHC.Show.Show (Agda.Syntax.Position.Range' GHC.Integer.Type.Integer) -- | Occurrences. module Agda.TypeChecking.Positivity.Occurrence -- | Subterm occurrences for positivity checking. The constructors are -- listed in increasing information they provide: Mixed <= JustPos -- <= StrictPos <= GuardPos <= Unused Mixed <= -- JustNeg <= Unused. data Occurrence -- | Arbitrary occurrence (positive and negative). Mixed :: Occurrence -- | Negative occurrence. JustNeg :: Occurrence -- | Positive occurrence, but not strictly positive. JustPos :: Occurrence -- | Strictly positive occurrence. StrictPos :: Occurrence -- | Guarded strictly positive occurrence (i.e., under ∞). For checking -- recursive records. GuardPos :: Occurrence Unused :: Occurrence -- | The map contains bindings of the form bound |-> es, -- satisfying the following property: for every non-empty list -- w, foldr1 otimes w <= bound -- iff or [ all every w && any -- some w | (every, some) <- ess ]. boundToEverySome :: Map Occurrence [(Occurrence -> Bool, Occurrence -> Bool)] -- | productOfEdgesInBoundedWalk occ g u v bound returns -- Just e iff there is a walk c (a list of -- edges) in g, from u to v, for which the -- product foldr1 otimes (map occ c) -- <= bound. In this case the returned value e is -- the product foldr1 otimes c for one such walk. -- -- Preconditions: u and v must belong to g, -- and bound must belong to the domain of -- boundToEverySome. productOfEdgesInBoundedWalk :: (SemiRing e, Ord n) => (e -> Occurrence) -> Graph n n e -> n -> n -> Occurrence -> Maybe e -- | Tests. tests :: IO Bool instance GHC.Enum.Bounded Agda.TypeChecking.Positivity.Occurrence.Occurrence instance GHC.Enum.Enum Agda.TypeChecking.Positivity.Occurrence.Occurrence instance GHC.Classes.Ord Agda.TypeChecking.Positivity.Occurrence.Occurrence instance GHC.Classes.Eq Agda.TypeChecking.Positivity.Occurrence.Occurrence instance GHC.Show.Show Agda.TypeChecking.Positivity.Occurrence.Occurrence instance Control.DeepSeq.NFData Agda.TypeChecking.Positivity.Occurrence.Occurrence instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Positivity.Occurrence.Occurrence instance Test.QuickCheck.Arbitrary.Arbitrary Agda.TypeChecking.Positivity.Occurrence.Occurrence instance Test.QuickCheck.Arbitrary.CoArbitrary Agda.TypeChecking.Positivity.Occurrence.Occurrence instance Agda.Utils.SemiRing.SemiRing Agda.TypeChecking.Positivity.Occurrence.Occurrence instance Agda.Utils.SemiRing.StarSemiRing Agda.TypeChecking.Positivity.Occurrence.Occurrence instance Agda.Utils.Null.Null Agda.TypeChecking.Positivity.Occurrence.Occurrence -- | Properties for graph library. module Agda.Utils.Graph.AdjacencyMap.Unidirectional.Tests -- | All tests as collected by quickCheckAll. -- -- Using quickCheckAll is convenient and superior to the manual -- enumeration of tests, since the name of the property is added -- automatically. tests :: IO Bool instance GHC.Show.Show Agda.Utils.Graph.AdjacencyMap.Unidirectional.Tests.Connected instance GHC.Classes.Eq Agda.Utils.Graph.AdjacencyMap.Unidirectional.Tests.Connected instance GHC.Classes.Ord Agda.Utils.Graph.AdjacencyMap.Unidirectional.Tests.N instance GHC.Classes.Eq Agda.Utils.Graph.AdjacencyMap.Unidirectional.Tests.N instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Utils.Graph.AdjacencyMap.Unidirectional.Tests.N instance GHC.Show.Show Agda.Utils.Graph.AdjacencyMap.Unidirectional.Tests.N instance Agda.Utils.SemiRing.SemiRing Agda.Utils.Graph.AdjacencyMap.Unidirectional.Tests.Connected instance Agda.Utils.SemiRing.StarSemiRing Agda.Utils.Graph.AdjacencyMap.Unidirectional.Tests.Connected module Agda.Utils.Permutation -- | Partial permutations. Examples: -- -- permute [1,2,0] [x0,x1,x2] = [x1,x2,x0] (proper permutation). -- -- permute [1,0] [x0,x1,x2] = [x1,x0] (partial permuation). -- -- permute [1,0,1,2] [x0,x1,x2] = [x1,x0,x1,x2] (not a -- permutation because not invertible). -- -- Agda typing would be: Perm : {m : Nat}(n : Nat) -> Vec (Fin n) -- m -> Permutation m is the size of the -- permutation. data Permutation Perm :: Int -> [Int] -> Permutation [permRange] :: Permutation -> Int [permPicks] :: Permutation -> [Int] -- | permute [1,2,0] [x0,x1,x2] = [x1,x2,x0] More precisely, -- permute indices list = sublist, generates sublist -- from list by picking the elements of list as indicated by -- indices. permute [1,3,0] [x0,x1,x2,x3] = [x1,x3,x0] -- -- Agda typing: permute (Perm {m} n is) : Vec A m -> Vec A n permute :: Permutation -> [a] -> [a] safePermute :: Permutation -> [a] -> [Maybe a] -- | Invert a Permutation on a partial finite int map. inversePermute -- perm f = f' such that permute perm f' = f -- -- Example, with map represented as [Maybe a]: f = -- [Nothing, Just a, Just b ] perm = Perm 4 [3,0,2] f' = [ Just a , -- Nothing , Just b , Nothing ] Zipping perm with -- f gives [(0,a),(2,b)], after compression with -- catMaybes. This is an IntMap which can easily -- written out into a substitution again. class InversePermute a b inversePermute :: InversePermute a b => Permutation -> a -> b -- | Identity permutation. idP :: Int -> Permutation -- | Restrict a permutation to work on n elements, discarding -- picks >=n. takeP :: Int -> Permutation -> Permutation -- | Pick the elements that are not picked by the permutation. droppedP :: Permutation -> Permutation -- | liftP k takes a Perm {m} n to a Perm {m+k} -- (n+k). Analogous to liftS, but Permutations operate on de -- Bruijn LEVELS, not indices. liftP :: Int -> Permutation -> Permutation -- |
-- permute (compose p1 p2) == permute p1 . permute p2 --composeP :: Permutation -> Permutation -> Permutation -- | invertP err p is the inverse of p where defined, -- otherwise defaults to err. composeP p (invertP err p) == -- p invertP :: Int -> Permutation -> Permutation -- | Turn a possible non-surjective permutation into a surjective -- permutation. compactP :: Permutation -> Permutation -- |
-- permute (reverseP p) xs == -- reverse $ permute p $ reverse xs ---- -- Example: permute (reverseP (Perm 4 [1,3,0])) [x0,x1,x2,x3] == -- permute (Perm 4 $ map (3-) [0,3,1]) [x0,x1,x2,x3] == permute (Perm 4 -- [3,0,2]) [x0,x1,x2,x3] == [x3,x0,x2] == reverse [x2,x0,x3] == reverse -- $ permute (Perm 4 [1,3,0]) [x3,x2,x1,x0] == reverse $ permute (Perm 4 -- [1,3,0]) $ reverse [x0,x1,x2,x3] -- -- With reverseP, you can convert a permutation on de Bruijn -- indices to one on de Bruijn levels, and vice versa. reverseP :: Permutation -> Permutation -- | permPicks (flipP p) = permute p (downFrom (permRange p)) or -- permute (flipP (Perm n xs)) [0..n-1] = permute (Perm n xs) -- (downFrom n) -- -- Can be use to turn a permutation from (de Bruijn) levels to levels to -- one from levels to indices. -- -- See numberPatVars. flipP :: Permutation -> Permutation -- | expandP i n π in the domain of π replace the -- ith element by n elements. expandP :: Int -> Int -> Permutation -> Permutation -- | Stable topologic sort. The first argument decides whether its first -- argument is an immediate parent to its second argument. topoSort :: (a -> a -> Bool) -> [a] -> Maybe Permutation -- | Delayed dropping which allows undropping. data Drop a Drop :: Int -> a -> Drop a -- | Non-negative number of things to drop. [dropN] :: Drop a -> Int -- | Where to drop from. [dropFrom] :: Drop a -> a -- | Things that support delayed dropping. class DoDrop a where dropMore n (Drop m xs) = Drop (m + n) xs unDrop n (Drop m xs) | n <= m = Drop (m - n) xs | otherwise = (throwImpossible (Impossible "src/full/Agda/Utils/Permutation.hs" 249)) doDrop :: DoDrop a => Drop a -> a dropMore :: DoDrop a => Int -> Drop a -> Drop a unDrop :: DoDrop a => Int -> Drop a -> Drop a instance Data.Traversable.Traversable Agda.Utils.Permutation.Drop instance Data.Foldable.Foldable Agda.Utils.Permutation.Drop instance GHC.Base.Functor Agda.Utils.Permutation.Drop instance GHC.Show.Show a => GHC.Show.Show (Agda.Utils.Permutation.Drop a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Agda.Utils.Permutation.Drop a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Utils.Permutation.Drop a) instance GHC.Classes.Eq Agda.Utils.Permutation.Permutation instance GHC.Show.Show Agda.Utils.Permutation.Permutation instance Agda.Utils.Size.Sized Agda.Utils.Permutation.Permutation instance Agda.Utils.Null.Null Agda.Utils.Permutation.Permutation instance Agda.Syntax.Position.KillRange Agda.Utils.Permutation.Permutation instance Agda.Utils.Permutation.InversePermute [GHC.Base.Maybe a] [(GHC.Types.Int, a)] instance Agda.Utils.Permutation.InversePermute [GHC.Base.Maybe a] (Data.IntMap.Base.IntMap a) instance Agda.Utils.Permutation.InversePermute [GHC.Base.Maybe a] [GHC.Base.Maybe a] instance Agda.Utils.Permutation.InversePermute (GHC.Types.Int -> a) [GHC.Base.Maybe a] instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Utils.Permutation.Drop a) instance Agda.Utils.Permutation.DoDrop [a] instance Agda.Utils.Permutation.DoDrop Agda.Utils.Permutation.Permutation instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Utils.Permutation.Permutation module Agda.Utils.Permutation.Tests -- | All tests as collected by quickCheckAll. tests :: IO Bool instance GHC.Show.Show Agda.Utils.Permutation.Tests.ComposablePermutations instance GHC.Classes.Eq Agda.Utils.Permutation.Tests.ComposablePermutations instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Utils.Permutation.Tests.ComposablePermutations module Agda.Syntax.Parser.Monad -- | The parse monad. Equivalent to StateT ParseState (Either -- ParseError) except for the definition of fail, -- which builds a suitable ParseError object. data Parser a -- | The result of parsing something. data ParseResult a ParseOk :: ParseState -> a -> ParseResult a ParseFailed :: ParseError -> ParseResult a -- | The parser state. Contains everything the parser and the lexer could -- ever need. data ParseState PState :: !SrcFile -> !PositionWithoutFile -> !PositionWithoutFile -> String -> !Char -> String -> [LayoutContext] -> [LexState] -> ParseFlags -> ParseState [parseSrcFile] :: ParseState -> !SrcFile -- | position at current input location [parsePos] :: ParseState -> !PositionWithoutFile -- | position of last token [parseLastPos] :: ParseState -> !PositionWithoutFile -- | the current input [parseInp] :: ParseState -> String -- | the character before the input [parsePrevChar] :: ParseState -> !Char -- | the previous token [parsePrevToken] :: ParseState -> String -- | the stack of layout contexts [parseLayout] :: ParseState -> [LayoutContext] -- | the state of the lexer (states can be nested so we need a stack) [parseLexState] :: ParseState -> [LexState] -- | currently there are no flags [parseFlags] :: ParseState -> ParseFlags -- | What you get if parsing fails. data ParseError ParseError :: !SrcFile -> !PositionWithoutFile -> String -> String -> String -> ParseError -- | The file in which the error occurred. [errSrcFile] :: ParseError -> !SrcFile -- | Where the error occurred. [errPos] :: ParseError -> !PositionWithoutFile -- | The remaining input. [errInput] :: ParseError -> String -- | The previous token. [errPrevToken] :: ParseError -> String -- | Hopefully an explanation of what happened. [errMsg] :: ParseError -> String -- | To do context sensitive lexing alex provides what is called start -- codes in the Alex documentation. It is really an integer -- representing the state of the lexer, so we call it LexState -- instead. type LexState = Int -- | We need to keep track of the context to do layout. The context -- specifies the indentation (if any) of a layout block. See -- Agda.Syntax.Parser.Layout for more informaton. data LayoutContext -- | no layout NoLayout :: LayoutContext -- | layout at specified column Layout :: Int32 -> LayoutContext -- | There aren't any parser flags at the moment. data ParseFlags ParseFlags :: Bool -> ParseFlags -- | Should comment tokens be returned by the lexer? [parseKeepComments] :: ParseFlags -> Bool -- | Constructs the initial state of the parser. The string argument is the -- input string, the file path is only there because it's part of a -- position. initState :: Maybe AbsolutePath -> ParseFlags -> String -> [LexState] -> ParseState -- | The default flags. defaultParseFlags :: ParseFlags -- | The most general way of parsing a string. The -- Agda.Syntax.Parser will define more specialised functions that -- supply the ParseFlags and the LexState. parse :: ParseFlags -> [LexState] -> Parser a -> String -> ParseResult a -- | The even more general way of parsing a string. parsePosString :: Position -> ParseFlags -> [LexState] -> Parser a -> String -> ParseResult a -- | The most general way of parsing a file. The Agda.Syntax.Parser -- will define more specialised functions that supply the -- ParseFlags and the LexState. -- -- Note that Agda source files always use the UTF-8 character encoding. parseFile :: ParseFlags -> [LexState] -> Parser a -> AbsolutePath -> IO (ParseResult a) setParsePos :: PositionWithoutFile -> Parser () setLastPos :: PositionWithoutFile -> Parser () -- | The parse interval is between the last position and the current -- position. getParseInterval :: Parser Interval setPrevToken :: String -> Parser () getParseFlags :: Parser ParseFlags getLexState :: Parser [LexState] pushLexState :: LexState -> Parser () popLexState :: Parser () -- | Return the current layout context. topContext :: Parser LayoutContext popContext :: Parser () pushContext :: LayoutContext -> Parser () -- | Should only be used at the beginning of a file. When we start parsing -- we should be in layout mode. Instead of forcing zero indentation we -- use the indentation of the first token. pushCurrentContext :: Parser () -- |
-- parseError = fail --parseError :: String -> Parser a -- | Fake a parse error at the specified position. Used, for instance, when -- lexing nested comments, which when failing will always fail at the end -- of the file. A more informative position is the beginning of the -- failing comment. parseErrorAt :: PositionWithoutFile -> String -> Parser a -- | Use parseErrorAt or parseError as appropriate. parseError' :: Maybe PositionWithoutFile -> String -> Parser a -- | For lexical errors we want to report the current position as the site -- of the error, whereas for parse errors the previous position is the -- one we're interested in (since this will be the position of the token -- we just lexed). This function does parseErrorAt the current -- position. lexError :: String -> Parser a instance GHC.Show.Show Agda.Syntax.Parser.Monad.ParseState instance GHC.Show.Show Agda.Syntax.Parser.Monad.ParseFlags instance GHC.Show.Show Agda.Syntax.Parser.Monad.LayoutContext instance GHC.Exception.Exception Agda.Syntax.Parser.Monad.ParseError instance GHC.Base.Monad Agda.Syntax.Parser.Monad.Parser instance GHC.Base.Functor Agda.Syntax.Parser.Monad.Parser instance GHC.Base.Applicative Agda.Syntax.Parser.Monad.Parser instance Control.Monad.Error.Class.MonadError Agda.Syntax.Parser.Monad.ParseError Agda.Syntax.Parser.Monad.Parser instance Control.Monad.State.Class.MonadState Agda.Syntax.Parser.Monad.ParseState Agda.Syntax.Parser.Monad.Parser instance GHC.Show.Show Agda.Syntax.Parser.Monad.ParseError instance Agda.Utils.Pretty.Pretty Agda.Syntax.Parser.Monad.ParseError instance Agda.Syntax.Position.HasRange Agda.Syntax.Parser.Monad.ParseError -- | This module defines the things required by Alex and some other Alex -- related things. module Agda.Syntax.Parser.Alex -- | This is what the lexer manipulates. data AlexInput AlexInput :: !SrcFile -> !PositionWithoutFile -> String -> !Char -> AlexInput -- | File. [lexSrcFile] :: AlexInput -> !SrcFile -- | Current position. [lexPos] :: AlexInput -> !PositionWithoutFile -- | Current input. [lexInput] :: AlexInput -> String -- | Previously read character. [lexPrevChar] :: AlexInput -> !Char -- | A lens for lexInput. lensLexInput :: Lens' String AlexInput -- | Get the previously lexed character. Same as lexPrevChar. Alex -- needs this to be defined to handle "patterns with a left-context". alexInputPrevChar :: AlexInput -> Char -- | Lex a character. No surprises. -- -- This function is used by Alex 2. alexGetChar :: AlexInput -> Maybe (Char, AlexInput) -- | A variant of alexGetChar. -- -- This function is used by Alex 3. alexGetByte :: AlexInput -> Maybe (Word8, AlexInput) -- | In the lexer, regular expressions are associated with lex actions -- who's task it is to construct the tokens. type LexAction r = PreviousInput -> CurrentInput -> TokenLength -> Parser r -- | Sometimes regular expressions aren't enough. Alex provides a way to do -- arbitrary computations to see if the input matches. This is done with -- a lex predicate. type LexPredicate = ([LexState], ParseFlags) -> PreviousInput -> TokenLength -> CurrentInput -> Bool -- | Conjunction of LexPredicates. (.&&.) :: LexPredicate -> LexPredicate -> LexPredicate -- | Disjunction of LexPredicates. (.||.) :: LexPredicate -> LexPredicate -> LexPredicate -- | Negation of LexPredicates. not' :: LexPredicate -> LexPredicate type PreviousInput = AlexInput type CurrentInput = AlexInput type TokenLength = Int getLexInput :: Parser AlexInput setLexInput :: AlexInput -> Parser () -- | When lexing by hands (for instance string literals) we need to do some -- looking ahead. The LookAhead monad keeps track of the position -- we are currently looking at, and provides facilities to synchronise -- the look-ahead position with the actual position of the Parser -- monad (see sync and rollback). module Agda.Syntax.Parser.LookAhead -- | The LookAhead monad is basically a state monad keeping with an extra -- AlexInput, wrapped around the Parser monad. data LookAhead a -- | Run a LookAhead computation. The first argument is the error -- function. runLookAhead :: (forall b. String -> LookAhead b) -> LookAhead a -> Parser a -- | Get the current look-ahead position. getInput :: LookAhead AlexInput -- | Set the look-ahead position. setInput :: AlexInput -> LookAhead () -- | Lift a computation in the Parser monad to the LookAhead -- monad. liftP :: Parser a -> LookAhead a -- | Look at the next character. Fails if there are no more characters. nextChar :: LookAhead Char -- | Consume the next character. Does nextChar followed by -- sync. eatNextChar :: LookAhead Char -- | Consume all the characters up to the current look-ahead position. sync :: LookAhead () -- | Undo look-ahead. Restores the input from the ParseState. rollback :: LookAhead () -- | Do a case on the current input string. If any of the given strings -- match we move past it and execute the corresponding action. If no -- string matches, we execute a default action, advancing the input one -- character. This function only affects the look-ahead position. match :: [(String, LookAhead a)] -> LookAhead a -> LookAhead a -- | Same as match but takes the initial character from the first -- argument instead of reading it from the input. Consequently, in the -- default case the input is not advanced. match' :: Char -> [(String, LookAhead a)] -> LookAhead a -> LookAhead a instance GHC.Base.Applicative Agda.Syntax.Parser.LookAhead.LookAhead instance GHC.Base.Functor Agda.Syntax.Parser.LookAhead.LookAhead instance GHC.Base.Monad Agda.Syntax.Parser.LookAhead.LookAhead -- | Some common syntactic entities are defined in this module. module Agda.Syntax.Common -- | Used to specify whether something should be delayed. data Delayed Delayed :: Delayed NotDelayed :: Delayed data Induction Inductive :: Induction CoInductive :: Induction data Hiding Hidden :: Hiding Instance :: Hiding NotHidden :: Hiding -- | Hiding is an idempotent partial monoid, with unit -- NotHidden. Instance and NotHidden are -- incompatible. -- | Decorating something with Hiding information. data WithHiding a WithHiding :: !Hiding -> a -> WithHiding a -- | A lens to access the Hiding attribute in data structures. -- Minimal implementation: getHiding and one of -- setHiding or mapHiding. class LensHiding a where setHiding h = mapHiding (const h) mapHiding f a = setHiding (f $ getHiding a) a getHiding :: LensHiding a => a -> Hiding setHiding :: LensHiding a => Hiding -> a -> a mapHiding :: LensHiding a => (Hiding -> Hiding) -> a -> a -- | Monoidal composition of Hiding information in some data. mergeHiding :: LensHiding a => WithHiding a -> a -- | isHidden does not apply to Instance, only to -- Hidden. isHidden :: LensHiding a => a -> Bool -- | Visible (NotHidden) arguments are notHidden. -- (DEPRECATED, use visible.) notHidden :: LensHiding a => a -> Bool -- | NotHidden arguments are visible. visible :: LensHiding a => a -> Bool -- | Instance and Hidden arguments are notVisible. notVisible :: LensHiding a => a -> Bool hide :: LensHiding a => a -> a hideOrKeepInstance :: LensHiding a => a -> a makeInstance :: LensHiding a => a -> a -- | An constructor argument is big if the sort of its type is bigger than -- the sort of the data type. Only parameters (and maybe forced -- arguments) are allowed to be big. List : Set -> Set nil : (A : -- Set) -> List A A is big in constructor nil -- as the sort Set1 of its type Set is bigger than the -- sort Set of the data type List. data Big Big :: Big Small :: Big -- | A function argument can be relevant or irrelevant. See -- Agda.TypeChecking.Irrelevance. data Relevance -- | The argument is (possibly) relevant at compile-time. Relevant :: Relevance -- | The argument may never flow into evaluation position. Therefore, it is -- irrelevant at run-time. It is treated relevantly during equality -- checking. NonStrict :: Relevance -- | The argument is irrelevant at compile- and runtime. Irrelevant :: Relevance -- | The argument can be skipped during equality checking because its value -- is already determined by the type. If a constructor argument is big, -- it has to be regarded absent, otherwise we get into paradoxes. Forced :: Big -> Relevance -- | The polarity checker has determined that this argument is unused in -- the definition. It can be skipped during equality checking but should -- be mined for solutions of meta-variables with relevance -- UnusedArg UnusedArg :: Relevance allRelevances :: [Relevance] -- | A lens to access the Relevance attribute in data structures. -- Minimal implementation: getRelevance and one of -- setRelevance or mapRelevance. class LensRelevance a where setRelevance h = mapRelevance (const h) mapRelevance f a = setRelevance (f $ getRelevance a) a getRelevance :: LensRelevance a => a -> Relevance setRelevance :: LensRelevance a => Relevance -> a -> a mapRelevance :: LensRelevance a => (Relevance -> Relevance) -> a -> a isRelevant :: LensRelevance a => a -> Bool isIrrelevant :: LensRelevance a => a -> Bool -- | Information ordering. Relevant `moreRelevant` UnusedArg -- `moreRelevant` Forced `moreRelevant` NonStrict `moreRelevant` -- Irrelevant moreRelevant :: Relevance -> Relevance -> Bool irrelevantOrUnused :: Relevance -> Bool -- | unusableRelevance rel == True iff we cannot use a variable of -- rel. unusableRelevance :: Relevance -> Bool -- | Relevance composition. Irrelevant is dominant, -- Relevant is neutral. composeRelevance :: Relevance -> Relevance -> Relevance -- | inverseComposeRelevance r x returns the most irrelevant -- y such that forall x, y we have x -- `moreRelevant` (r `composeRelevance` y) iff (r -- `inverseComposeRelevance` x) `moreRelevant` y (Galois -- connection). inverseComposeRelevance :: Relevance -> Relevance -> Relevance -- | For comparing Relevance ignoring Forced and -- UnusedArg. ignoreForced :: Relevance -> Relevance -- | Irrelevant function arguments may appear non-strictly in the codomain -- type. irrToNonStrict :: Relevance -> Relevance nonStrictToIrr :: Relevance -> Relevance -- | A function argument can be hidden and/or irrelevant. data ArgInfo ArgInfo :: Hiding -> Relevance -> ArgInfo [argInfoHiding] :: ArgInfo -> Hiding [argInfoRelevance] :: ArgInfo -> Relevance class LensArgInfo a where setArgInfo ai = mapArgInfo (const ai) mapArgInfo f a = setArgInfo (f $ getArgInfo a) a getArgInfo :: LensArgInfo a => a -> ArgInfo setArgInfo :: LensArgInfo a => ArgInfo -> a -> a mapArgInfo :: LensArgInfo a => (ArgInfo -> ArgInfo) -> a -> a defaultArgInfo :: ArgInfo data Arg e Arg :: ArgInfo -> e -> Arg e [argInfo] :: Arg e -> ArgInfo [unArg] :: Arg e -> e defaultArg :: a -> Arg a -- | xs `withArgsFrom` args translates xs into a list of -- Args, using the elements in args to fill in the -- non-unArg fields. -- -- Precondition: The two lists should have equal length. withArgsFrom :: [a] -> [Arg b] -> [Arg a] withNamedArgsFrom :: [a] -> [NamedArg b] -> [NamedArg a] class Eq a => Underscore a where isUnderscore = (== underscore) underscore :: Underscore a => a isUnderscore :: Underscore a => a -> Bool -- | Similar to Arg, but we need to distinguish an irrelevance -- annotation in a function domain (the domain itself is not irrelevant!) -- from an irrelevant argument. -- -- Dom is used in Pi of internal syntax, in -- Context and Telescope. Arg is used for actual -- arguments (Var, Con, Def etc.) and in -- Abstract syntax and other situations. data Dom e Dom :: ArgInfo -> e -> Dom e [domInfo] :: Dom e -> ArgInfo [unDom] :: Dom e -> e argFromDom :: Dom a -> Arg a domFromArg :: Arg a -> Dom a defaultDom :: a -> Dom a -- | Something potentially carrying a name. data Named name a Named :: Maybe name -> a -> Named name a [nameOf] :: Named name a -> Maybe name [namedThing] :: Named name a -> a -- | Standard naming. type Named_ = Named RString unnamed :: a -> Named name a named :: name -> a -> Named name a -- | Only Hidden arguments can have names. type NamedArg a = Arg (Named_ a) -- | Get the content of a NamedArg. namedArg :: NamedArg a -> a defaultNamedArg :: a -> NamedArg a -- | The functor instance for NamedArg would be ambiguous, so we -- give it another name here. updateNamedArg :: (a -> b) -> NamedArg a -> NamedArg b -- | Thing with range info. data Ranged a Ranged :: Range -> a -> Ranged a [rangeOf] :: Ranged a -> Range [rangedThing] :: Ranged a -> a -- | Thing with no range info. unranged :: a -> Ranged a -- | Ranges are not forced. -- | A RawName is some sort of string. type RawName = String rawNameToString :: RawName -> String stringToRawName :: String -> RawName -- | String with range info. type RString = Ranged RawName -- | Where does the ConP of come from? data ConPOrigin -- | Expanded from an implicit pattern. ConPImplicit :: ConPOrigin -- | User wrote a constructor pattern. ConPCon :: ConPOrigin -- | User wrote a record pattern. ConPRec :: ConPOrigin -- | Functions can be defined in both infix and prefix style. See -- LHS. data IsInfix InfixDef :: IsInfix PrefixDef :: IsInfix -- | Access modifier. data Access PrivateAccess :: Access PublicAccess :: Access -- | Visible from outside, but not exported when opening the module Used -- for qualified constructors. OnlyQualified :: Access -- | Abstract or concrete data IsAbstract AbstractDef :: IsAbstract ConcreteDef :: IsAbstract -- | Is this definition eligible for instance search? data IsInstance InstanceDef :: IsInstance NotInstanceDef :: IsInstance -- | Is this a macro definition? data IsMacro MacroDef :: IsMacro NotMacroDef :: IsMacro type Nat = Int type Arity = Nat -- | The unique identifier of a name. Second argument is the top-level -- module identifier. data NameId NameId :: !Integer -> !Integer -> NameId -- | A meta variable identifier is just a natural number. newtype MetaId MetaId :: Nat -> MetaId [metaId] :: MetaId -> Nat -- | Show non-record version of this newtype. newtype Constr a Constr :: a -> Constr a -- | The position of a name part or underscore in a name. data PositionInName -- | The following underscore is at the beginning of the name: -- _foo. Beginning :: PositionInName -- | The following underscore is in the middle of the name: -- foo_bar. Middle :: PositionInName -- | The following underscore is at the end of the name: foo_. End :: PositionInName -- | Placeholders are used to represent the underscores in a section. data MaybePlaceholder e Placeholder :: !PositionInName -> MaybePlaceholder e -- | The second argument is used only (but not always) for name parts other -- than underscores. NoPlaceholder :: !(Maybe PositionInName) -> e -> MaybePlaceholder e -- | An abbreviation: noPlaceholder = NoPlaceholder -- Nothing. noPlaceholder :: e -> MaybePlaceholder e newtype InteractionId InteractionId :: Nat -> InteractionId [interactionId] :: InteractionId -> Nat -- | The things you are allowed to say when you shuffle names between name -- spaces (i.e. in import, namespace, or open -- declarations). data ImportDirective' a b ImportDirective :: Range -> Using' a b -> [ImportedName' a b] -> [Renaming' a b] -> Bool -> ImportDirective' a b [importDirRange] :: ImportDirective' a b -> Range [using] :: ImportDirective' a b -> Using' a b [hiding] :: ImportDirective' a b -> [ImportedName' a b] [impRenaming] :: ImportDirective' a b -> [Renaming' a b] -- | Only for open. Exports the opened names from the current -- module. [publicOpen] :: ImportDirective' a b -> Bool data Using' a b UseEverything :: Using' a b Using :: [ImportedName' a b] -> Using' a b -- | Default is directive is private (use everything, but do not -- export). defaultImportDir :: ImportDirective' a b isDefaultImportDir :: ImportDirective' a b -> Bool -- | An imported name can be a module or a defined name data ImportedName' a b ImportedModule :: b -> ImportedName' a b ImportedName :: a -> ImportedName' a b setImportedName :: ImportedName' a a -> a -> ImportedName' a a data Renaming' a b Renaming :: ImportedName' a b -> ImportedName' a b -> Range -> Renaming' a b -- | Rename from this name. [renFrom] :: Renaming' a b -> ImportedName' a b -- | To this one. Must be same kind as renFrom. [renTo] :: Renaming' a b -> ImportedName' a b -- | The range of the "to" keyword. Retained for highlighting purposes. [renToRange] :: Renaming' a b -> Range -- | Ranges are not forced. -- | Ranges are not forced. -- | Termination check? (Default = TerminationCheck). data TerminationCheck m -- | Run the termination checker. TerminationCheck :: TerminationCheck m -- | Skip termination checking (unsafe). NoTerminationCheck :: TerminationCheck m -- | Treat as non-terminating. NonTerminating :: TerminationCheck m -- | Treat as terminating (unsafe). Same effect as -- NoTerminationCheck. Terminating :: TerminationCheck m -- | Skip termination checking but use measure instead. TerminationMeasure :: Range -> m -> TerminationCheck m -- | Positivity check? (Default = True). type PositivityCheck = Bool instance GHC.Base.Functor Agda.Syntax.Common.TerminationCheck instance GHC.Classes.Eq m => GHC.Classes.Eq (Agda.Syntax.Common.TerminationCheck m) instance GHC.Show.Show m => GHC.Show.Show (Agda.Syntax.Common.TerminationCheck m) instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (Agda.Syntax.Common.ImportDirective' a b) instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (Agda.Syntax.Common.Renaming' a b) instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (Agda.Syntax.Common.Using' a b) instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Agda.Syntax.Common.ImportedName' a b) instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Agda.Syntax.Common.ImportedName' a b) instance GHC.Enum.Enum Agda.Syntax.Common.InteractionId instance GHC.Real.Real Agda.Syntax.Common.InteractionId instance GHC.Real.Integral Agda.Syntax.Common.InteractionId instance GHC.Num.Num Agda.Syntax.Common.InteractionId instance GHC.Classes.Ord Agda.Syntax.Common.InteractionId instance GHC.Classes.Eq Agda.Syntax.Common.InteractionId instance GHC.Show.Show e => GHC.Show.Show (Agda.Syntax.Common.MaybePlaceholder e) instance Data.Traversable.Traversable Agda.Syntax.Common.MaybePlaceholder instance Data.Foldable.Foldable Agda.Syntax.Common.MaybePlaceholder instance GHC.Base.Functor Agda.Syntax.Common.MaybePlaceholder instance GHC.Classes.Ord e => GHC.Classes.Ord (Agda.Syntax.Common.MaybePlaceholder e) instance GHC.Classes.Eq e => GHC.Classes.Eq (Agda.Syntax.Common.MaybePlaceholder e) instance GHC.Classes.Ord Agda.Syntax.Common.PositionInName instance GHC.Classes.Eq Agda.Syntax.Common.PositionInName instance GHC.Show.Show Agda.Syntax.Common.PositionInName instance GHC.Real.Integral Agda.Syntax.Common.MetaId instance GHC.Enum.Enum Agda.Syntax.Common.MetaId instance GHC.Real.Real Agda.Syntax.Common.MetaId instance GHC.Num.Num Agda.Syntax.Common.MetaId instance GHC.Classes.Ord Agda.Syntax.Common.MetaId instance GHC.Classes.Eq Agda.Syntax.Common.MetaId instance GHC.Generics.Generic Agda.Syntax.Common.NameId instance GHC.Classes.Ord Agda.Syntax.Common.NameId instance GHC.Classes.Eq Agda.Syntax.Common.NameId instance GHC.Classes.Ord Agda.Syntax.Common.IsMacro instance GHC.Classes.Eq Agda.Syntax.Common.IsMacro instance GHC.Show.Show Agda.Syntax.Common.IsMacro instance GHC.Classes.Ord Agda.Syntax.Common.IsInstance instance GHC.Classes.Eq Agda.Syntax.Common.IsInstance instance GHC.Show.Show Agda.Syntax.Common.IsInstance instance GHC.Classes.Ord Agda.Syntax.Common.IsAbstract instance GHC.Classes.Eq Agda.Syntax.Common.IsAbstract instance GHC.Show.Show Agda.Syntax.Common.IsAbstract instance GHC.Classes.Ord Agda.Syntax.Common.Access instance GHC.Classes.Eq Agda.Syntax.Common.Access instance GHC.Show.Show Agda.Syntax.Common.Access instance GHC.Classes.Ord Agda.Syntax.Common.IsInfix instance GHC.Classes.Eq Agda.Syntax.Common.IsInfix instance GHC.Show.Show Agda.Syntax.Common.IsInfix instance GHC.Enum.Bounded Agda.Syntax.Common.ConPOrigin instance GHC.Enum.Enum Agda.Syntax.Common.ConPOrigin instance GHC.Classes.Ord Agda.Syntax.Common.ConPOrigin instance GHC.Classes.Eq Agda.Syntax.Common.ConPOrigin instance GHC.Show.Show Agda.Syntax.Common.ConPOrigin instance Data.Traversable.Traversable Agda.Syntax.Common.Ranged instance Data.Foldable.Foldable Agda.Syntax.Common.Ranged instance GHC.Base.Functor Agda.Syntax.Common.Ranged instance Data.Traversable.Traversable (Agda.Syntax.Common.Named name) instance Data.Foldable.Foldable (Agda.Syntax.Common.Named name) instance GHC.Base.Functor (Agda.Syntax.Common.Named name) instance (GHC.Classes.Ord a, GHC.Classes.Ord name) => GHC.Classes.Ord (Agda.Syntax.Common.Named name a) instance (GHC.Classes.Eq a, GHC.Classes.Eq name) => GHC.Classes.Eq (Agda.Syntax.Common.Named name a) instance Data.Traversable.Traversable Agda.Syntax.Common.Dom instance Data.Foldable.Foldable Agda.Syntax.Common.Dom instance GHC.Base.Functor Agda.Syntax.Common.Dom instance GHC.Classes.Ord e => GHC.Classes.Ord (Agda.Syntax.Common.Dom e) instance GHC.Classes.Eq e => GHC.Classes.Eq (Agda.Syntax.Common.Dom e) instance Data.Traversable.Traversable Agda.Syntax.Common.Arg instance Data.Foldable.Foldable Agda.Syntax.Common.Arg instance GHC.Base.Functor Agda.Syntax.Common.Arg instance GHC.Classes.Ord e => GHC.Classes.Ord (Agda.Syntax.Common.Arg e) instance GHC.Show.Show Agda.Syntax.Common.ArgInfo instance GHC.Classes.Ord Agda.Syntax.Common.ArgInfo instance GHC.Classes.Eq Agda.Syntax.Common.ArgInfo instance GHC.Classes.Eq Agda.Syntax.Common.Relevance instance GHC.Show.Show Agda.Syntax.Common.Relevance instance GHC.Enum.Bounded Agda.Syntax.Common.Big instance GHC.Enum.Enum Agda.Syntax.Common.Big instance GHC.Classes.Eq Agda.Syntax.Common.Big instance GHC.Show.Show Agda.Syntax.Common.Big instance Data.Traversable.Traversable Agda.Syntax.Common.WithHiding instance Data.Foldable.Foldable Agda.Syntax.Common.WithHiding instance GHC.Base.Functor Agda.Syntax.Common.WithHiding instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Common.WithHiding a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Agda.Syntax.Common.WithHiding a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Syntax.Common.WithHiding a) instance GHC.Classes.Ord Agda.Syntax.Common.Hiding instance GHC.Classes.Eq Agda.Syntax.Common.Hiding instance GHC.Show.Show Agda.Syntax.Common.Hiding instance GHC.Classes.Ord Agda.Syntax.Common.Induction instance GHC.Classes.Eq Agda.Syntax.Common.Induction instance GHC.Classes.Ord Agda.Syntax.Common.Delayed instance GHC.Classes.Eq Agda.Syntax.Common.Delayed instance GHC.Show.Show Agda.Syntax.Common.Delayed instance Agda.Syntax.Position.KillRange Agda.Syntax.Common.Delayed instance GHC.Show.Show Agda.Syntax.Common.Induction instance Agda.Syntax.Position.HasRange Agda.Syntax.Common.Induction instance Agda.Syntax.Position.KillRange Agda.Syntax.Common.Induction instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Syntax.Common.Induction instance Test.QuickCheck.Arbitrary.CoArbitrary Agda.Syntax.Common.Induction instance Control.DeepSeq.NFData Agda.Syntax.Common.Induction instance GHC.Base.Monoid Agda.Syntax.Common.Hiding instance Agda.Syntax.Position.KillRange Agda.Syntax.Common.Hiding instance Control.DeepSeq.NFData Agda.Syntax.Common.Hiding instance Agda.Utils.Functor.Decoration Agda.Syntax.Common.WithHiding instance GHC.Base.Applicative Agda.Syntax.Common.WithHiding instance Agda.Syntax.Position.HasRange a => Agda.Syntax.Position.HasRange (Agda.Syntax.Common.WithHiding a) instance Agda.Syntax.Position.SetRange a => Agda.Syntax.Position.SetRange (Agda.Syntax.Common.WithHiding a) instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Syntax.Common.WithHiding a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Agda.Syntax.Common.WithHiding a) instance Agda.Syntax.Common.LensHiding Agda.Syntax.Common.Hiding instance Agda.Syntax.Common.LensHiding (Agda.Syntax.Common.WithHiding a) instance GHC.Classes.Ord Agda.Syntax.Common.Big instance Control.DeepSeq.NFData Agda.Syntax.Common.Big instance Agda.Syntax.Position.KillRange Agda.Syntax.Common.Relevance instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Syntax.Common.Relevance instance GHC.Classes.Ord Agda.Syntax.Common.Relevance instance Control.DeepSeq.NFData Agda.Syntax.Common.Relevance instance Agda.Syntax.Common.LensRelevance Agda.Syntax.Common.Relevance instance Agda.Syntax.Position.KillRange Agda.Syntax.Common.ArgInfo instance Agda.Syntax.Common.LensArgInfo Agda.Syntax.Common.ArgInfo instance Control.DeepSeq.NFData Agda.Syntax.Common.ArgInfo instance Agda.Syntax.Common.LensHiding Agda.Syntax.Common.ArgInfo instance Agda.Syntax.Common.LensRelevance Agda.Syntax.Common.ArgInfo instance Agda.Utils.Functor.Decoration Agda.Syntax.Common.Arg instance Agda.Syntax.Position.HasRange a => Agda.Syntax.Position.HasRange (Agda.Syntax.Common.Arg a) instance Agda.Syntax.Position.SetRange a => Agda.Syntax.Position.SetRange (Agda.Syntax.Common.Arg a) instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Syntax.Common.Arg a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Syntax.Common.Arg a) instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Common.Arg a) instance Control.DeepSeq.NFData e => Control.DeepSeq.NFData (Agda.Syntax.Common.Arg e) instance Agda.Syntax.Common.LensHiding (Agda.Syntax.Common.Arg e) instance Agda.Syntax.Common.LensRelevance (Agda.Syntax.Common.Arg e) instance Agda.Syntax.Common.LensArgInfo (Agda.Syntax.Common.Arg a) instance Agda.Syntax.Common.Underscore GHC.Base.String instance Agda.Syntax.Common.Underscore Data.ByteString.Internal.ByteString instance Agda.Syntax.Common.Underscore Text.PrettyPrint.HughesPJ.Doc instance Agda.Utils.Functor.Decoration Agda.Syntax.Common.Dom instance Agda.Syntax.Position.HasRange a => Agda.Syntax.Position.HasRange (Agda.Syntax.Common.Dom a) instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Syntax.Common.Dom a) instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Common.Dom a) instance Agda.Syntax.Common.LensHiding (Agda.Syntax.Common.Dom e) instance Agda.Syntax.Common.LensRelevance (Agda.Syntax.Common.Dom e) instance Agda.Syntax.Common.LensArgInfo (Agda.Syntax.Common.Dom e) instance Agda.Utils.Functor.Decoration (Agda.Syntax.Common.Named name) instance Agda.Syntax.Position.HasRange a => Agda.Syntax.Position.HasRange (Agda.Syntax.Common.Named name a) instance Agda.Syntax.Position.SetRange a => Agda.Syntax.Position.SetRange (Agda.Syntax.Common.Named name a) instance (Agda.Syntax.Position.KillRange name, Agda.Syntax.Position.KillRange a) => Agda.Syntax.Position.KillRange (Agda.Syntax.Common.Named name a) instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Common.Named_ a) instance (Control.DeepSeq.NFData name, Control.DeepSeq.NFData a) => Control.DeepSeq.NFData (Agda.Syntax.Common.Named name a) instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Common.Ranged a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Syntax.Common.Ranged a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Agda.Syntax.Common.Ranged a) instance Agda.Syntax.Position.HasRange (Agda.Syntax.Common.Ranged a) instance Agda.Syntax.Position.KillRange (Agda.Syntax.Common.Ranged a) instance Agda.Utils.Functor.Decoration Agda.Syntax.Common.Ranged instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Agda.Syntax.Common.Ranged a) instance Agda.Syntax.Position.KillRange Agda.Syntax.Common.IsAbstract instance Agda.Syntax.Position.KillRange Agda.Syntax.Common.IsInstance instance Agda.Syntax.Position.HasRange Agda.Syntax.Common.IsInstance instance Control.DeepSeq.NFData Agda.Syntax.Common.IsInstance instance Agda.Syntax.Position.KillRange Agda.Syntax.Common.IsMacro instance Agda.Syntax.Position.HasRange Agda.Syntax.Common.IsMacro instance Agda.Syntax.Position.KillRange Agda.Syntax.Common.NameId instance GHC.Show.Show Agda.Syntax.Common.NameId instance GHC.Enum.Enum Agda.Syntax.Common.NameId instance Control.DeepSeq.NFData Agda.Syntax.Common.NameId instance Data.Hashable.Class.Hashable Agda.Syntax.Common.NameId instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Syntax.Common.NameId instance Test.QuickCheck.Arbitrary.CoArbitrary Agda.Syntax.Common.NameId instance Agda.Utils.Pretty.Pretty Agda.Syntax.Common.MetaId instance GHC.Show.Show Agda.Syntax.Common.MetaId instance Control.DeepSeq.NFData Agda.Syntax.Common.MetaId instance Agda.Syntax.Position.HasRange a => Agda.Syntax.Position.HasRange (Agda.Syntax.Common.MaybePlaceholder a) instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Syntax.Common.MaybePlaceholder a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Agda.Syntax.Common.MaybePlaceholder a) instance GHC.Show.Show Agda.Syntax.Common.InteractionId instance Agda.Syntax.Position.KillRange Agda.Syntax.Common.InteractionId instance GHC.Base.Monoid (Agda.Syntax.Common.Using' a b) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Agda.Syntax.Common.ImportedName' a b) instance (Agda.Syntax.Position.HasRange a, Agda.Syntax.Position.HasRange b) => Agda.Syntax.Position.HasRange (Agda.Syntax.Common.ImportDirective' a b) instance (Agda.Syntax.Position.HasRange a, Agda.Syntax.Position.HasRange b) => Agda.Syntax.Position.HasRange (Agda.Syntax.Common.Using' a b) instance (Agda.Syntax.Position.HasRange a, Agda.Syntax.Position.HasRange b) => Agda.Syntax.Position.HasRange (Agda.Syntax.Common.Renaming' a b) instance (Agda.Syntax.Position.HasRange a, Agda.Syntax.Position.HasRange b) => Agda.Syntax.Position.HasRange (Agda.Syntax.Common.ImportedName' a b) instance (Agda.Syntax.Position.KillRange a, Agda.Syntax.Position.KillRange b) => Agda.Syntax.Position.KillRange (Agda.Syntax.Common.ImportDirective' a b) instance (Agda.Syntax.Position.KillRange a, Agda.Syntax.Position.KillRange b) => Agda.Syntax.Position.KillRange (Agda.Syntax.Common.Using' a b) instance (Agda.Syntax.Position.KillRange a, Agda.Syntax.Position.KillRange b) => Agda.Syntax.Position.KillRange (Agda.Syntax.Common.Renaming' a b) instance (Agda.Syntax.Position.KillRange a, Agda.Syntax.Position.KillRange b) => Agda.Syntax.Position.KillRange (Agda.Syntax.Common.ImportedName' a b) instance (Control.DeepSeq.NFData a, Control.DeepSeq.NFData b) => Control.DeepSeq.NFData (Agda.Syntax.Common.ImportDirective' a b) instance (Control.DeepSeq.NFData a, Control.DeepSeq.NFData b) => Control.DeepSeq.NFData (Agda.Syntax.Common.Using' a b) instance (Control.DeepSeq.NFData a, Control.DeepSeq.NFData b) => Control.DeepSeq.NFData (Agda.Syntax.Common.Renaming' a b) instance (Control.DeepSeq.NFData a, Control.DeepSeq.NFData b) => Control.DeepSeq.NFData (Agda.Syntax.Common.ImportedName' a b) instance Agda.Syntax.Position.KillRange m => Agda.Syntax.Position.KillRange (Agda.Syntax.Common.TerminationCheck m) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Agda.Syntax.Common.TerminationCheck a) -- | Names in the concrete syntax are just strings (or lists of strings for -- qualified names). module Agda.Syntax.Concrete.Name -- | A name is a non-empty list of alternating Ids and Holes. -- A normal name is represented by a singleton list, and operators are -- represented by a list with Holes where the arguments should go. -- For instance: [Hole,Id "+",Hole] is infix addition. -- -- Equality and ordering on Names are defined to ignore range so -- same names in different locations are equal. data Name -- | A (mixfix) identifier. Name :: Range -> [NamePart] -> Name -- | _. NoName :: Range -> NameId -> Name -- | Mixfix identifiers are composed of words and holes, e.g. _+_ -- or if_then_else_ or [_/_]. data NamePart -- | _ part. Hole :: NamePart -- | Identifier part. Id :: RawName -> NamePart -- | Define equality on Name to ignore range so same names in -- different locations are equal. -- -- Is there a reason not to do this? -Jeff -- -- No. But there are tons of reasons to do it. For instance, when using -- names as keys in maps you really don't want to have to get the range -- right to be able to do a lookup. -Ulf -- | QName is a list of namespaces and the name of the constant. -- For the moment assumes namespaces are just Names and not -- explicitly applied modules. Also assumes namespaces are generative by -- just using derived equality. We will have to define an equality -- instance to non-generative namespaces (as well as having some sort of -- lookup table for namespace names). data QName -- | A.rest. Qual :: Name -> QName -> QName -- | x. QName :: Name -> QName -- | Top-level module names. Used in connection with the file system. -- -- Invariant: The list must not be empty. newtype TopLevelModuleName TopLevelModuleName :: [String] -> TopLevelModuleName [moduleNameParts] :: TopLevelModuleName -> [String] nameToRawName :: Name -> RawName nameParts :: Name -> [NamePart] nameStringParts :: Name -> [RawName] -- | Parse a string to parts of a concrete name. -- -- Note: stringNameParts "_" == [Id "_"] == nameParts NoName{} stringNameParts :: String -> [NamePart] -- | Number of holes in a Name (i.e., arity of a mixfix-operator). class NumHoles a numHoles :: NumHoles a => a -> Int -- | Is the name an operator? isOperator :: Name -> Bool isHole :: NamePart -> Bool isPrefix :: Name -> Bool isPostfix :: Name -> Bool isInfix :: Name -> Bool isNonfix :: Name -> Bool -- |
-- qualify A.B x == A.B.x --qualify :: QName -> Name -> QName -- |
-- unqualify A.B.x == x ---- -- The range is preserved. unqualify :: QName -> Name -- |
-- qnameParts A.B.x = [A, B, x] --qnameParts :: QName -> [Name] -- | Turns a qualified name into a TopLevelModuleName. The qualified -- name is assumed to represent a top-level module name. toTopLevelModuleName :: QName -> TopLevelModuleName -- | Turns a top-level module name into a file name with the given suffix. moduleNameToFileName :: TopLevelModuleName -> String -> FilePath -- | Finds the current project's "root" directory, given a project file and -- the corresponding top-level module name. -- -- Example: If the module "A.B.C" is located in the file -- "fooABC.agda", then the root is "foo". -- -- Precondition: The module name must be well-formed. projectRoot :: AbsolutePath -> TopLevelModuleName -> AbsolutePath -- |
-- noName_ = noName noRange --noName_ :: Name noName :: Range -> Name -- | Check whether a name is the empty name "_". class IsNoName a isNoName :: IsNoName a => a -> Bool -- | Ranges are not forced. instance GHC.Classes.Ord Agda.Syntax.Concrete.Name.TopLevelModuleName instance GHC.Classes.Eq Agda.Syntax.Concrete.Name.TopLevelModuleName instance GHC.Show.Show Agda.Syntax.Concrete.Name.TopLevelModuleName instance GHC.Classes.Ord Agda.Syntax.Concrete.Name.QName instance GHC.Classes.Eq Agda.Syntax.Concrete.Name.QName instance GHC.Generics.Generic Agda.Syntax.Concrete.Name.NamePart instance Agda.Syntax.Common.Underscore Agda.Syntax.Concrete.Name.Name instance GHC.Classes.Eq Agda.Syntax.Concrete.Name.Name instance GHC.Classes.Ord Agda.Syntax.Concrete.Name.Name instance GHC.Classes.Eq Agda.Syntax.Concrete.Name.NamePart instance GHC.Classes.Ord Agda.Syntax.Concrete.Name.NamePart instance Agda.Syntax.Common.Underscore Agda.Syntax.Concrete.Name.QName instance Agda.Syntax.Concrete.Name.NumHoles [Agda.Syntax.Concrete.Name.NamePart] instance Agda.Syntax.Concrete.Name.NumHoles Agda.Syntax.Concrete.Name.Name instance Agda.Syntax.Concrete.Name.NumHoles Agda.Syntax.Concrete.Name.QName instance Agda.Syntax.Concrete.Name.IsNoName GHC.Base.String instance Agda.Syntax.Concrete.Name.IsNoName Data.ByteString.Internal.ByteString instance Agda.Syntax.Concrete.Name.IsNoName Agda.Syntax.Concrete.Name.Name instance Agda.Syntax.Concrete.Name.IsNoName Agda.Syntax.Concrete.Name.QName instance GHC.Show.Show Agda.Syntax.Concrete.Name.Name instance GHC.Show.Show Agda.Syntax.Concrete.Name.NamePart instance GHC.Show.Show Agda.Syntax.Concrete.Name.QName instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.Name.Name instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.Name.NamePart instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.Name.QName instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.Name.TopLevelModuleName instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Syntax.Concrete.Name.TopLevelModuleName instance Test.QuickCheck.Arbitrary.CoArbitrary Agda.Syntax.Concrete.Name.TopLevelModuleName instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Syntax.Concrete.Name.Name instance Test.QuickCheck.Arbitrary.CoArbitrary Agda.Syntax.Concrete.Name.NamePart instance Test.QuickCheck.Arbitrary.CoArbitrary Agda.Syntax.Concrete.Name.Name instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.Name.Name instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.Name.QName instance Agda.Syntax.Position.SetRange Agda.Syntax.Concrete.Name.Name instance Agda.Syntax.Position.SetRange Agda.Syntax.Concrete.Name.QName instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.Name.QName instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.Name.Name instance Control.DeepSeq.NFData Agda.Syntax.Concrete.Name.Name instance Control.DeepSeq.NFData Agda.Syntax.Concrete.Name.NamePart instance Control.DeepSeq.NFData Agda.Syntax.Concrete.Name.QName -- | As a concrete name, a notation is a non-empty list of alternating -- IdParts and holes. In contrast to concrete names, holes can be -- binders. -- -- Example: syntax fmap (λ x → e) xs = for x ∈ xs return e -- -- The declared notation for fmap is for_∈_return_ -- where the first hole is a binder. module Agda.Syntax.Notation -- | Data type constructed in the Happy parser; converted to GenPart -- before it leaves the Happy code. data HoleName -- | x -> y; 1st argument is the bound name (unused for now). LambdaHole :: RawName -> RawName -> HoleName [_bindHoleName] :: HoleName -> RawName [holeName] :: HoleName -> RawName -- | Simple named hole with hiding. ExprHole :: RawName -> HoleName [holeName] :: HoleName -> RawName -- | Is the hole a binder? isLambdaHole :: HoleName -> Bool -- | Notation as provided by the syntax declaration. type Notation = [GenPart] -- | Part of a Notation data GenPart -- | Argument is the position of the hole (with binding) where the binding -- should occur. BindHole :: !Int -> GenPart -- | Argument is where the expression should go. NormalHole :: (NamedArg Int) -> GenPart -- | An underscore in binding position. WildHole :: !Int -> GenPart IdPart :: RawName -> GenPart -- | Get a flat list of identifier parts of a notation. stringParts :: Notation -> [RawName] -- | Target argument position of a part (Nothing if it is not a hole). holeTarget :: GenPart -> Maybe Int -- | Is the part a hole? WildHoles don't count since they don't correspond -- to anything the user writes. isAHole :: GenPart -> Bool -- | Is the part a normal hole? isNormalHole :: GenPart -> Bool -- | Is the part a binder? isBindingHole :: GenPart -> Bool -- | Classification of notations. data NotationKind -- | Ex: _bla_blub_. InfixNotation :: NotationKind -- | Ex: _bla_blub. PrefixNotation :: NotationKind -- | Ex: bla_blub_. PostfixNotation :: NotationKind -- | Ex: bla_blub. NonfixNotation :: NotationKind NoNotation :: NotationKind -- | Classify a notation by presence of leading and/or trailing -- normal holes. notationKind :: Notation -> NotationKind -- | From notation with names to notation with indices. -- -- Example: ids = ["for", "x", "∈", "xs", "return", "e"] holes = [ -- LambdaHole "x" "e", ExprHole "xs" ] creates the notation [ -- IdPart "for" , BindHole 0 , IdPart "∈" , NormalHole 1 , IdPart -- "return" , NormalHole 0 ] mkNotation :: [NamedArg HoleName] -> [RawName] -> Either String Notation noNotation :: Notation instance GHC.Show.Show Agda.Syntax.Notation.NotationKind instance GHC.Classes.Eq Agda.Syntax.Notation.NotationKind instance GHC.Classes.Ord Agda.Syntax.Notation.GenPart instance GHC.Classes.Eq Agda.Syntax.Notation.GenPart instance GHC.Show.Show Agda.Syntax.Notation.GenPart instance Agda.Syntax.Position.KillRange Agda.Syntax.Notation.GenPart instance Control.DeepSeq.NFData Agda.Syntax.Notation.GenPart -- | Construct a graph from constraints x + n y becomes x -- ---(-n)--- y x n + y becomes x ---(+n)--- y the -- default edge (= no edge) is labelled with infinity. -- -- Building the graph involves keeping track of the node names. We do -- this in a finite map, assigning consecutive numbers to nodes. module Agda.Utils.Warshall type Matrix a = Array (Int, Int) a warshall :: SemiRing a => Matrix a -> Matrix a type AdjList node edge = Map node [(node, edge)] -- | Warshall's algorithm on a graph represented as an adjacency list. warshallG :: (SemiRing edge, Ord node) => AdjList node edge -> AdjList node edge -- | Edge weight in the graph, forming a semi ring. data Weight Finite :: Int -> Weight Infinite :: Weight inc :: Weight -> Int -> Weight -- | Nodes of the graph are either - flexible variables (with identifiers -- drawn from Int), - rigid variables (also identified by -- Ints), or - constants (like 0, infinity, or anything -- between). data Node Rigid :: Rigid -> Node Flex :: FlexId -> Node data Rigid RConst :: Weight -> Rigid RVar :: RigidId -> Rigid type NodeId = Int type RigidId = Int type FlexId = Int -- | Which rigid variables a flex may be instatiated to. type Scope = RigidId -> Bool infinite :: Rigid -> Bool -- | isBelow r w r' checks, if r and r' are -- connected by w (meaning w not infinite), whether -- r + w <= r'. Precondition: not the same rigid variable. isBelow :: Rigid -> Weight -> Rigid -> Bool -- | A constraint is an edge in the graph. data Constraint NewFlex :: FlexId -> Scope -> Constraint -- | For Arc v1 k v2 at least one of v1 or v2 is -- a MetaV (Flex), the other a MetaV or a Var -- (Rigid). If k <= 0 this means suc^(-k) v1 <= -- v2 otherwise v1 <= suc^k v3. Arc :: Node -> Int -> Node -> Constraint type Constraints = [Constraint] emptyConstraints :: Constraints data Graph Graph :: Map FlexId Scope -> Map Node NodeId -> Map NodeId Node -> NodeId -> (NodeId -> NodeId -> Weight) -> Graph -- | Scope for each flexible var. [flexScope] :: Graph -> Map FlexId Scope -- | Node labels to node numbers. [nodeMap] :: Graph -> Map Node NodeId -- | Node numbers to node labels. [intMap] :: Graph -> Map NodeId Node -- | Number of nodes n. [nextNode] :: Graph -> NodeId -- | The edges (restrict to [0..n[). [graph] :: Graph -> NodeId -> NodeId -> Weight -- | The empty graph: no nodes, edges are all undefined (infinity weight). initGraph :: Graph -- | The Graph Monad, for constructing a graph iteratively. type GM = State Graph -- | Add a size meta node. addFlex :: FlexId -> Scope -> GM () -- | Lookup identifier of a node. If not present, it is added first. addNode :: Node -> GM Int -- | addEdge n1 k n2 improves the weight of egde -- n1->n2 to be at most k. Also adds nodes if not -- yet present. addEdge :: Node -> Int -> Node -> GM () addConstraint :: Constraint -> GM () buildGraph :: Constraints -> Graph mkMatrix :: Int -> (Int -> Int -> Weight) -> Matrix Weight -- | A matrix with row descriptions in b and column descriptions -- in c. data LegendMatrix a b c LegendMatrix :: Matrix a -> (Int -> b) -> (Int -> c) -> LegendMatrix a b c [matrix] :: LegendMatrix a b c -> Matrix a [rowdescr] :: LegendMatrix a b c -> Int -> b [coldescr] :: LegendMatrix a b c -> Int -> c -- | A solution assigns to each flexible variable a size expression which -- is either a constant or a v + n for a rigid variable -- v. type Solution = Map Int SizeExpr emptySolution :: Solution extendSolution :: Solution -> Int -> SizeExpr -> Solution data SizeExpr -- | e.g. x + 5 SizeVar :: RigidId -> Int -> SizeExpr -- | a number or infinity SizeConst :: Weight -> SizeExpr -- | sizeRigid r n returns the size expression corresponding to -- r + n sizeRigid :: Rigid -> Int -> SizeExpr solve :: Constraints -> Maybe Solution genGraph :: Ord node => Float -> Gen edge -> [node] -> Gen (AdjList node edge) type Distance = Weight genGraph_ :: Nat -> Gen (AdjList Nat Distance) lookupEdge :: Ord n => n -> n -> AdjList n e -> Maybe e edges :: AdjList n e -> [(n, n, e)] -- | Check that no edges get longer when completing a graph. prop_smaller :: Nat -> Property newEdge :: Nat -> Nat -> Distance -> AdjList Nat Distance -> AdjList Nat Distance genPath :: Nat -> Nat -> Nat -> AdjList Nat Distance -> Gen (AdjList Nat Distance) -- | Check that all transitive edges are added. prop_path :: Nat -> Property mapNodes :: Ord node' => (node -> node') -> AdjList node edge -> AdjList node' edge -- | Check that no edges are added between components. prop_disjoint :: Nat -> Property prop_stable :: Nat -> Property tests :: IO Bool instance GHC.Classes.Ord Agda.Utils.Warshall.Node instance GHC.Classes.Eq Agda.Utils.Warshall.Node instance GHC.Show.Show Agda.Utils.Warshall.Rigid instance GHC.Classes.Ord Agda.Utils.Warshall.Rigid instance GHC.Classes.Eq Agda.Utils.Warshall.Rigid instance GHC.Classes.Eq Agda.Utils.Warshall.Weight instance GHC.Show.Show Agda.Utils.Warshall.Weight instance GHC.Classes.Ord Agda.Utils.Warshall.Weight instance Agda.Utils.SemiRing.SemiRing Agda.Utils.Warshall.Weight instance GHC.Show.Show Agda.Utils.Warshall.Node instance GHC.Show.Show Agda.Utils.Warshall.Constraint instance (GHC.Show.Show a, GHC.Show.Show b, GHC.Show.Show c) => GHC.Show.Show (Agda.Utils.Warshall.LegendMatrix a b c) instance GHC.Show.Show Agda.Utils.Warshall.SizeExpr -- | Abstract names carry unique identifiers and stuff. module Agda.Syntax.Abstract.Name -- | A name is a unique identifier and a suggestion for a concrete name. -- The concrete name contains the source location (if any) of the name. -- The source location of the binding site is also recorded. data Name Name :: !NameId -> Name -> Range -> Fixity' -> Name [nameId] :: Name -> !NameId [nameConcrete] :: Name -> Name [nameBindingSite] :: Name -> Range [nameFixity] :: Name -> Fixity' -- | Qualified names are non-empty lists of names. Equality on qualified -- names are just equality on the last name, i.e. the module part is just -- for show. -- -- The SetRange instance for qualified names sets all individual -- ranges (including those of the module prefix) to the given one. data QName QName :: ModuleName -> Name -> QName [qnameModule] :: QName -> ModuleName [qnameName] :: QName -> Name -- | Something preceeded by a qualified name. data QNamed a QNamed :: QName -> a -> QNamed a [qname] :: QNamed a -> QName [qnamed] :: QNamed a -> a -- | A module name is just a qualified name. -- -- The SetRange instance for module names sets all individual -- ranges to the given one. newtype ModuleName MName :: [Name] -> ModuleName [mnameToList] :: ModuleName -> [Name] -- | Ambiguous qualified names. Used for overloaded constructors. -- -- Invariant: All the names in the list must have the same concrete, -- unqualified name. (This implies that they all have the same -- Range). newtype AmbiguousQName AmbQ :: [QName] -> AmbiguousQName [unAmbQ] :: AmbiguousQName -> [QName] -- | A module is anonymous if the qualification path ends in an underscore. isAnonymousModuleName :: ModuleName -> Bool -- | Sets the ranges of the individual names in the module name to match -- those of the corresponding concrete names. If the concrete names are -- fewer than the number of module name name parts, then the initial name -- parts get the range noRange. -- -- C.D.E `withRangesOf` [A, B] returns C.D.E but with -- ranges set as follows: -- --
-- tactic solve | subgoal1 | .. | subgoalN --Tactic :: Range -> Expr -> [Expr] -> Expr -- | ex: unquote, should be applied to a term of type -- Term Unquote :: Range -> Expr -- | to print irrelevant things DontCare :: Expr -> Expr -- | ex: a = b, used internally in the parser Equal :: Range -> Expr -> Expr -> Expr data OpApp e -- | An abstraction inside a special syntax declaration (see Issue 358 why -- we introduce this). SyntaxBindingLambda :: Range -> [LamBinding] -> e -> OpApp e Ordinary :: e -> OpApp e fromOrdinary :: e -> OpApp e -> e appView :: Expr -> AppView -- | The Expr is not an application. data AppView AppView :: Expr -> [NamedArg Expr] -> AppView -- | A lambda binding is either domain free or typed. type LamBinding = LamBinding' TypedBindings data LamBinding' a -- | . x or {x} or .x or .{x} or -- {.x} DomainFree :: ArgInfo -> BoundName -> LamBinding' a -- | . (xs : e) or {xs : e} DomainFull :: a -> LamBinding' a -- | A sequence of typed bindings with hiding information. Appears in -- dependent function spaces, typed lambdas, and telescopes. -- -- If the individual binding contains hiding information as well, the -- Hiding in TypedBindings must be the unit -- NotHidden. type TypedBindings = TypedBindings' TypedBinding data TypedBindings' a -- | . (xs : e) or {xs : e} or something like (x {y} -- _ : e). TypedBindings :: Range -> (Arg a) -> TypedBindings' a -- | A typed binding. type TypedBinding = TypedBinding' Expr data TypedBinding' e -- | Binding (x1 ... xn : A). TBind :: Range -> [WithHiding BoundName] -> e -> TypedBinding' e -- | Let binding (let Ds) or (open M args). TLet :: Range -> [Declaration] -> TypedBinding' e type RecordAssignment = Either FieldAssignment ModuleAssignment type RecordAssignments = [RecordAssignment] type FieldAssignment = FieldAssignment' Expr data FieldAssignment' a FieldAssignment :: Name -> a -> FieldAssignment' a [_nameFieldA] :: FieldAssignment' a -> Name [_exprFieldA] :: FieldAssignment' a -> a nameFieldA :: Lens' Name (FieldAssignment' a) exprFieldA :: Lens' a (FieldAssignment' a) data ModuleAssignment ModuleAssignment :: QName -> [Expr] -> ImportDirective -> ModuleAssignment [_qnameModA] :: ModuleAssignment -> QName [_exprModA] :: ModuleAssignment -> [Expr] [_importDirModA] :: ModuleAssignment -> ImportDirective data BoundName BName :: Name -> Name -> Fixity' -> BoundName [boundName] :: BoundName -> Name -- | for implicit function types the label matters and can't be -- alpha-renamed [boundLabel] :: BoundName -> Name [bnameFixity] :: BoundName -> Fixity' mkBoundName_ :: Name -> BoundName mkBoundName :: Name -> Fixity' -> BoundName -- | A telescope is a sequence of typed bindings. Bound variables are in -- scope in later types. type Telescope = [TypedBindings] countTelVars :: Telescope -> Nat -- | The representation type of a declaration. The comments indicate which -- type in the intended family the constructor targets. data Declaration -- | Axioms and functions can be irrelevant. (Hiding should be NotHidden) TypeSig :: ArgInfo -> Name -> Expr -> Declaration -- | Record field, can be hidden and/or irrelevant. Field :: IsInstance -> Name -> (Arg Expr) -> Declaration FunClause :: LHS -> RHS -> WhereClause -> Bool -> Declaration -- | lone data signature in mutual block DataSig :: Range -> Induction -> Name -> [LamBinding] -> Expr -> Declaration Data :: Range -> Induction -> Name -> [LamBinding] -> (Maybe Expr) -> [TypeSignatureOrInstanceBlock] -> Declaration -- | lone record signature in mutual block RecordSig :: Range -> Name -> [LamBinding] -> Expr -> Declaration -- | The optional name is a name for the record constructor. Record :: Range -> Name -> (Maybe (Ranged Induction)) -> (Maybe Bool) -> (Maybe (Name, IsInstance)) -> [LamBinding] -> (Maybe Expr) -> [Declaration] -> Declaration Infix :: Fixity -> [Name] -> Declaration -- | notation declaration for a name Syntax :: Name -> Notation -> Declaration PatternSyn :: Range -> Name -> [Arg Name] -> Pattern -> Declaration Mutual :: Range -> [Declaration] -> Declaration Abstract :: Range -> [Declaration] -> Declaration Private :: Range -> [Declaration] -> Declaration InstanceB :: Range -> [Declaration] -> Declaration Macro :: Range -> [Declaration] -> Declaration Postulate :: Range -> [TypeSignatureOrInstanceBlock] -> Declaration Primitive :: Range -> [TypeSignature] -> Declaration Open :: Range -> QName -> ImportDirective -> Declaration Import :: Range -> QName -> (Maybe AsName) -> !OpenShortHand -> ImportDirective -> Declaration ModuleMacro :: Range -> Name -> ModuleApplication -> !OpenShortHand -> ImportDirective -> Declaration Module :: Range -> QName -> [TypedBindings] -> [Declaration] -> Declaration UnquoteDecl :: Range -> [Name] -> Expr -> Declaration UnquoteDef :: Range -> [Name] -> Expr -> Declaration Pragma :: Pragma -> Declaration data ModuleApplication -- |
-- tel. M args --SectionApp :: Range -> [TypedBindings] -> Expr -> ModuleApplication -- |
-- M {{...}} --RecordModuleIFS :: Range -> QName -> ModuleApplication -- | Just type signatures. type TypeSignature = Declaration -- | Just type signatures or instance blocks. type TypeSignatureOrInstanceBlock = Declaration -- | The things you are allowed to say when you shuffle names between name -- spaces (i.e. in import, namespace, or open -- declarations). type ImportDirective = ImportDirective' Name Name type Using = Using' Name Name -- | An imported name can be a module or a defined name. type ImportedName = ImportedName' Name Name type Renaming = Renaming' Name Name data AsName AsName :: Name -> Range -> AsName -- | The "as" name. [asName] :: AsName -> Name -- | The range of the "as" keyword. Retained for highlighting purposes. [asRange] :: AsName -> Range data OpenShortHand DoOpen :: OpenShortHand DontOpen :: OpenShortHand type RewriteEqn = Expr type WithExpr = Expr -- | Left hand sides can be written in infix style. For example: -- --
-- n + suc m = suc (n + m) -- (f ∘ g) x = f (g x) ---- -- We use fixity information to see which name is actually defined. data LHS -- | original pattern, with-patterns, rewrite equations and -- with-expressions LHS :: Pattern -> [Pattern] -> [RewriteEqn] -> [WithExpr] -> LHS -- |
-- f ps --[lhsOriginalPattern] :: LHS -> Pattern -- | | p (many) [lhsWithPattern] :: LHS -> [Pattern] -- | rewrite e (many) [lhsRewriteEqn] :: LHS -> [RewriteEqn] -- | with e (many) [lhsWithExpr] :: LHS -> [WithExpr] -- | new with-patterns, rewrite equations and with-expressions Ellipsis :: Range -> [Pattern] -> [RewriteEqn] -> [WithExpr] -> LHS -- | Concrete patterns. No literals in patterns at the moment. data Pattern -- | c or x IdentP :: QName -> Pattern -- |
-- quote --QuoteP :: Range -> Pattern -- | p p' or p {x = p'} AppP :: Pattern -> (NamedArg Pattern) -> Pattern -- | p1..pn before parsing operators RawAppP :: Range -> [Pattern] -> Pattern -- | eg: p => p' for operator _=>_ The QName -- is possibly ambiguous, but it must correspond to one of the names in -- the set. OpAppP :: Range -> QName -> (Set Name) -> [NamedArg Pattern] -> Pattern -- | {p} or {x = p} HiddenP :: Range -> (Named_ Pattern) -> Pattern -- | {{p}} or {{x = p}} InstanceP :: Range -> (Named_ Pattern) -> Pattern -- |
-- (p) --ParenP :: Range -> Pattern -> Pattern -- |
-- _ --WildP :: Range -> Pattern -- |
-- () --AbsurdP :: Range -> Pattern -- | x@p unused AsP :: Range -> Name -> Pattern -> Pattern -- |
-- .e --DotP :: Range -> Expr -> Pattern -- | 0, 1, etc. LitP :: Literal -> Pattern -- |
-- record {x = p; y = q} --RecP :: Range -> [FieldAssignment' Pattern] -> Pattern -- | Processed (scope-checked) intermediate form of the core f ps -- of LHS. Corresponds to lhsOriginalPattern. data LHSCore LHSHead :: QName -> [NamedArg Pattern] -> LHSCore -- |
-- f --[lhsDefName] :: LHSCore -> QName -- |
-- ps --[lhsPats] :: LHSCore -> [NamedArg Pattern] LHSProj :: QName -> [NamedArg Pattern] -> NamedArg LHSCore -> [NamedArg Pattern] -> LHSCore -- | record projection identifier [lhsDestructor] :: LHSCore -> QName -- | side patterns [lhsPatsLeft] :: LHSCore -> [NamedArg Pattern] -- | main branch [lhsFocus] :: LHSCore -> NamedArg LHSCore -- | side patterns [lhsPatsRight] :: LHSCore -> [NamedArg Pattern] type RHS = RHS' Expr data RHS' e -- | No right hand side because of absurd match. AbsurdRHS :: RHS' e RHS :: e -> RHS' e type WhereClause = WhereClause' [Declaration] data WhereClause' decls -- | No where clauses. NoWhere :: WhereClause' decls -- | Ordinary where. AnyWhere :: decls -> WhereClause' decls -- | Named where: module M where. SomeWhere :: Name -> decls -> WhereClause' decls -- | An expression followed by a where clause. Currently only used to give -- better a better error message in interaction. data ExprWhere ExprWhere :: Expr -> WhereClause -> ExprWhere data Pragma OptionsPragma :: Range -> [String] -> Pragma BuiltinPragma :: Range -> String -> Expr -> Pragma RewritePragma :: Range -> QName -> Pragma CompiledDataPragma :: Range -> QName -> String -> [String] -> Pragma CompiledDeclareDataPragma :: Range -> QName -> String -> Pragma CompiledTypePragma :: Range -> QName -> String -> Pragma CompiledPragma :: Range -> QName -> String -> Pragma CompiledExportPragma :: Range -> QName -> String -> Pragma CompiledEpicPragma :: Range -> QName -> String -> Pragma CompiledJSPragma :: Range -> QName -> String -> Pragma CompiledUHCPragma :: Range -> QName -> String -> Pragma CompiledDataUHCPragma :: Range -> QName -> String -> [String] -> Pragma HaskellCodePragma :: Range -> String -> Pragma NoSmashingPragma :: Range -> QName -> Pragma StaticPragma :: Range -> QName -> Pragma InlinePragma :: Range -> QName -> Pragma -- | Invariant: The string must be a valid Haskell module name. ImportPragma :: Range -> String -> Pragma -- | same as above, but for the UHC backend ImportUHCPragma :: Range -> String -> Pragma ImpossiblePragma :: Range -> Pragma TerminationCheckPragma :: Range -> (TerminationCheck Name) -> Pragma CatchallPragma :: Range -> Pragma DisplayPragma :: Range -> Pattern -> Expr -> Pragma NoPositivityCheckPragma :: Range -> Pragma -- | Modules: Top-level pragmas plus other top-level declarations. type Module = ([Pragma], [Declaration]) -- | Decorating something with Fixity'. data ThingWithFixity x ThingWithFixity :: x -> Fixity' -> ThingWithFixity x -- | Computes the top-level module name. -- -- Precondition: The Module has to be well-formed. This means that -- there are only allowed declarations before the first module -- declaration, typically import declarations. See -- spanAllowedBeforeModule. topLevelModuleName :: Module -> TopLevelModuleName -- | Splits off allowed (= import) declarations before the first -- non-allowed declaration. After successful parsing, the first -- non-allowed declaration should be a module declaration. spanAllowedBeforeModule :: [Declaration] -> ([Declaration], [Declaration]) -- | Get all the identifiers in a pattern in left-to-right order. patternNames :: Pattern -> [Name] -- | Get all the identifiers in a pattern in left-to-right order. patternQNames :: Pattern -> [QName] mapLhsOriginalPattern :: (Pattern -> Pattern) -> LHS -> LHS instance Data.Traversable.Traversable Agda.Syntax.Concrete.OpApp instance Data.Foldable.Foldable Agda.Syntax.Concrete.OpApp instance GHC.Base.Functor Agda.Syntax.Concrete.OpApp instance Data.Traversable.Traversable Agda.Syntax.Concrete.TypedBinding' instance Data.Foldable.Foldable Agda.Syntax.Concrete.TypedBinding' instance GHC.Base.Functor Agda.Syntax.Concrete.TypedBinding' instance GHC.Show.Show Agda.Syntax.Concrete.OpenShortHand instance GHC.Classes.Eq Agda.Syntax.Concrete.OpenShortHand instance GHC.Show.Show Agda.Syntax.Concrete.AsName instance Data.Traversable.Traversable Agda.Syntax.Concrete.WhereClause' instance Data.Foldable.Foldable Agda.Syntax.Concrete.WhereClause' instance GHC.Base.Functor Agda.Syntax.Concrete.WhereClause' instance Data.Traversable.Traversable Agda.Syntax.Concrete.RHS' instance Data.Foldable.Foldable Agda.Syntax.Concrete.RHS' instance GHC.Base.Functor Agda.Syntax.Concrete.RHS' instance Data.Traversable.Traversable Agda.Syntax.Concrete.LamBinding' instance Data.Foldable.Foldable Agda.Syntax.Concrete.LamBinding' instance GHC.Base.Functor Agda.Syntax.Concrete.LamBinding' instance Data.Traversable.Traversable Agda.Syntax.Concrete.TypedBindings' instance Data.Foldable.Foldable Agda.Syntax.Concrete.TypedBindings' instance GHC.Base.Functor Agda.Syntax.Concrete.TypedBindings' instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Syntax.Concrete.FieldAssignment' a) instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Concrete.FieldAssignment' a) instance Data.Traversable.Traversable Agda.Syntax.Concrete.FieldAssignment' instance Data.Foldable.Foldable Agda.Syntax.Concrete.FieldAssignment' instance GHC.Base.Functor Agda.Syntax.Concrete.FieldAssignment' instance Agda.Utils.Null.Null (Agda.Syntax.Concrete.WhereClause' a) instance Agda.Syntax.Common.LensRelevance Agda.Syntax.Concrete.TypedBindings instance Agda.Syntax.Common.LensHiding Agda.Syntax.Concrete.TypedBindings instance Agda.Syntax.Common.LensHiding Agda.Syntax.Concrete.LamBinding instance Agda.Syntax.Position.HasRange e => Agda.Syntax.Position.HasRange (Agda.Syntax.Concrete.OpApp e) instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.Expr instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.TypedBindings instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.TypedBinding instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.LamBinding instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.BoundName instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.WhereClause instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.ModuleApplication instance Agda.Syntax.Position.HasRange a => Agda.Syntax.Position.HasRange (Agda.Syntax.Concrete.FieldAssignment' a) instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.ModuleAssignment instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.Declaration instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.LHS instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.LHSCore instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.RHS instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.Pragma instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.AsName instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.Pattern instance Agda.Syntax.Position.SetRange Agda.Syntax.Concrete.TypedBindings instance Agda.Syntax.Position.SetRange Agda.Syntax.Concrete.Pattern instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Syntax.Concrete.FieldAssignment' a) instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.ModuleAssignment instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.AsName instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.BoundName instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.Declaration instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.Expr instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.LamBinding instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.LHS instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.ModuleApplication instance Agda.Syntax.Position.KillRange e => Agda.Syntax.Position.KillRange (Agda.Syntax.Concrete.OpApp e) instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.Pattern instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.Pragma instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.RHS instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.TypedBinding instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.TypedBindings instance Agda.Syntax.Position.KillRange Agda.Syntax.Concrete.WhereClause instance Control.DeepSeq.NFData Agda.Syntax.Concrete.Expr instance Control.DeepSeq.NFData Agda.Syntax.Concrete.Pattern instance Control.DeepSeq.NFData Agda.Syntax.Concrete.Declaration instance Control.DeepSeq.NFData Agda.Syntax.Concrete.Pragma instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Agda.Syntax.Concrete.TypedBindings' a) instance Control.DeepSeq.NFData Agda.Syntax.Concrete.AsName instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Agda.Syntax.Concrete.TypedBinding' a) instance Control.DeepSeq.NFData Agda.Syntax.Concrete.ModuleApplication instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Agda.Syntax.Concrete.OpApp a) instance Control.DeepSeq.NFData Agda.Syntax.Concrete.LHS instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Agda.Syntax.Concrete.FieldAssignment' a) instance Control.DeepSeq.NFData Agda.Syntax.Concrete.ModuleAssignment instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Agda.Syntax.Concrete.WhereClause' a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Agda.Syntax.Concrete.LamBinding' a) instance Control.DeepSeq.NFData Agda.Syntax.Concrete.BoundName instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Agda.Syntax.Concrete.RHS' a) -- | Generic traversal and reduce for concrete syntax, in the style of -- Agda.Syntax.Internal.Generic. -- -- However, here we use the terminology of Traversable. module Agda.Syntax.Concrete.Generic -- | Generic traversals for concrete expressions. -- -- Note: does not go into patterns! class ExprLike a where traverseExpr = (throwImpossible (Impossible "src/full/Agda/Syntax/Concrete/Generic.hs" 44)) foldExpr = (throwImpossible (Impossible "src/full/Agda/Syntax/Concrete/Generic.hs" 45)) -- | This corresponds to map. mapExpr :: ExprLike a => (Expr -> Expr) -> a -> a -- | This corresponds to mapM. traverseExpr :: (ExprLike a, Monad m) => (Expr -> m Expr) -> a -> m a -- | This is a reduce. foldExpr :: (ExprLike a, Monoid m) => (Expr -> m) -> a -> m instance Agda.Syntax.Concrete.Generic.ExprLike Agda.Syntax.Concrete.Name.Name instance Agda.Syntax.Concrete.Generic.ExprLike Agda.Syntax.Concrete.Name.QName instance Agda.Syntax.Concrete.Generic.ExprLike GHC.Types.Bool instance Agda.Syntax.Concrete.Generic.ExprLike a => Agda.Syntax.Concrete.Generic.ExprLike (Agda.Syntax.Common.Named name a) instance Agda.Syntax.Concrete.Generic.ExprLike a => Agda.Syntax.Concrete.Generic.ExprLike (Agda.Syntax.Common.Arg a) instance Agda.Syntax.Concrete.Generic.ExprLike a => Agda.Syntax.Concrete.Generic.ExprLike [a] instance Agda.Syntax.Concrete.Generic.ExprLike a => Agda.Syntax.Concrete.Generic.ExprLike (GHC.Base.Maybe a) instance Agda.Syntax.Concrete.Generic.ExprLike a => Agda.Syntax.Concrete.Generic.ExprLike (Agda.Syntax.Common.MaybePlaceholder a) instance (Agda.Syntax.Concrete.Generic.ExprLike a, Agda.Syntax.Concrete.Generic.ExprLike b) => Agda.Syntax.Concrete.Generic.ExprLike (Data.Either.Either a b) instance Agda.Syntax.Concrete.Generic.ExprLike a => Agda.Syntax.Concrete.Generic.ExprLike (Agda.Syntax.Concrete.TypedBinding' a) instance Agda.Syntax.Concrete.Generic.ExprLike a => Agda.Syntax.Concrete.Generic.ExprLike (Agda.Syntax.Concrete.RHS' a) instance Agda.Syntax.Concrete.Generic.ExprLike a => Agda.Syntax.Concrete.Generic.ExprLike (Agda.Syntax.Concrete.WhereClause' a) instance (Agda.Syntax.Concrete.Generic.ExprLike a, Agda.Syntax.Concrete.Generic.ExprLike b) => Agda.Syntax.Concrete.Generic.ExprLike (a, b) instance (Agda.Syntax.Concrete.Generic.ExprLike a, Agda.Syntax.Concrete.Generic.ExprLike b, Agda.Syntax.Concrete.Generic.ExprLike c) => Agda.Syntax.Concrete.Generic.ExprLike (a, b, c) instance (Agda.Syntax.Concrete.Generic.ExprLike a, Agda.Syntax.Concrete.Generic.ExprLike b, Agda.Syntax.Concrete.Generic.ExprLike c, Agda.Syntax.Concrete.Generic.ExprLike d) => Agda.Syntax.Concrete.Generic.ExprLike (a, b, c, d) instance Agda.Syntax.Concrete.Generic.ExprLike Agda.Syntax.Concrete.Expr instance Agda.Syntax.Concrete.Generic.ExprLike Agda.Syntax.Concrete.FieldAssignment instance Agda.Syntax.Concrete.Generic.ExprLike Agda.Syntax.Concrete.ModuleAssignment instance Agda.Syntax.Concrete.Generic.ExprLike a => Agda.Syntax.Concrete.Generic.ExprLike (Agda.Syntax.Concrete.OpApp a) instance Agda.Syntax.Concrete.Generic.ExprLike Agda.Syntax.Concrete.LamBinding instance Agda.Syntax.Concrete.Generic.ExprLike Agda.Syntax.Concrete.TypedBindings instance Agda.Syntax.Concrete.Generic.ExprLike Agda.Syntax.Concrete.LHS instance Agda.Syntax.Concrete.Generic.ExprLike Agda.Syntax.Concrete.ModuleApplication instance Agda.Syntax.Concrete.Generic.ExprLike Agda.Syntax.Concrete.Declaration module Agda.Syntax.Concrete.Operators.Parser data MemoKey NodeK :: (Either Integer Integer) -> MemoKey PostLeftsK :: (Either Integer Integer) -> MemoKey TopK :: MemoKey AppK :: MemoKey NonfixK :: MemoKey type Parser tok a = Parser MemoKey tok (MaybePlaceholder tok) a placeholder :: PositionInName -> Parser e (MaybePlaceholder e) maybePlaceholder :: Maybe PositionInName -> Parser e e -> Parser e (MaybePlaceholder e) notPlaceholder :: Parser e e sat' :: (e -> Bool) -> Parser e e data ExprView e LocalV :: QName -> ExprView e WildV :: e -> ExprView e OtherV :: e -> ExprView e AppV :: e -> (NamedArg e) -> ExprView e -- | The QName is possibly ambiguous, but it must correspond to one -- of the names in the set. OpAppV :: QName -> (Set Name) -> [NamedArg (MaybePlaceholder (OpApp e))] -> ExprView e HiddenArgV :: (Named_ e) -> ExprView e InstanceArgV :: (Named_ e) -> ExprView e LamV :: [LamBinding] -> e -> ExprView e ParenV :: e -> ExprView e class HasRange e => IsExpr e exprView :: IsExpr e => e -> ExprView e unExprView :: IsExpr e => ExprView e -> e -- | Should sections be parsed? data ParseSections ParseSections :: ParseSections DoNotParseSections :: ParseSections -- | Runs a parser. If sections should be parsed, then identifiers with at -- least two name parts are split up into multiple tokens, using -- PositionInName to record the tokens' original positions within -- their respective identifiers. parse :: IsExpr e => (ParseSections, Parser e a) -> [e] -> [a] -- | Parse a specific identifier as a NamePart partP :: IsExpr e => [Name] -> RawName -> Parser e Range -- | Parses a split-up, unqualified name consisting of at least two name -- parts. -- -- The parser does not check that underscores and other name parts -- alternate. The range of the resulting name is the range of the first -- name part that is not an underscore. atLeastTwoParts :: IsExpr e => Parser e Name -- | Either a wildcard (_), or an unqualified name (possibly -- containing multiple name parts). wildOrUnqualifiedName :: IsExpr e => Parser e (Maybe Name) -- | Used to define the return type of opP. -- | A singleton type for NotationKind (except for the constructor -- NoNotation). data NK (k :: NotationKind) :: * [In] :: NK InfixNotation [Pre] :: NK PrefixNotation [Post] :: NK PostfixNotation [Non] :: NK NonfixNotation -- | Parse the "operator part" of the given notation. -- -- Normal holes (but not binders) at the beginning and end are ignored. -- -- If the notation does not contain any binders, then a section notation -- is allowed. opP :: forall e k. IsExpr e => ParseSections -> Parser e e -> NewNotation -> NK k -> Parser e (OperatorType k e) argsP :: IsExpr e => Parser e e -> Parser e [NamedArg e] appP :: IsExpr e => Parser e e -> Parser e [NamedArg e] -> Parser e e atomP :: IsExpr e => (QName -> Bool) -> Parser e e instance GHC.Show.Show Agda.Syntax.Concrete.Operators.Parser.ParseSections instance GHC.Classes.Eq Agda.Syntax.Concrete.Operators.Parser.ParseSections instance GHC.Generics.Generic Agda.Syntax.Concrete.Operators.Parser.MemoKey instance GHC.Classes.Eq Agda.Syntax.Concrete.Operators.Parser.MemoKey instance Data.Hashable.Class.Hashable Agda.Syntax.Concrete.Operators.Parser.MemoKey instance Agda.Syntax.Concrete.Operators.Parser.IsExpr e => Agda.Syntax.Position.HasRange (Agda.Syntax.Concrete.Operators.Parser.ExprView e) instance Agda.Syntax.Concrete.Operators.Parser.IsExpr Agda.Syntax.Concrete.Expr instance Agda.Syntax.Concrete.Operators.Parser.IsExpr Agda.Syntax.Concrete.Pattern -- | Pretty printer for the concrete syntax. module Agda.Syntax.Concrete.Pretty braces' :: Doc -> Doc dbraces :: Doc -> Doc bracesAndSemicolons :: [Doc] -> Doc arrow :: Doc lambda :: Doc -- | prettyHiding info visible doc puts the correct braces around -- doc according to info info and returns visible -- doc if the we deal with a visible thing. prettyHiding :: LensHiding a => a -> (Doc -> Doc) -> Doc -> Doc prettyRelevance :: LensRelevance a => a -> Doc -> Doc newtype Tel Tel :: Telescope -> Tel smashTel :: Telescope -> Telescope prettyOpApp :: Pretty a => QName -> [NamedArg (MaybePlaceholder a)] -> [Doc] instance GHC.Show.Show Agda.Syntax.Concrete.Expr instance GHC.Show.Show Agda.Syntax.Concrete.Declaration instance GHC.Show.Show Agda.Syntax.Concrete.Pattern instance GHC.Show.Show Agda.Syntax.Concrete.TypedBinding instance GHC.Show.Show Agda.Syntax.Concrete.TypedBindings instance GHC.Show.Show Agda.Syntax.Concrete.LamBinding instance (Agda.Utils.Pretty.Pretty a, Agda.Utils.Pretty.Pretty b) => GHC.Show.Show (Agda.Syntax.Common.ImportDirective' a b) instance GHC.Show.Show Agda.Syntax.Concrete.Pragma instance GHC.Show.Show Agda.Syntax.Concrete.RHS instance (Agda.Utils.Pretty.Pretty a, Agda.Utils.Pretty.Pretty b) => Agda.Utils.Pretty.Pretty (a, b) instance Agda.Utils.Pretty.Pretty (Agda.Syntax.Fixity.ThingWithFixity Agda.Syntax.Concrete.Name.Name) instance Agda.Utils.Pretty.Pretty a => Agda.Utils.Pretty.Pretty (Agda.Syntax.Common.WithHiding a) instance Agda.Utils.Pretty.Pretty Agda.Syntax.Common.Relevance instance Agda.Utils.Pretty.Pretty Agda.Syntax.Common.Induction instance Agda.Utils.Pretty.Pretty (Agda.Syntax.Concrete.OpApp Agda.Syntax.Concrete.Expr) instance Agda.Utils.Pretty.Pretty a => Agda.Utils.Pretty.Pretty (Agda.Syntax.Common.MaybePlaceholder a) instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.Expr instance (Agda.Utils.Pretty.Pretty a, Agda.Utils.Pretty.Pretty b) => Agda.Utils.Pretty.Pretty (Data.Either.Either a b) instance Agda.Utils.Pretty.Pretty a => Agda.Utils.Pretty.Pretty (Agda.Syntax.Concrete.FieldAssignment' a) instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.ModuleAssignment instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.BoundName instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.LamBinding instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.TypedBindings instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.Pretty.Tel instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.TypedBinding instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.RHS instance GHC.Show.Show Agda.Syntax.Concrete.WhereClause instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.WhereClause instance GHC.Show.Show Agda.Syntax.Concrete.LHS instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.LHS instance GHC.Show.Show Agda.Syntax.Concrete.LHSCore instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.LHSCore instance Agda.Utils.Pretty.Pretty [Agda.Syntax.Concrete.Declaration] instance GHC.Show.Show Agda.Syntax.Concrete.ModuleApplication instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.ModuleApplication instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.Declaration instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.OpenShortHand instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.Pragma instance Agda.Utils.Pretty.Pretty Agda.Syntax.Fixity.Fixity instance Agda.Utils.Pretty.Pretty Agda.Syntax.Notation.GenPart instance Agda.Utils.Pretty.Pretty Agda.Syntax.Notation.Notation instance Agda.Utils.Pretty.Pretty Agda.Syntax.Fixity.Fixity' instance Agda.Utils.Pretty.Pretty e => Agda.Utils.Pretty.Pretty (Agda.Syntax.Common.Arg e) instance Agda.Utils.Pretty.Pretty e => Agda.Utils.Pretty.Pretty (Agda.Syntax.Common.Named_ e) instance Agda.Utils.Pretty.Pretty [Agda.Syntax.Concrete.Pattern] instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.Pattern instance (Agda.Utils.Pretty.Pretty a, Agda.Utils.Pretty.Pretty b) => Agda.Utils.Pretty.Pretty (Agda.Syntax.Common.ImportDirective' a b) instance (Agda.Utils.Pretty.Pretty a, Agda.Utils.Pretty.Pretty b) => Agda.Utils.Pretty.Pretty (Agda.Syntax.Common.Using' a b) instance (Agda.Utils.Pretty.Pretty a, Agda.Utils.Pretty.Pretty b) => Agda.Utils.Pretty.Pretty (Agda.Syntax.Common.ImportedName' a b) -- | Preprocess Declarations, producing NiceDeclarations. -- --
-- lexer k = lexToken >>= k --lexer :: (Token -> Parser a) -> Parser a -- | This is the initial state for parsing a regular, non-literate file. normal :: LexState -- | This is the initial state for parsing a literate file. Code blocks -- should be enclosed in \begin{code} \end{code} pairs. literate :: LexState code :: Int -- | The layout state. Entered when we see a layout keyword -- (withLayout) and exited either when seeing an open brace -- (openBrace) or at the next token (newLayoutContext). -- -- Update: we don't use braces for layout anymore. layout :: LexState -- | We enter this state from newLayoutContext when the token -- following a layout keyword is to the left of (or at the same column -- as) the current layout context. Example: -- --
-- data Empty : Set where -- foo : Empty -> Nat ---- -- Here the second line is not part of the where clause since it -- is has the same indentation as the data definition. What we -- have to do is insert an empty layout block {} after the -- where. The only thing that can happen in this state is that -- emptyLayout is executed, generating the closing brace. The open -- brace is generated when entering by newLayoutContext. empty_layout :: LexState -- | This state is entered at the beginning of each line. You can't lex -- anything in this state, and to exit you have to check the layout rule. -- Done with offsideRule. bol :: LexState -- | This state can only be entered by the parser. In this state you can -- only lex the keywords using, hiding, -- renaming and to. Moreover they are only keywords in -- this particular state. The lexer will never enter this state by -- itself, that has to be done in the parser. imp_dir :: LexState data AlexReturn a AlexEOF :: AlexReturn a AlexError :: !AlexInput -> AlexReturn a AlexSkip :: !AlexInput -> !Int -> AlexReturn a AlexToken :: !AlexInput -> !Int -> a -> AlexReturn a -- | This is the main lexing function generated by Alex. alexScanUser :: ([LexState], ParseFlags) -> AlexInput -> Int -> AlexReturn (LexAction Token) instance GHC.Base.Functor Agda.Syntax.Parser.Lexer.AlexLastAcc -- | This module contains the building blocks used to construct the lexer. module Agda.Syntax.Parser.LexActions -- | Scan the input to find the next token. Calls alexScanUser. This -- is the main lexing function where all the work happens. The function -- lexer, used by the parser is the continuation version of this -- function. lexToken :: Parser Token -- | The most general way of parsing a token. token :: (String -> Parser tok) -> LexAction tok -- | Parse a token from an Interval and the lexed string. withInterval :: ((Interval, String) -> tok) -> LexAction tok -- | Like withInterval, but applies a function to the string. withInterval' :: (String -> a) -> ((Interval, a) -> tok) -> LexAction tok -- | Return a token without looking at the lexed string. withInterval_ :: (Interval -> r) -> LexAction r -- | Executed for layout keywords. Enters the layout state and -- performs the given action. withLayout :: LexAction r -> LexAction r -- | Enter a new state without consuming any input. begin :: LexState -> LexAction Token -- | Exit the current state without consuming any input end :: LexAction Token -- | Exit the current state and perform the given action. endWith :: LexAction a -> LexAction a -- | Enter a new state throwing away the current lexeme. begin_ :: LexState -> LexAction Token -- | Exit the current state throwing away the current lexeme. end_ :: LexAction Token -- | For lexical errors we want to report the current position as the site -- of the error, whereas for parse errors the previous position is the -- one we're interested in (since this will be the position of the token -- we just lexed). This function does parseErrorAt the current -- position. lexError :: String -> Parser a -- | Parse a Keyword token, triggers layout for -- layoutKeywords. keyword :: Keyword -> LexAction Token -- | Parse a Symbol token. symbol :: Symbol -> LexAction Token -- | Parse an identifier. Identifiers can be qualified (see Name). -- Example: Foo.Bar.f identifier :: LexAction Token -- | Parse a literal. literal :: Read a => (Range -> a -> Literal) -> LexAction Token -- | True when the given character is the next character of the input -- string. followedBy :: Char -> LexPredicate -- | True if we are at the end of the file. eof :: LexPredicate -- | True if the given state appears somewhere on the state stack inState :: LexState -> LexPredicate -- | This module contains the lex actions that handle the layout rules. The -- way it works is that the Parser monad keeps track of a stack of -- LayoutContexts specifying the indentation of the layout blocks -- in scope. For instance, consider the following incomplete (Haskell) -- program: -- --
-- f x = x' -- where -- x' = case x of { True -> False; False -> ... ---- -- At the ... the layout context would be -- --
-- [NoLayout, Layout 4, Layout 0] ---- -- The closest layout block is the one containing the case -- branches. This block starts with an open brace ('{') and so -- doesn't use layout. The second closest block is the where -- clause. Here, there is no open brace so the block is started by the -- x' token which has indentation 4. Finally there is a -- top-level layout block with indentation 0. module Agda.Syntax.Parser.Layout -- | Executed upon lexing an open brace ('{'). Enters the -- NoLayout context. openBrace :: LexAction Token -- | Executed upon lexing a close brace ('}'). Exits the current -- layout context. This might look a bit funny--the lexer will happily -- use a close brace to close a context open by a virtual brace. This is -- not a problem since the parser will make sure the braces are -- appropriately matched. closeBrace :: LexAction Token -- | Executed for layout keywords. Enters the layout state and -- performs the given action. withLayout :: LexAction r -> LexAction r -- | Executed for the first token in each line (see bol). Checks the -- position of the token relative to the current layout context. If the -- token is -- --
-- tactic e x1 .. xn | y1 | .. | yn --Tactic :: ExprInfo -> Expr -> [NamedArg Expr] -> [NamedArg Expr] -> Expr -- | For printing DontCare from Syntax.Internal. DontCare :: Expr -> Expr -- | Record field assignment f = e. type Assign = FieldAssignment' Expr type Assigns = [Assign] type RecordAssign = Either Assign ModuleName type RecordAssigns = [RecordAssign] -- | Is a type signature a postulate or a function signature? data Axiom -- | A function signature. FunSig :: Axiom -- | Not a function signature, i.e., a postulate (in user input) or another -- (e.g. data/record) type signature (internally). NoFunSig :: Axiom -- | Renaming (generic). type Ren a = [(a, a)] data Declaration -- | type signature (can be irrelevant and colored, but not hidden) Axiom :: Axiom -> DefInfo -> ArgInfo -> QName -> Expr -> Declaration -- | record field Field :: DefInfo -> QName -> (Arg Expr) -> Declaration -- | primitive function Primitive :: DefInfo -> QName -> Expr -> Declaration -- | a bunch of mutually recursive definitions Mutual :: MutualInfo -> [Declaration] -> Declaration Section :: ModuleInfo -> ModuleName -> [TypedBindings] -> [Declaration] -> Declaration -- | The ImportDirective is for highlighting purposes. Apply :: ModuleInfo -> ModuleName -> ModuleApplication -> (Ren QName) -> (Ren ModuleName) -> ImportDirective -> Declaration -- | The ImportDirective is for highlighting purposes. Import :: ModuleInfo -> ModuleName -> ImportDirective -> Declaration Pragma :: Range -> Pragma -> Declaration -- | only retained for highlighting purposes Open :: ModuleInfo -> ModuleName -> ImportDirective -> Declaration -- | sequence of function clauses FunDef :: DefInfo -> QName -> Delayed -> [Clause] -> Declaration -- | lone data signature ^ the LamBindings are DomainFree and -- binds the parameters of the datatype. DataSig :: DefInfo -> QName -> Telescope -> Expr -> Declaration -- | the LamBindings are DomainFree and binds the parameters -- of the datatype. DataDef :: DefInfo -> QName -> [LamBinding] -> [Constructor] -> Declaration -- | lone record signature RecSig :: DefInfo -> QName -> Telescope -> Expr -> Declaration -- | The Expr gives the constructor type telescope, (x1 : -- A1)..(xn : An) -> Prop, and the optional name is the -- constructor's name. RecDef :: DefInfo -> QName -> (Maybe (Ranged Induction)) -> (Maybe Bool) -> (Maybe QName) -> [LamBinding] -> Expr -> [Declaration] -> Declaration -- | Only for highlighting purposes PatternSynDef :: QName -> [Arg Name] -> (Pattern' Void) -> Declaration UnquoteDecl :: MutualInfo -> [DefInfo] -> [QName] -> Expr -> Declaration UnquoteDef :: [DefInfo] -> [QName] -> Expr -> Declaration -- | scope annotation ScopedDecl :: ScopeInfo -> [Declaration] -> Declaration class GetDefInfo a getDefInfo :: GetDefInfo a => a -> Maybe DefInfo type ImportDirective = ImportDirective' QName ModuleName type Renaming = Renaming' QName ModuleName type ImportedName = ImportedName' QName ModuleName data ModuleApplication -- | tel. M args: applies M to args and -- abstracts tel. SectionApp :: Telescope -> ModuleName -> [NamedArg Expr] -> ModuleApplication -- |
-- M {{...}} --RecordModuleIFS :: ModuleName -> ModuleApplication data Pragma OptionsPragma :: [String] -> Pragma BuiltinPragma :: String -> Expr -> Pragma -- | Builtins that do not come with a definition, but declare a name for an -- Agda concept. BuiltinNoDefPragma :: String -> QName -> Pragma RewritePragma :: QName -> Pragma CompiledPragma :: QName -> String -> Pragma CompiledExportPragma :: QName -> String -> Pragma CompiledDeclareDataPragma :: QName -> String -> Pragma CompiledTypePragma :: QName -> String -> Pragma CompiledDataPragma :: QName -> String -> [String] -> Pragma CompiledEpicPragma :: QName -> String -> Pragma CompiledJSPragma :: QName -> String -> Pragma CompiledUHCPragma :: QName -> String -> Pragma CompiledDataUHCPragma :: QName -> String -> [String] -> Pragma NoSmashingPragma :: QName -> Pragma StaticPragma :: QName -> Pragma InlinePragma :: QName -> Pragma DisplayPragma :: QName -> [NamedArg Pattern] -> Expr -> Pragma -- | Bindings that are valid in a let. data LetBinding -- |
-- LetBind info rel name type defn --LetBind :: LetInfo -> ArgInfo -> Name -> Expr -> Expr -> LetBinding -- | Irrefutable pattern binding. LetPatBind :: LetInfo -> Pattern -> Expr -> LetBinding -- | LetApply mi newM (oldM args) renaming moduleRenaming dir. The -- ImportDirective is for highlighting purposes. LetApply :: ModuleInfo -> ModuleName -> ModuleApplication -> (Ren QName) -> (Ren ModuleName) -> ImportDirective -> LetBinding -- | only for highlighting and abstractToConcrete LetOpen :: ModuleInfo -> ModuleName -> ImportDirective -> LetBinding -- | Only used for highlighting. Refers to the first occurrence of -- x in let x : A; x = e. LetDeclaredVariable :: Name -> LetBinding -- | Only Axioms. type TypeSignature = Declaration type Constructor = TypeSignature type Field = TypeSignature -- | A lambda binding is either domain free or typed. data LamBinding -- | . x or {x} or .x or .{x} DomainFree :: ArgInfo -> Name -> LamBinding -- | . (xs:e) or {xs:e} or (let Ds) DomainFull :: TypedBindings -> LamBinding -- | Typed bindings with hiding information. data TypedBindings -- | . (xs : e) or {xs : e} TypedBindings :: Range -> (Arg TypedBinding) -> TypedBindings -- | A typed binding. Appears in dependent function spaces, typed lambdas, -- and telescopes. It might be tempting to simplify this to only bind a -- single name at a time, and translate, say, (x y : A) to -- (x : A)(y : A) before type-checking. However, this would be -- slightly problematic: -- --
-- c vs --Con :: ConHead -> Args -> Term -- | dependent or non-dependent function space Pi :: (Dom Type) -> (Abs Type) -> Term Sort :: Sort -> Term Level :: Level -> Term MetaV :: {-# UNPACK #-} !MetaId -> Elims -> Term -- | Irrelevant stuff in relevant position, but created in an irrelevant -- context. Basically, an internal version of the irrelevance axiom -- .irrAx : .A -> A. DontCare :: Term -> Term -- | Explicit sharing Shared :: !(Ptr Term) -> Term -- | Eliminations, subsuming applications and projections. data Elim' a Apply :: (Arg a) -> Elim' a -- | name of a record projection Proj :: QName -> Elim' a type Elim = Elim' Term type Elims = [Elim] eliminations ordered left-to-right. -- | Names in binders and arguments. type ArgName = String argNameToString :: ArgName -> String stringToArgName :: String -> ArgName appendArgNames :: ArgName -> ArgName -> ArgName nameToArgName :: Name -> ArgName -- | Binder. Abs: The bound variable might appear in the body. -- NoAbs is pseudo-binder, it does not introduce a fresh variable, -- similar to the const of Haskell. data Abs a -- | The body has (at least) one free variable. Danger: unAbs -- doesn't shift variables properly Abs :: ArgName -> a -> Abs a [absName] :: Abs a -> ArgName [unAbs] :: Abs a -> a NoAbs :: ArgName -> a -> Abs a [absName] :: Abs a -> ArgName [unAbs] :: Abs a -> a -- | Types are terms with a sort annotation. data Type' a El :: Sort -> a -> Type' a [_getSort] :: Type' a -> Sort [unEl] :: Type' a -> a type Type = Type' Term class LensSort a where getSort a = a ^. lensSort lensSort :: LensSort a => Lens' Sort a getSort :: LensSort a => a -> Sort -- | Sequence of types. An argument of the first type is bound in later -- types and so on. data Tele a EmptyTel :: Tele a -- | Abs is never NoAbs. ExtendTel :: a -> (Abs (Tele a)) -> Tele a type Telescope = Tele (Dom Type) -- | A traversal for the names in a telescope. mapAbsNamesM :: Applicative m => (ArgName -> m ArgName) -> Tele a -> m (Tele a) mapAbsNames :: (ArgName -> ArgName) -> Tele a -> Tele a replaceEmptyName :: ArgName -> Tele a -> Tele a -- | Sorts. data Sort -- | Set ℓ. Type :: Level -> Sort -- | Dummy sort. Prop :: Sort -- | Setω. Inf :: Sort -- | SizeUniv, a sort inhabited by type Size. SizeUniv :: Sort -- | Dependent least upper bound. If the free variable occurs in the second -- sort, the whole thing should reduce to Inf, otherwise it's the normal -- lub. DLub :: Sort -> (Abs Sort) -> Sort -- | A level is a maximum expression of 0..n PlusLevel expressions -- each of which is a number or an atom plus a number. -- -- The empty maximum is the canonical representation for level 0. newtype Level Max :: [PlusLevel] -> Level data PlusLevel -- | n, to represent Setₙ. ClosedLevel :: Integer -> PlusLevel -- | n + ℓ. Plus :: Integer -> LevelAtom -> PlusLevel -- | An atomic term of type Level. data LevelAtom -- | A meta variable targeting Level under some eliminations. MetaLevel :: MetaId -> Elims -> LevelAtom -- | A term of type Level whose reduction is blocked by a meta. BlockedLevel :: MetaId -> Term -> LevelAtom -- | A neutral term of type Level. NeutralLevel :: NotBlocked -> Term -> LevelAtom -- | Introduced by instantiate, removed by reduce. UnreducedLevel :: Term -> LevelAtom -- | Even if we are not stuck on a meta during reduction we can fail to -- reduce a definition by pattern matching for another reason. data NotBlocked -- | The Elim is neutral and blocks a pattern match. StuckOn :: Elim -> NotBlocked -- | Not enough arguments were supplied to complete the matching. Underapplied :: NotBlocked -- | We matched an absurd clause, results in a neutral Def. AbsurdMatch :: NotBlocked -- | We ran out of clauses, all considered clauses produced an actual -- mismatch. This can happen when try to reduce a function application -- but we are still missing some function clauses. See -- Agda.TypeChecking.Patterns.Match. MissingClauses :: NotBlocked -- | Reduction was not blocked, we reached a whnf which can be anything but -- a stuck Def. ReallyNotBlocked :: NotBlocked -- | ReallyNotBlocked is the unit. MissingClauses is -- dominant. StuckOn{} should be propagated, if tied, we -- take the left. -- | Something where a meta variable may block reduction. data Blocked t Blocked :: MetaId -> t -> Blocked t [theBlockingMeta] :: Blocked t -> MetaId [ignoreBlocking] :: Blocked t -> t NotBlocked :: NotBlocked -> t -> Blocked t [blockingStatus] :: Blocked t -> NotBlocked [ignoreBlocking] :: Blocked t -> t -- | Blocking by a meta is dominant. -- | Blocked t without the t. type Blocked_ = Blocked () -- | When trying to reduce f es, on match failed on one -- elimination e ∈ es that came with info r :: -- NotBlocked. stuckOn e r produces the new -- NotBlocked info. -- -- MissingClauses must be propagated, as this is blockage that can -- be lifted in the future (as more clauses are added). -- -- StuckOn e0 is also propagated, since it provides more -- precise information as StuckOn e (as e0 is the -- original reason why reduction got stuck and usually a subterm of -- e). An information like StuckOn (Apply (Arg info (Var i -- []))) (stuck on a variable) could be used by the lhs/coverage -- checker to trigger a split on that (pattern) variable. -- -- In the remaining cases for r, we are terminally stuck due to -- StuckOn e. Propagating AbsurdMatch does not -- seem useful. -- -- Underapplied must not be propagated, as this would mean that -- f es is underapplied, which is not the case (it is stuck). -- Note that Underapplied can only arise when projection patterns -- were missing to complete the original match (in e). (Missing -- ordinary pattern would mean the e is of function type, but we -- cannot match against something of function type.) stuckOn :: Elim -> NotBlocked -> NotBlocked -- | A clause is a list of patterns and the clause body should -- Bind. -- -- The telescope contains the types of the pattern variables and the de -- Bruijn indices say how to get from the order the variables occur in -- the patterns to the order they occur in the telescope. The body binds -- the variables in the order they appear in the patterns. -- --
-- clauseTel ~ permute clausePerm (patternVars namedClausePats) ---- -- Terms in dot patterns are valid in the clause telescope. -- -- For the purpose of the permutation and the body dot patterns count as -- variables. TODO: Change this! data Clause Clause :: Range -> Telescope -> [NamedArg DeBruijnPattern] -> ClauseBody -> Maybe (Arg Type) -> Bool -> Clause [clauseRange] :: Clause -> Range -- | Δ: The types of the pattern variables. [clauseTel] :: Clause -> Telescope -- |
-- let Γ = patternVars namedClausePats --[namedClausePats] :: Clause -> [NamedArg DeBruijnPattern] -- |
-- λΓ.v --[clauseBody] :: Clause -> ClauseBody -- | Δ ⊢ t. The type of the rhs under clauseTel. Used, -- e.g., by TermCheck. Can be Irrelevant if we -- encountered an irrelevant projection pattern on the lhs. [clauseType] :: Clause -> Maybe (Arg Type) [clauseCatchall] :: Clause -> Bool clausePats :: Clause -> [Arg DeBruijnPattern] data ClauseBodyF a Body :: a -> ClauseBodyF a Bind :: (Abs (ClauseBodyF a)) -> ClauseBodyF a -- | for absurd clauses. NoBody :: ClauseBodyF a type ClauseBody = ClauseBodyF Term imapClauseBody :: (Nat -> a -> b) -> ClauseBodyF a -> ClauseBodyF b -- | Pattern variables. type PatVarName = ArgName patVarNameToString :: PatVarName -> String nameToPatVarName :: Name -> PatVarName -- | Patterns are variables, constructors, or wildcards. QName is -- used in ConP rather than Name since a constructor -- might come from a particular namespace. This also meshes well with the -- fact that values (i.e. the arguments we are matching with) use -- QName. data Pattern' x -- |
-- x --VarP :: x -> Pattern' x -- |
-- .t --DotP :: Term -> Pattern' x -- | c ps The subpatterns do not contain any projection -- copatterns. ConP :: ConHead -> ConPatternInfo -> [NamedArg (Pattern' x)] -> Pattern' x -- | E.g. 5, "hello". LitP :: Literal -> Pattern' x -- | Projection copattern. Can only appear by itself. ProjP :: QName -> Pattern' x type Pattern = Pattern' PatVarName The @PatVarName@ is a name suggestion. -- | Type used when numbering pattern variables. type DeBruijnPattern = Pattern' (Int, PatVarName) namedVarP :: PatVarName -> Named (Ranged PatVarName) Pattern namedDBVarP :: Int -> PatVarName -> Named (Ranged PatVarName) DeBruijnPattern -- | The ConPatternInfo states whether the constructor belongs to -- a record type (Just) or data type (Nothing). In the -- former case, the Bool says whether the record pattern -- orginates from the expansion of an implicit pattern. The Type -- is the type of the whole record pattern. The scope used for the type -- is given by any outer scope plus the clause's telescope -- (clauseTel). data ConPatternInfo ConPatternInfo :: Maybe ConPOrigin -> Maybe (Arg Type) -> ConPatternInfo -- | Nothing if data constructor. Just if record -- constructor. [conPRecord] :: ConPatternInfo -> Maybe ConPOrigin -- | The type of the whole constructor pattern. Should be present -- (Just) if constructor pattern is is generated ordinarily by -- type-checking. Could be absent (Nothing) if pattern comes -- from some plugin (like Agsy). Needed e.g. for with-clause stripping. [conPType] :: ConPatternInfo -> Maybe (Arg Type) noConPatternInfo :: ConPatternInfo -- | Extract pattern variables in left-to-right order. A DotP is -- also treated as variable (see docu for Clause). patternVars :: Arg (Pattern' a) -> [Arg (Either a Term)] -- | Does the pattern perform a match that could fail? properlyMatching :: Pattern' a -> Bool -- | Substitutions. data Substitution' a -- | Identity substitution. Γ ⊢ IdS : Γ IdS :: Substitution' a -- | Empty substitution, lifts from the empty context. Apply this to closed -- terms you want to use in a non-empty context. Γ ⊢ EmptyS : () EmptyS :: Substitution' a -- | Substitution extension, `cons'. Γ ⊢ u : Aρ Γ ⊢ ρ : Δ -- ---------------------- Γ ⊢ u :# ρ : Δ, A (:#) :: a -> Substitution' a -> Substitution' a -- | Strengthening substitution. First argument is -- IMPOSSIBLE. Apply this to a term which does not -- contain variable 0 to lower all de Bruijn indices by one. Γ ⊢ ρ : -- Δ --------------------------- Γ ⊢ Strengthen ρ : Δ, A Strengthen :: Empty -> (Substitution' a) -> Substitution' a -- | Weakning substitution, lifts to an extended context. Γ ⊢ ρ : Δ -- ------------------- Γ, Ψ ⊢ Wk |Ψ| ρ : Δ Wk :: !Int -> (Substitution' a) -> Substitution' a -- | Lifting substitution. Use this to go under a binder. Lift 1 ρ == -- var 0 :# Wk 1 ρ. Γ ⊢ ρ : Δ ------------------------- Γ, Ψρ ⊢ -- Lift |Ψ| ρ : Δ, Ψ Lift :: !Int -> (Substitution' a) -> Substitution' a type Substitution = Substitution' Term type PatternSubstitution = Substitution' DeBruijnPattern -- | View type as equality type. data EqualityView EqualityType :: Sort -> QName -> Arg Term -> Arg Term -> Arg Term -> Arg Term -> EqualityView -- | Sort of this type. [eqtSort] :: EqualityView -> Sort -- | Builtin EQUALITY. [eqtName] :: EqualityView -> QName -- | Hidden [eqtLevel] :: EqualityView -> Arg Term -- | Hidden [eqtType] :: EqualityView -> Arg Term -- | NotHidden [eqtLhs] :: EqualityView -> Arg Term -- | NotHidden [eqtRhs] :: EqualityView -> Arg Term -- | reduced OtherType :: Type -> EqualityView isEqualityType :: EqualityView -> Bool -- | Absurd lambdas are internally represented as identity with variable -- name "()". absurdBody :: Abs Term isAbsurdBody :: Abs Term -> Bool absurdPatternName :: PatVarName isAbsurdPatternName :: PatVarName -> Bool -- | Remove top-level Shared data constructors. ignoreSharing :: Term -> Term ignoreSharingType :: Type -> Type -- | Introduce sharing. shared_ :: Term -> Term -- | Typically m would be TCM and f would be Blocked. updateSharedFM :: (Monad m, Traversable f) => (Term -> m (f Term)) -> Term -> m (f Term) updateSharedM :: Monad m => (Term -> m Term) -> Term -> m Term updateShared :: (Term -> Term) -> Term -> Term pointerChain :: Term -> [Ptr Term] compressPointerChain :: Term -> Term -- | An unapplied variable. var :: Nat -> Term -- | Add DontCare is it is not already a DontCare. dontCare :: Term -> Term -- | A dummy type. typeDontCare :: Type -- | Top sort (Setomega). topSort :: Type sort :: Sort -> Type varSort :: Int -> Sort -- | Get the next higher sort. sSuc :: Sort -> Sort levelSuc :: Level -> Level mkType :: Integer -> Sort impossibleTerm :: String -> Int -> Term -- | Constructing a singleton telescope. class SgTel a sgTel :: SgTel a => a -> Telescope hackReifyToMeta :: Term isHackReifyToMeta :: Term -> Bool blockingMeta :: Blocked t -> Maybe MetaId blocked :: MetaId -> a -> Blocked a notBlocked :: a -> Blocked a -- | Removing a topmost DontCare constructor. stripDontCare :: Term -> Term -- | Doesn't do any reduction. arity :: Type -> Nat -- | Make a name that is not in scope. notInScopeName :: ArgName -> ArgName -- | Pick the better name suggestion, i.e., the one that is not just -- underscore. class Suggest a b suggest :: Suggest a b => a -> b -> String -- | Convert top-level postfix projections into prefix projections. unSpine :: Term -> Term -- | A view distinguishing the neutrals Var, Def, and -- MetaV which can be projected. hasElims :: Term -> Maybe (Elims -> Term, Elims) -- | Drop Apply constructor. (Unsafe!) argFromElim :: Elim -> Arg Term -- | Drop Apply constructor. (Safe) isApplyElim :: Elim -> Maybe (Arg Term) -- | Drop Apply constructors. (Safe) allApplyElims :: Elims -> Maybe Args -- | Split at first non-Apply splitApplyElims :: Elims -> (Args, Elims) class IsProjElim e isProjElim :: IsProjElim e => e -> Maybe QName -- | Discard Proj f entries. dropProjElims :: IsProjElim e => [e] -> [e] -- | Discards Proj f entries. argsFromElims :: Elims -> Args -- | Drop Proj constructors. (Safe) allProjElims :: Elims -> Maybe [QName] -- | A null clause is one with no patterns and no rhs. Should not -- exist in practice. -- | The size of a telescope is its length (as a list). -- | The size of a term is roughly the number of nodes in its syntax tree. -- This number need not be precise for logical correctness of Agda, it is -- only used for reporting (and maybe decisions regarding performance). -- -- Not counting towards the term size are: -- --
-- (x:A)->B(x) piApply [u] = B(u) ---- -- Precondition: The type must contain the right number of pis without -- having to perform any reduction. -- -- piApply is potentially unsafe, the monadic piApplyM -- is preferable. piApply :: Type -> Args -> Type -- | (abstract args v) apply args --> v[args]. class Abstract t abstract :: Abstract t => Telescope -> t -> t -- | tel ⊢ (Γ ⊢ lhs ↦ rhs : t) becomes tel, Γ ⊢ lhs ↦ rhs : -- t) we do not need to change lhs, rhs, and t since they live in Γ. -- See 'Abstract Clause'. telVars :: Int -> Telescope -> [Arg DeBruijnPattern] namedTelVars :: Int -> Telescope -> [NamedArg DeBruijnPattern] abstractArgs :: Abstract a => Args -> a -> a class DeBruijn a where debruijnVar = debruijnNamedVar underscore debruijnNamedVar _ = debruijnVar debruijnVar :: DeBruijn a => Int -> a debruijnNamedVar :: DeBruijn a => String -> Int -> a debruijnView :: DeBruijn a => a -> Maybe Int idS :: Substitution' a wkS :: Int -> Substitution' a -> Substitution' a raiseS :: Int -> Substitution' a consS :: DeBruijn a => a -> Substitution' a -> Substitution' a -- | To replace index n by term u, do applySubst -- (singletonS n u). singletonS :: DeBruijn a => Int -> a -> Substitution' a -- | Lift a substitution under k binders. liftS :: Int -> Substitution' a -> Substitution' a dropS :: Int -> Substitution' a -> Substitution' a -- |
-- applySubst (ρ composeS σ) v == applySubst ρ (applySubst σ v) --composeS :: Subst a a => Substitution' a -> Substitution' a -> Substitution' a splitS :: Int -> Substitution' a -> (Substitution' a, Substitution' a) (++#) :: DeBruijn a => [a] -> Substitution' a -> Substitution' a infixr 4 ++# prependS :: DeBruijn a => Empty -> [Maybe a] -> Substitution' a -> Substitution' a parallelS :: DeBruijn a => [a] -> Substitution' a compactS :: DeBruijn a => Empty -> [Maybe a] -> Substitution' a -- | Γ ⊢ (strengthenS ⊥ |Δ|) : Γ,Δ strengthenS :: Empty -> Int -> Substitution' a lookupS :: Subst a a => Substitution' a -> Nat -> a -- | Apply a substitution. class DeBruijn t => Subst t a | a -> t applySubst :: Subst t a => Substitution' t -> a -> a raise :: Subst t a => Nat -> a -> a raiseFrom :: Subst t a => Nat -> Nat -> a -> a -- | Replace de Bruijn index i by a Term in something. subst :: Subst t a => Int -> t -> a -> a strengthen :: Subst t a => Empty -> a -> a -- | Replace what is now de Bruijn index 0, but go under n binders. -- substUnder n u == subst n (raise n u). substUnder :: Subst t a => Nat -> t -> a -> a type TelView = TelV Type data TelV a TelV :: Tele (Dom a) -> a -> TelV a [theTel] :: TelV a -> Tele (Dom a) [theCore] :: TelV a -> a type ListTel' a = [Dom (a, Type)] type ListTel = ListTel' ArgName telFromList' :: (a -> ArgName) -> ListTel' a -> Telescope telFromList :: ListTel -> Telescope telToList :: Telescope -> ListTel telToArgs :: Telescope -> [Arg ArgName] -- | Turn a typed binding (x1 .. xn : A) into a telescope. bindsToTel' :: (Name -> a) -> [Name] -> Dom Type -> ListTel' a bindsToTel :: [Name] -> Dom Type -> ListTel -- | Turn a typed binding (x1 .. xn : A) into a telescope. bindsWithHidingToTel' :: (Name -> a) -> [WithHiding Name] -> Dom Type -> ListTel' a bindsWithHidingToTel :: [WithHiding Name] -> Dom Type -> ListTel -- | Takes off all exposed function domains from the given type. This means -- that it does not reduce to expose Pi-types. telView' :: Type -> TelView -- | telView'UpTo n t takes off the first n exposed -- function types of t. Takes off all (exposed ones) if n -- < 0. telView'UpTo :: Int -> Type -> TelView -- |
-- mkPi dom t = telePi (telFromList [dom]) t --mkPi :: Dom (ArgName, Type) -> Type -> Type mkLam :: Arg ArgName -> Term -> Term telePi' :: (Abs Type -> Abs Type) -> Telescope -> Type -> Type -- | Uses free variable analysis to introduce noAbs bindings. telePi :: Telescope -> Type -> Type -- | Everything will be a Abs. telePi_ :: Telescope -> Type -> Type teleLam :: Telescope -> Term -> Term -- | Performs void (noAbs) abstraction over telescope. class TeleNoAbs a teleNoAbs :: TeleNoAbs a => a -> Term -> Term -- | Dependent least upper bound, to assign a level to expressions like -- forall i -> Set i. -- -- dLub s1 i.s2 = omega if i appears in the rigid -- variables of s2. dLub :: Sort -> Abs Sort -> Sort -- | Instantiate an abstraction. Strict in the term. absApp :: Subst t a => Abs a -> t -> a -- | Instantiate an abstraction. Lazy in the term, which allow it to be -- IMPOSSIBLE in the case where the variable shouldn't be used but -- we cannot use noabsApp. Used in Apply. lazyAbsApp :: Subst t a => Abs a -> t -> a -- | Instantiate an abstraction that doesn't use its argument. noabsApp :: Subst t a => Empty -> Abs a -> a absBody :: Subst t a => Abs a -> a mkAbs :: (Subst t a, Free a) => ArgName -> a -> Abs a reAbs :: (Subst t a, Free a) => Abs a -> Abs a -- | underAbs k a b applies k to a and the -- content of abstraction b and puts the abstraction back. -- a is raised if abstraction was proper such that at point of -- application of k and the content of b are at the -- same context. Precondition: a and b are at the same -- context at call time. underAbs :: Subst t a => (a -> b -> b) -> a -> Abs b -> Abs b -- | underLambdas n k a b drops n initial Lams -- from b, performs operation k on a and the -- body of b, and puts the Lams back. a is -- raised correctly according to the number of abstractions. underLambdas :: Subst Term a => Int -> (a -> Term -> Term) -> a -> Term -> Term -- | Methods to retrieve the clauseBody. class GetBody a -- | Returns the properly raised clause Body, and Nothing if -- NoBody. getBody :: GetBody a => a -> Maybe Term -- | Just grabs the body, without raising the de Bruijn indices. This is -- useful if you want to consider the body in context clauseTel. getBodyUnraised :: GetBody a => a -> Maybe Term -- | Syntactic Type equality, ignores sort annotations. -- | Syntactic Term equality, ignores stuff below DontCare -- and sharing. -- | The `rule', if Agda is considered as a functional pure type -- system (pts). -- -- TODO: This needs to be properly implemented, requiring refactoring of -- Agda's handling of levels. Without impredicativity or SizeUniv, -- Agda's pts rule is just the least upper bound, which is total and -- commutative. The handling of levels relies on this simplification. pts :: Sort -> Sort -> Sort sLub :: Sort -> Sort -> Sort lvlView :: Term -> Level levelMax :: [PlusLevel] -> Level sortTm :: Sort -> Term levelSort :: Level -> Sort levelTm :: Level -> Term unLevelAtom :: LevelAtom -> Term -- | Substitutions. data Substitution' a -- | Identity substitution. Γ ⊢ IdS : Γ IdS :: Substitution' a -- | Empty substitution, lifts from the empty context. Apply this to closed -- terms you want to use in a non-empty context. Γ ⊢ EmptyS : () EmptyS :: Substitution' a -- | Substitution extension, `cons'. Γ ⊢ u : Aρ Γ ⊢ ρ : Δ -- ---------------------- Γ ⊢ u :# ρ : Δ, A (:#) :: a -> Substitution' a -> Substitution' a -- | Strengthening substitution. First argument is -- IMPOSSIBLE. Apply this to a term which does not -- contain variable 0 to lower all de Bruijn indices by one. Γ ⊢ ρ : -- Δ --------------------------- Γ ⊢ Strengthen ρ : Δ, A Strengthen :: Empty -> (Substitution' a) -> Substitution' a -- | Weakning substitution, lifts to an extended context. Γ ⊢ ρ : Δ -- ------------------- Γ, Ψ ⊢ Wk |Ψ| ρ : Δ Wk :: !Int -> (Substitution' a) -> Substitution' a -- | Lifting substitution. Use this to go under a binder. Lift 1 ρ == -- var 0 :# Wk 1 ρ. Γ ⊢ ρ : Δ ------------------------- Γ, Ψρ ⊢ -- Lift |Ψ| ρ : Δ, Ψ Lift :: !Int -> (Substitution' a) -> Substitution' a type Substitution = Substitution' Term instance GHC.Base.Functor Agda.TypeChecking.Substitute.TelV instance GHC.Show.Show a => GHC.Show.Show (Agda.TypeChecking.Substitute.TelV a) instance (Agda.TypeChecking.Substitute.Subst t a, GHC.Classes.Eq a) => GHC.Classes.Eq (Agda.TypeChecking.Substitute.TelV a) instance (Agda.TypeChecking.Substitute.Subst t a, GHC.Classes.Ord a) => GHC.Classes.Ord (Agda.TypeChecking.Substitute.TelV a) instance GHC.Classes.Eq (Agda.Syntax.Internal.Substitution' Agda.Syntax.Internal.Term) instance GHC.Classes.Ord (Agda.Syntax.Internal.Substitution' Agda.Syntax.Internal.Term) instance GHC.Classes.Eq Agda.Syntax.Internal.Sort instance GHC.Classes.Ord Agda.Syntax.Internal.Sort instance GHC.Classes.Eq Agda.Syntax.Internal.Level instance GHC.Classes.Ord Agda.Syntax.Internal.Level instance GHC.Classes.Eq Agda.Syntax.Internal.PlusLevel instance GHC.Classes.Ord Agda.Syntax.Internal.LevelAtom instance GHC.Classes.Eq Agda.Syntax.Internal.NotBlocked instance GHC.Classes.Ord Agda.Syntax.Internal.NotBlocked instance GHC.Classes.Eq t => GHC.Classes.Eq (Agda.Syntax.Internal.Blocked t) instance GHC.Classes.Ord t => GHC.Classes.Ord (Agda.Syntax.Internal.Blocked t) instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.Candidate instance (Agda.TypeChecking.Substitute.Subst t a, GHC.Classes.Eq a) => GHC.Classes.Eq (Agda.Syntax.Internal.Elim' a) instance (Agda.TypeChecking.Substitute.Subst t a, GHC.Classes.Ord a) => GHC.Classes.Ord (Agda.Syntax.Internal.Elim' a) instance (Agda.TypeChecking.Substitute.Subst t a, GHC.Classes.Eq a) => GHC.Classes.Eq (Agda.Syntax.Internal.Tele a) instance (Agda.TypeChecking.Substitute.Subst t a, GHC.Classes.Ord a) => GHC.Classes.Ord (Agda.Syntax.Internal.Tele a) instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.Constraint instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.Section instance Agda.TypeChecking.Substitute.Apply Agda.Syntax.Internal.Term instance Agda.TypeChecking.Substitute.Apply Agda.Syntax.Internal.Sort instance Agda.TypeChecking.Substitute.Apply a => Agda.TypeChecking.Substitute.Apply (Agda.Utils.Pointer.Ptr a) instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term a => Agda.TypeChecking.Substitute.Apply (Agda.Syntax.Internal.Tele a) instance Agda.TypeChecking.Substitute.Apply Agda.TypeChecking.Monad.Base.Definition instance Agda.TypeChecking.Substitute.Apply Agda.TypeChecking.Monad.Base.RewriteRule instance Agda.TypeChecking.Substitute.Apply [Agda.TypeChecking.Positivity.Occurrence.Occurrence] instance Agda.TypeChecking.Substitute.Apply [Agda.TypeChecking.Monad.Base.Polarity] instance Agda.TypeChecking.Substitute.Apply Agda.TypeChecking.Monad.Base.Projection instance Agda.TypeChecking.Substitute.Apply Agda.TypeChecking.Monad.Base.Defn instance Agda.TypeChecking.Substitute.Apply Agda.TypeChecking.Monad.Base.PrimFun instance Agda.TypeChecking.Substitute.Apply Agda.Syntax.Internal.Clause instance Agda.TypeChecking.Substitute.Apply Agda.TypeChecking.CompiledClause.CompiledClauses instance Agda.TypeChecking.Substitute.Apply a => Agda.TypeChecking.Substitute.Apply (Agda.TypeChecking.CompiledClause.WithArity a) instance Agda.TypeChecking.Substitute.Apply a => Agda.TypeChecking.Substitute.Apply (Agda.TypeChecking.CompiledClause.Case a) instance Agda.TypeChecking.Substitute.Apply Agda.TypeChecking.Monad.Base.FunctionInverse instance Agda.TypeChecking.Substitute.Apply Agda.Syntax.Internal.ClauseBody instance Agda.TypeChecking.Substitute.Apply Agda.TypeChecking.Monad.Base.DisplayTerm instance Agda.TypeChecking.Substitute.Apply t => Agda.TypeChecking.Substitute.Apply [t] instance Agda.TypeChecking.Substitute.Apply t => Agda.TypeChecking.Substitute.Apply (Agda.Syntax.Internal.Blocked t) instance Agda.TypeChecking.Substitute.Apply t => Agda.TypeChecking.Substitute.Apply (GHC.Base.Maybe t) instance Agda.TypeChecking.Substitute.Apply v => Agda.TypeChecking.Substitute.Apply (Data.Map.Base.Map k v) instance (Agda.TypeChecking.Substitute.Apply a, Agda.TypeChecking.Substitute.Apply b) => Agda.TypeChecking.Substitute.Apply (a, b) instance (Agda.TypeChecking.Substitute.Apply a, Agda.TypeChecking.Substitute.Apply b, Agda.TypeChecking.Substitute.Apply c) => Agda.TypeChecking.Substitute.Apply (a, b, c) instance Agda.Utils.Permutation.DoDrop a => Agda.TypeChecking.Substitute.Apply (Agda.Utils.Permutation.Drop a) instance Agda.Utils.Permutation.DoDrop a => Agda.TypeChecking.Substitute.Abstract (Agda.Utils.Permutation.Drop a) instance Agda.TypeChecking.Substitute.Apply Agda.Utils.Permutation.Permutation instance Agda.TypeChecking.Substitute.Abstract Agda.Utils.Permutation.Permutation instance Agda.TypeChecking.Substitute.Abstract Agda.Syntax.Internal.Term instance Agda.TypeChecking.Substitute.Abstract Agda.Syntax.Internal.Type instance Agda.TypeChecking.Substitute.Abstract Agda.Syntax.Internal.Sort instance Agda.TypeChecking.Substitute.Abstract Agda.Syntax.Internal.Telescope instance Agda.TypeChecking.Substitute.Abstract Agda.TypeChecking.Monad.Base.Definition instance Agda.TypeChecking.Substitute.Abstract Agda.TypeChecking.Monad.Base.RewriteRule instance Agda.TypeChecking.Substitute.Abstract [Agda.TypeChecking.Positivity.Occurrence.Occurrence] instance Agda.TypeChecking.Substitute.Abstract [Agda.TypeChecking.Monad.Base.Polarity] instance Agda.TypeChecking.Substitute.Abstract Agda.TypeChecking.Monad.Base.Projection instance Agda.TypeChecking.Substitute.Abstract Agda.TypeChecking.Monad.Base.Defn instance Agda.TypeChecking.Substitute.Abstract Agda.TypeChecking.Monad.Base.PrimFun instance Agda.TypeChecking.Substitute.Abstract Agda.Syntax.Internal.Clause instance Agda.TypeChecking.Substitute.Abstract Agda.TypeChecking.CompiledClause.CompiledClauses instance Agda.TypeChecking.Substitute.Abstract a => Agda.TypeChecking.Substitute.Abstract (Agda.TypeChecking.CompiledClause.WithArity a) instance Agda.TypeChecking.Substitute.Abstract a => Agda.TypeChecking.Substitute.Abstract (Agda.TypeChecking.CompiledClause.Case a) instance Agda.TypeChecking.Substitute.Abstract Agda.TypeChecking.Monad.Base.FunctionInverse instance Agda.TypeChecking.Substitute.Abstract Agda.Syntax.Internal.ClauseBody instance Agda.TypeChecking.Substitute.Abstract t => Agda.TypeChecking.Substitute.Abstract [t] instance Agda.TypeChecking.Substitute.Abstract t => Agda.TypeChecking.Substitute.Abstract (GHC.Base.Maybe t) instance Agda.TypeChecking.Substitute.Abstract v => Agda.TypeChecking.Substitute.Abstract (Data.Map.Base.Map k v) instance Agda.TypeChecking.Substitute.DeBruijn Agda.Syntax.Internal.Term instance Agda.TypeChecking.Substitute.Subst a a => Agda.TypeChecking.Substitute.Subst a (Agda.Syntax.Internal.Substitution' a) instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.Term instance Agda.TypeChecking.Substitute.Subst t a => Agda.TypeChecking.Substitute.Subst t (Agda.Utils.Pointer.Ptr a) instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term a => Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term (Agda.Syntax.Internal.Type' a) instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.Sort instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.Level instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.PlusLevel instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.LevelAtom instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.Syntax.Abstract.Name.Name instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term GHC.Base.String instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.ConPatternInfo instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.Pattern instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.NLPat instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.RewriteRule instance Agda.TypeChecking.Substitute.Subst t a => Agda.TypeChecking.Substitute.Subst t (Agda.Syntax.Internal.Blocked a) instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.DisplayForm instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.DisplayTerm instance Agda.TypeChecking.Substitute.Subst t a => Agda.TypeChecking.Substitute.Subst t (Agda.Syntax.Internal.Tele a) instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.Constraint instance Agda.TypeChecking.Substitute.Subst t a => Agda.TypeChecking.Substitute.Subst t (Agda.Syntax.Internal.Elim' a) instance Agda.TypeChecking.Substitute.Subst t a => Agda.TypeChecking.Substitute.Subst t (Agda.Syntax.Internal.Abs a) instance Agda.TypeChecking.Substitute.Subst t a => Agda.TypeChecking.Substitute.Subst t (Agda.Syntax.Common.Arg a) instance Agda.TypeChecking.Substitute.Subst t a => Agda.TypeChecking.Substitute.Subst t (Agda.Syntax.Common.Named name a) instance Agda.TypeChecking.Substitute.Subst t a => Agda.TypeChecking.Substitute.Subst t (Agda.Syntax.Common.Dom a) instance Agda.TypeChecking.Substitute.Subst t a => Agda.TypeChecking.Substitute.Subst t (GHC.Base.Maybe a) instance Agda.TypeChecking.Substitute.Subst t a => Agda.TypeChecking.Substitute.Subst t [a] instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term () instance (Agda.TypeChecking.Substitute.Subst t a, Agda.TypeChecking.Substitute.Subst t b) => Agda.TypeChecking.Substitute.Subst t (a, b) instance (Agda.TypeChecking.Substitute.Subst t a, Agda.TypeChecking.Substitute.Subst t b, Agda.TypeChecking.Substitute.Subst t c) => Agda.TypeChecking.Substitute.Subst t (a, b, c) instance (Agda.TypeChecking.Substitute.Subst t a, Agda.TypeChecking.Substitute.Subst t b, Agda.TypeChecking.Substitute.Subst t c, Agda.TypeChecking.Substitute.Subst t d) => Agda.TypeChecking.Substitute.Subst t (a, b, c, d) instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.ClauseBody instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.Candidate instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.EqualityView instance Agda.TypeChecking.Substitute.TeleNoAbs Agda.TypeChecking.Substitute.ListTel instance Agda.TypeChecking.Substitute.TeleNoAbs Agda.Syntax.Internal.Telescope instance Agda.TypeChecking.Substitute.GetBody Agda.Syntax.Internal.ClauseBody instance Agda.TypeChecking.Substitute.GetBody Agda.Syntax.Internal.Clause instance GHC.Classes.Ord Agda.Syntax.Internal.PlusLevel instance GHC.Classes.Eq Agda.Syntax.Internal.LevelAtom instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Syntax.Internal.Type' a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Agda.Syntax.Internal.Type' a) instance GHC.Classes.Eq Agda.Syntax.Internal.Term instance GHC.Classes.Ord Agda.Syntax.Internal.Term instance (Agda.TypeChecking.Substitute.Subst t a, GHC.Classes.Eq a) => GHC.Classes.Eq (Agda.Syntax.Internal.Abs a) instance (Agda.TypeChecking.Substitute.Subst t a, GHC.Classes.Ord a) => GHC.Classes.Ord (Agda.Syntax.Internal.Abs a) module Agda.Compiler.Treeless.Subst newtype UnderLambda UnderLambda :: Any -> UnderLambda newtype SeqArg SeqArg :: All -> SeqArg data Occurs Occurs :: Int -> UnderLambda -> SeqArg -> Occurs once :: Occurs inSeq :: Occurs -> Occurs underLambda :: Occurs -> Occurs class HasFree a freeVars :: HasFree a => a -> Map Int Occurs freeIn :: HasFree a => Int -> a -> Bool occursIn :: HasFree a => Int -> a -> Occurs data Binder a Binder :: Int -> a -> Binder a newtype InSeq a InSeq :: a -> InSeq a instance GHC.Show.Show Agda.Compiler.Treeless.Subst.Occurs instance GHC.Classes.Ord Agda.Compiler.Treeless.Subst.Occurs instance GHC.Classes.Eq Agda.Compiler.Treeless.Subst.Occurs instance GHC.Base.Monoid Agda.Compiler.Treeless.Subst.SeqArg instance GHC.Show.Show Agda.Compiler.Treeless.Subst.SeqArg instance GHC.Classes.Ord Agda.Compiler.Treeless.Subst.SeqArg instance GHC.Classes.Eq Agda.Compiler.Treeless.Subst.SeqArg instance GHC.Base.Monoid Agda.Compiler.Treeless.Subst.UnderLambda instance GHC.Show.Show Agda.Compiler.Treeless.Subst.UnderLambda instance GHC.Classes.Ord Agda.Compiler.Treeless.Subst.UnderLambda instance GHC.Classes.Eq Agda.Compiler.Treeless.Subst.UnderLambda instance Agda.TypeChecking.Substitute.DeBruijn Agda.Syntax.Treeless.TTerm instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Treeless.TTerm Agda.Syntax.Treeless.TTerm instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Treeless.TTerm Agda.Syntax.Treeless.TAlt instance GHC.Base.Monoid Agda.Compiler.Treeless.Subst.Occurs instance Agda.Compiler.Treeless.Subst.HasFree GHC.Types.Int instance Agda.Compiler.Treeless.Subst.HasFree a => Agda.Compiler.Treeless.Subst.HasFree [a] instance (Agda.Compiler.Treeless.Subst.HasFree a, Agda.Compiler.Treeless.Subst.HasFree b) => Agda.Compiler.Treeless.Subst.HasFree (a, b) instance Agda.Compiler.Treeless.Subst.HasFree a => Agda.Compiler.Treeless.Subst.HasFree (Agda.Compiler.Treeless.Subst.Binder a) instance Agda.Compiler.Treeless.Subst.HasFree a => Agda.Compiler.Treeless.Subst.HasFree (Agda.Compiler.Treeless.Subst.InSeq a) instance Agda.Compiler.Treeless.Subst.HasFree Agda.Syntax.Treeless.TTerm instance Agda.Compiler.Treeless.Subst.HasFree Agda.Syntax.Treeless.TAlt module Agda.Compiler.Treeless.Compare equalTerms :: TTerm -> TTerm -> Bool -- | Translates guard alternatives to if-then-else cascades. -- -- The builtin translation must be run before this transformation. module Agda.Compiler.Treeless.GuardsToPrims convertGuards :: TTerm -> TTerm module Agda.Compiler.Treeless.Uncase caseToSeq :: Monad m => TTerm -> m TTerm module Agda.TypeChecking.LevelConstraints -- | simplifyLevelConstraint n c cs turns an c into an -- equality constraint if it is an inequality constraint and the reverse -- inequality is contained in cs. Number n is the -- length of the context c is defined in. simplifyLevelConstraint :: Int -> Constraint -> Constraints -> Constraint instance GHC.Classes.Eq Agda.TypeChecking.LevelConstraints.Leq instance GHC.Show.Show Agda.TypeChecking.LevelConstraints.Leq module Agda.TypeChecking.Monad.Builtin class (Functor m, Applicative m, Monad m) => HasBuiltins m getBuiltinThing :: HasBuiltins m => String -> m (Maybe (Builtin PrimFun)) litType :: Literal -> TCM Type setBuiltinThings :: BuiltinThings PrimFun -> TCM () bindBuiltinName :: String -> Term -> TCM () bindPrimitive :: String -> PrimFun -> TCM () getBuiltin :: String -> TCM Term getBuiltin' :: HasBuiltins m => String -> m (Maybe Term) getPrimitive' :: HasBuiltins m => String -> m (Maybe PrimFun) getPrimitive :: String -> TCM PrimFun -- | Rewrite a literal to constructor form if possible. constructorForm :: Term -> TCM Term constructorForm' :: Applicative m => m Term -> m Term -> Term -> m Term primInteger :: TCM Term primIntegerPos :: TCM Term primIntegerNegSuc :: TCM Term primFloat :: TCM Term primChar :: TCM Term primString :: TCM Term primUnit :: TCM Term primUnitUnit :: TCM Term primBool :: TCM Term primTrue :: TCM Term primFalse :: TCM Term primList :: TCM Term primNil :: TCM Term primCons :: TCM Term primIO :: TCM Term primNat :: TCM Term primSuc :: TCM Term primZero :: TCM Term primNatPlus :: TCM Term primNatMinus :: TCM Term primNatTimes :: TCM Term primNatDivSucAux :: TCM Term primNatModSucAux :: TCM Term primNatEquality :: TCM Term primNatLess :: TCM Term primSizeUniv :: TCM Term primSize :: TCM Term primSizeLt :: TCM Term primSizeSuc :: TCM Term primSizeInf :: TCM Term primSizeMax :: TCM Term primInf :: TCM Term primSharp :: TCM Term primFlat :: TCM Term primEquality :: TCM Term primRefl :: TCM Term primRewrite :: TCM Term primLevel :: TCM Term primLevelZero :: TCM Term primLevelSuc :: TCM Term primLevelMax :: TCM Term primFromNat :: TCM Term primFromNeg :: TCM Term primFromString :: TCM Term primQName :: TCM Term primArgInfo :: TCM Term primArgArgInfo :: TCM Term primArg :: TCM Term primArgArg :: TCM Term primAbs :: TCM Term primAbsAbs :: TCM Term primAgdaTerm :: TCM Term primAgdaTermVar :: TCM Term primAgdaTermLam :: TCM Term primAgdaTermExtLam :: TCM Term primAgdaTermDef :: TCM Term primAgdaTermCon :: TCM Term primAgdaTermPi :: TCM Term primAgdaTermSort :: TCM Term primAgdaTermLit :: TCM Term primAgdaTermUnsupported :: TCM Term primAgdaTermMeta :: TCM Term primAgdaErrorPart :: TCM Term primAgdaErrorPartString :: TCM Term primAgdaErrorPartTerm :: TCM Term primAgdaErrorPartName :: TCM Term primHiding :: TCM Term primHidden :: TCM Term primInstance :: TCM Term primVisible :: TCM Term primRelevance :: TCM Term primRelevant :: TCM Term primIrrelevant :: TCM Term primAgdaLiteral :: TCM Term primAgdaLitNat :: TCM Term primAgdaLitFloat :: TCM Term primAgdaLitString :: TCM Term primAgdaLitChar :: TCM Term primAgdaLitQName :: TCM Term primAgdaLitMeta :: TCM Term primAgdaSort :: TCM Term primAgdaSortSet :: TCM Term primAgdaSortLit :: TCM Term primAgdaSortUnsupported :: TCM Term primAgdaDefinition :: TCM Term primAgdaDefinitionFunDef :: TCM Term primAgdaDefinitionDataDef :: TCM Term primAgdaDefinitionRecordDef :: TCM Term primAgdaDefinitionPostulate :: TCM Term primAgdaDefinitionPrimitive :: TCM Term primAgdaDefinitionDataConstructor :: TCM Term primAgdaClause :: TCM Term primAgdaClauseClause :: TCM Term primAgdaClauseAbsurd :: TCM Term primAgdaPattern :: TCM Term primAgdaPatCon :: TCM Term primAgdaPatVar :: TCM Term primAgdaPatDot :: TCM Term primAgdaPatLit :: TCM Term primAgdaPatProj :: TCM Term primAgdaPatAbsurd :: TCM Term primAgdaMeta :: TCM Term primAgdaTCM :: TCM Term primAgdaTCMReturn :: TCM Term primAgdaTCMBind :: TCM Term primAgdaTCMUnify :: TCM Term primAgdaTCMTypeError :: TCM Term primAgdaTCMInferType :: TCM Term primAgdaTCMCheckType :: TCM Term primAgdaTCMNormalise :: TCM Term primAgdaTCMCatchError :: TCM Term primAgdaTCMGetContext :: TCM Term primAgdaTCMExtendContext :: TCM Term primAgdaTCMInContext :: TCM Term primAgdaTCMFreshName :: TCM Term primAgdaTCMDeclareDef :: TCM Term primAgdaTCMDefineFun :: TCM Term primAgdaTCMGetType :: TCM Term primAgdaTCMGetDefinition :: TCM Term primAgdaTCMQuoteTerm :: TCM Term primAgdaTCMUnquoteTerm :: TCM Term primAgdaTCMBlockOnMeta :: TCM Term primAgdaTCMCommit :: TCM Term builtinNat :: String builtinSuc :: String builtinZero :: String builtinNatPlus :: String builtinNatMinus :: String builtinNatTimes :: String builtinNatDivSucAux :: String builtinNatModSucAux :: String builtinNatEquals :: String builtinNatLess :: String builtinInteger :: String builtinIntegerPos :: String builtinIntegerNegSuc :: String builtinFloat :: String builtinChar :: String builtinString :: String builtinUnit :: String builtinUnitUnit :: String builtinBool :: String builtinTrue :: String builtinFalse :: String builtinList :: String builtinNil :: String builtinCons :: String builtinIO :: String builtinSizeUniv :: String builtinSize :: String builtinSizeLt :: String builtinSizeSuc :: String builtinSizeInf :: String builtinSizeMax :: String builtinInf :: String builtinSharp :: String builtinFlat :: String builtinEquality :: String builtinRefl :: String builtinRewrite :: String builtinLevelMax :: String builtinLevel :: String builtinLevelZero :: String builtinLevelSuc :: String builtinFromNat :: String builtinFromNeg :: String builtinFromString :: String builtinQName :: String builtinAgdaSort :: String builtinAgdaSortSet :: String builtinAgdaSortLit :: String builtinAgdaSortUnsupported :: String builtinHiding :: String builtinHidden :: String builtinInstance :: String builtinVisible :: String builtinRelevance :: String builtinRelevant :: String builtinIrrelevant :: String builtinArg :: String builtinArgInfo :: String builtinArgArgInfo :: String builtinArgArg :: String builtinAbs :: String builtinAbsAbs :: String builtinAgdaTerm :: String builtinAgdaTermVar :: String builtinAgdaTermLam :: String builtinAgdaTermExtLam :: String builtinAgdaTermDef :: String builtinAgdaTermCon :: String builtinAgdaTermPi :: String builtinAgdaTermSort :: String builtinAgdaTermLit :: String builtinAgdaTermUnsupported :: String builtinAgdaTermMeta :: String builtinAgdaErrorPart :: String builtinAgdaErrorPartString :: String builtinAgdaErrorPartTerm :: String builtinAgdaErrorPartName :: String builtinAgdaLiteral :: String builtinAgdaLitNat :: String builtinAgdaLitFloat :: String builtinAgdaLitChar :: String builtinAgdaLitString :: String builtinAgdaLitQName :: String builtinAgdaLitMeta :: String builtinAgdaClause :: String builtinAgdaClauseClause :: String builtinAgdaClauseAbsurd :: String builtinAgdaPattern :: String builtinAgdaPatVar :: String builtinAgdaPatCon :: String builtinAgdaPatDot :: String builtinAgdaPatLit :: String builtinAgdaPatProj :: String builtinAgdaPatAbsurd :: String builtinAgdaDefinitionFunDef :: String builtinAgdaDefinitionDataDef :: String builtinAgdaDefinitionRecordDef :: String builtinAgdaDefinitionDataConstructor :: String builtinAgdaDefinitionPostulate :: String builtinAgdaDefinitionPrimitive :: String builtinAgdaDefinition :: String builtinAgdaMeta :: String builtinAgdaTCM :: String builtinAgdaTCMReturn :: String builtinAgdaTCMBind :: String builtinAgdaTCMUnify :: String builtinAgdaTCMTypeError :: String builtinAgdaTCMInferType :: String builtinAgdaTCMCheckType :: String builtinAgdaTCMNormalise :: String builtinAgdaTCMCatchError :: String builtinAgdaTCMGetContext :: String builtinAgdaTCMExtendContext :: String builtinAgdaTCMInContext :: String builtinAgdaTCMFreshName :: String builtinAgdaTCMDeclareDef :: String builtinAgdaTCMDefineFun :: String builtinAgdaTCMGetType :: String builtinAgdaTCMGetDefinition :: String builtinAgdaTCMQuoteTerm :: String builtinAgdaTCMUnquoteTerm :: String builtinAgdaTCMBlockOnMeta :: String builtinAgdaTCMCommit :: String -- | Builtins that come without a definition in Agda syntax. These are -- giving names to Agda internal concepts which cannot be assigned an -- Agda type. -- -- An example would be a user-defined name for Set. -- -- {--} -- -- The type of Type would be Type : Level → Setω which -- is not valid Agda. builtinsNoDef :: [String] -- | The coinductive primitives. data CoinductionKit CoinductionKit :: QName -> QName -> QName -> CoinductionKit [nameOfInf] :: CoinductionKit -> QName [nameOfSharp] :: CoinductionKit -> QName [nameOfFlat] :: CoinductionKit -> QName -- | Tries to build a CoinductionKit. coinductionKit' :: TCM CoinductionKit coinductionKit :: TCM (Maybe CoinductionKit) -- | Get the name of the equality type. primEqualityName :: TCM QName -- | Check whether the type is actually an equality (lhs ≡ rhs) and extract -- lhs, rhs, and their type. -- -- Precondition: type is reduced. equalityView :: Type -> TCM EqualityView -- | Revert the EqualityView. -- -- Postcondition: type is reduced. equalityUnview :: EqualityView -> Type instance Control.Monad.IO.Class.MonadIO m => Agda.TypeChecking.Monad.Builtin.HasBuiltins (Agda.TypeChecking.Monad.Base.TCMT m) module Agda.TypeChecking.Monad.Open -- | Create an open term in the current context. makeOpen :: a -> TCM (Open a) -- | Create an open term which is closed. makeClosed :: a -> Open a -- | Check if an Open is closed. isClosed :: Open a -> Bool -- | Extract the value from an open term. Must be done in an extension of -- the context in which the term was created. getOpen :: (Subst t a, MonadReader TCEnv m) => Open a -> m a -- | Try to use an Open the current context. Returns Nothing -- if current context is not an extension of the context in which the -- Open was created. tryOpen :: (Subst t a, MonadReader TCEnv m) => Open a -> m (Maybe a) module Agda.TypeChecking.Substitute.Pattern fromPatternSubstitution :: PatternSubstitution -> Substitution applyPatSubst :: (Subst Term a) => PatternSubstitution -> a -> a instance Agda.TypeChecking.Substitute.DeBruijn Agda.Syntax.Internal.DeBruijnPattern instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.DeBruijnPattern Agda.Syntax.Internal.DeBruijnPattern module Agda.TypeChecking.Test.Generators data TermConfiguration TermConf :: [QName] -> [QName] -> [QName] -> [Nat] -> UseLiterals -> Frequencies -> Maybe Int -> Bool -> TermConfiguration [tcDefinedNames] :: TermConfiguration -> [QName] [tcConstructorNames] :: TermConfiguration -> [QName] [tcProjectionNames] :: TermConfiguration -> [QName] [tcFreeVariables] :: TermConfiguration -> [Nat] [tcLiterals] :: TermConfiguration -> UseLiterals [tcFrequencies] :: TermConfiguration -> Frequencies -- | Maximum size of the generated element. When Nothing this -- value is initialized from the size parameter. [tcFixSize] :: TermConfiguration -> Maybe Int -- | When this is true no lambdas, literals, or constructors are generated [tcIsType] :: TermConfiguration -> Bool data Frequencies Freqs :: HiddenFreqs -> ElimFreqs -> SortFreqs -> TermFreqs -> Frequencies [hiddenFreqs] :: Frequencies -> HiddenFreqs [elimFreqs] :: Frequencies -> ElimFreqs [sortFreqs] :: Frequencies -> SortFreqs [termFreqs] :: Frequencies -> TermFreqs data TermFreqs TermFreqs :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> TermFreqs [varFreq] :: TermFreqs -> Int [defFreq] :: TermFreqs -> Int [conFreq] :: TermFreqs -> Int [litFreq] :: TermFreqs -> Int [sortFreq] :: TermFreqs -> Int [lamFreq] :: TermFreqs -> Int [piFreq] :: TermFreqs -> Int [funFreq] :: TermFreqs -> Int data ElimFreqs ElimFreqs :: Int -> Int -> ElimFreqs [applyFreq] :: ElimFreqs -> Int [projFreq] :: ElimFreqs -> Int data HiddenFreqs HiddenFreqs :: Int -> Int -> HiddenFreqs [hiddenFreq] :: HiddenFreqs -> Int [notHiddenFreq] :: HiddenFreqs -> Int data SortFreqs SortFreqs :: [Int] -> Int -> SortFreqs [setFreqs] :: SortFreqs -> [Int] [propFreq] :: SortFreqs -> Int defaultFrequencies :: Frequencies noProp :: TermConfiguration -> TermConfiguration data UseLiterals UseLit :: Bool -> Bool -> Bool -> Bool -> UseLiterals [useLitInt] :: UseLiterals -> Bool [useLitFloat] :: UseLiterals -> Bool [useLitString] :: UseLiterals -> Bool [useLitChar] :: UseLiterals -> Bool noLiterals :: UseLiterals fixSizeConf :: Int -> TermConfiguration -> TermConfiguration resizeConf :: (Int -> Int) -> TermConfiguration -> TermConfiguration decrConf :: TermConfiguration -> TermConfiguration divConf :: TermConfiguration -> Int -> TermConfiguration isTypeConf :: TermConfiguration -> TermConfiguration isntTypeConf :: TermConfiguration -> TermConfiguration extendConf :: TermConfiguration -> TermConfiguration extendWithTelConf :: Telescope -> TermConfiguration -> TermConfiguration makeConfiguration :: [RawName] -> [RawName] -> [RawName] -> [Nat] -> TermConfiguration class GenC a genC :: GenC a => TermConfiguration -> Gen a newtype YesType a YesType :: a -> YesType a [unYesType] :: YesType a -> a newtype NoType a NoType :: a -> NoType a [unNoType] :: NoType a -> a newtype VarName VarName :: Nat -> VarName [unVarName] :: VarName -> Nat newtype DefName DefName :: QName -> DefName [unDefName] :: DefName -> QName newtype ConName ConName :: ConHead -> ConName [unConName] :: ConName -> ConHead newtype ProjName ProjName :: QName -> ProjName [unProjName] :: ProjName -> QName newtype SizedList a SizedList :: [a] -> SizedList a [unSizedList] :: SizedList a -> [a] fixSize :: TermConfiguration -> Gen a -> Gen a genArgs :: TermConfiguration -> Gen Args genElims :: TermConfiguration -> Gen Elims -- | Only generates default configurations. Names and free variables -- varies. genConf :: Gen TermConfiguration class ShrinkC a b | a -> b shrinkC :: ShrinkC a b => TermConfiguration -> a -> [b] noShrink :: ShrinkC a b => a -> b killAbs :: KillVar a => Abs a -> a class KillVar a killVar :: KillVar a => Nat -> a -> a isWellScoped :: FreeVS a => TermConfiguration -> a -> Bool -- | Check that the generated terms don't have any out of scope variables. prop_wellScopedVars :: TermConfiguration -> Property instance GHC.Show.Show Agda.TypeChecking.Test.Generators.TermConfiguration instance GHC.Show.Show Agda.TypeChecking.Test.Generators.UseLiterals instance GHC.Show.Show Agda.TypeChecking.Test.Generators.Frequencies instance GHC.Show.Show Agda.TypeChecking.Test.Generators.SortFreqs instance GHC.Show.Show Agda.TypeChecking.Test.Generators.HiddenFreqs instance GHC.Show.Show Agda.TypeChecking.Test.Generators.ElimFreqs instance GHC.Show.Show Agda.TypeChecking.Test.Generators.TermFreqs instance Agda.TypeChecking.Test.Generators.GenC a => Agda.TypeChecking.Test.Generators.GenC (Agda.TypeChecking.Test.Generators.SizedList a) instance Agda.TypeChecking.Test.Generators.GenC a => Agda.TypeChecking.Test.Generators.GenC [a] instance (Agda.TypeChecking.Test.Generators.GenC a, Agda.TypeChecking.Test.Generators.GenC b) => Agda.TypeChecking.Test.Generators.GenC (a, b) instance Agda.TypeChecking.Test.Generators.GenC Agda.Syntax.Position.Range instance Agda.TypeChecking.Test.Generators.GenC Agda.Syntax.Common.Hiding instance Agda.TypeChecking.Test.Generators.GenC a => Agda.TypeChecking.Test.Generators.GenC (Agda.Syntax.Common.Arg a) instance Agda.TypeChecking.Test.Generators.GenC a => Agda.TypeChecking.Test.Generators.GenC (Agda.Syntax.Common.Dom a) instance Agda.TypeChecking.Test.Generators.GenC a => Agda.TypeChecking.Test.Generators.GenC (Agda.Syntax.Internal.Abs a) instance Agda.TypeChecking.Test.Generators.GenC a => Agda.TypeChecking.Test.Generators.GenC (Agda.Syntax.Internal.Elim' a) instance Agda.TypeChecking.Test.Generators.GenC Agda.TypeChecking.Test.Generators.DefName instance Agda.TypeChecking.Test.Generators.GenC Agda.TypeChecking.Test.Generators.ProjName instance Agda.TypeChecking.Test.Generators.GenC Agda.Syntax.Internal.Sort instance Agda.TypeChecking.Test.Generators.GenC GHC.Types.Char instance Agda.TypeChecking.Test.Generators.GenC GHC.Types.Double instance Agda.TypeChecking.Test.Generators.GenC GHC.Integer.Type.Integer instance Agda.TypeChecking.Test.Generators.GenC Agda.Syntax.Literal.Literal instance Agda.TypeChecking.Test.Generators.GenC Agda.Syntax.Internal.Telescope instance Agda.TypeChecking.Test.Generators.GenC Agda.Syntax.Internal.Type instance Agda.TypeChecking.Test.Generators.GenC Agda.Syntax.Internal.Term instance Test.QuickCheck.Arbitrary.Arbitrary Agda.TypeChecking.Test.Generators.TermConfiguration instance Agda.TypeChecking.Test.Generators.ShrinkC a b => Agda.TypeChecking.Test.Generators.ShrinkC (Agda.TypeChecking.Test.Generators.YesType a) b instance Agda.TypeChecking.Test.Generators.ShrinkC a b => Agda.TypeChecking.Test.Generators.ShrinkC (Agda.TypeChecking.Test.Generators.NoType a) b instance Agda.TypeChecking.Test.Generators.ShrinkC a b => Agda.TypeChecking.Test.Generators.ShrinkC [a] [b] instance (Agda.TypeChecking.Test.Generators.ShrinkC a a', Agda.TypeChecking.Test.Generators.ShrinkC b b') => Agda.TypeChecking.Test.Generators.ShrinkC (a, b) (a', b') instance Agda.TypeChecking.Test.Generators.ShrinkC Agda.TypeChecking.Test.Generators.VarName Agda.Syntax.Common.Nat instance Agda.TypeChecking.Test.Generators.ShrinkC Agda.TypeChecking.Test.Generators.DefName Agda.Syntax.Abstract.Name.QName instance Agda.TypeChecking.Test.Generators.ShrinkC Agda.TypeChecking.Test.Generators.ConName Agda.Syntax.Internal.ConHead instance Agda.TypeChecking.Test.Generators.ShrinkC Agda.Syntax.Literal.Literal Agda.Syntax.Literal.Literal instance Agda.TypeChecking.Test.Generators.ShrinkC GHC.Types.Char GHC.Types.Char instance Agda.TypeChecking.Test.Generators.ShrinkC Agda.Syntax.Common.Hiding Agda.Syntax.Common.Hiding instance Agda.TypeChecking.Test.Generators.ShrinkC a b => Agda.TypeChecking.Test.Generators.ShrinkC (Agda.Syntax.Internal.Abs a) (Agda.Syntax.Internal.Abs b) instance Agda.TypeChecking.Test.Generators.ShrinkC a b => Agda.TypeChecking.Test.Generators.ShrinkC (Agda.Syntax.Common.Arg a) (Agda.Syntax.Common.Arg b) instance Agda.TypeChecking.Test.Generators.ShrinkC a b => Agda.TypeChecking.Test.Generators.ShrinkC (Agda.Syntax.Common.Dom a) (Agda.Syntax.Common.Dom b) instance Agda.TypeChecking.Test.Generators.ShrinkC a b => Agda.TypeChecking.Test.Generators.ShrinkC (Agda.Syntax.Internal.Blocked a) (Agda.Syntax.Internal.Blocked b) instance Agda.TypeChecking.Test.Generators.ShrinkC a b => Agda.TypeChecking.Test.Generators.ShrinkC (Agda.Syntax.Internal.Elim' a) (Agda.Syntax.Internal.Elim' b) instance Agda.TypeChecking.Test.Generators.ShrinkC Agda.Syntax.Internal.Sort Agda.Syntax.Internal.Sort instance Agda.TypeChecking.Test.Generators.ShrinkC Agda.Syntax.Internal.Telescope Agda.Syntax.Internal.Telescope instance Agda.TypeChecking.Test.Generators.ShrinkC Agda.Syntax.Internal.Type Agda.Syntax.Internal.Type instance Agda.TypeChecking.Test.Generators.ShrinkC Agda.Syntax.Internal.Term Agda.Syntax.Internal.Term instance Agda.TypeChecking.Test.Generators.KillVar Agda.Syntax.Internal.Term instance Agda.TypeChecking.Test.Generators.KillVar Agda.Syntax.Internal.Type instance Agda.TypeChecking.Test.Generators.KillVar Agda.Syntax.Internal.Telescope instance Agda.TypeChecking.Test.Generators.KillVar a => Agda.TypeChecking.Test.Generators.KillVar (Agda.Syntax.Internal.Elim' a) instance Agda.TypeChecking.Test.Generators.KillVar a => Agda.TypeChecking.Test.Generators.KillVar (Agda.Syntax.Common.Arg a) instance Agda.TypeChecking.Test.Generators.KillVar a => Agda.TypeChecking.Test.Generators.KillVar (Agda.Syntax.Common.Dom a) instance Agda.TypeChecking.Test.Generators.KillVar a => Agda.TypeChecking.Test.Generators.KillVar (Agda.Syntax.Internal.Abs a) instance Agda.TypeChecking.Test.Generators.KillVar a => Agda.TypeChecking.Test.Generators.KillVar [a] instance Agda.TypeChecking.Test.Generators.KillVar a => Agda.TypeChecking.Test.Generators.KillVar (GHC.Base.Maybe a) instance (Agda.TypeChecking.Test.Generators.KillVar a, Agda.TypeChecking.Test.Generators.KillVar b) => Agda.TypeChecking.Test.Generators.KillVar (a, b) -- | Tests for free variable computations. module Agda.TypeChecking.Free.Tests -- | All tests as collected by quickCheckAll. tests :: IO Bool -- | Measure CPU time for individual phases of the Agda pipeline. module Agda.TypeChecking.Monad.Benchmark -- | Monad with access to benchmarking data. class (Ord a, Functor m, MonadIO m) => MonadBench a m | m -> a where getsBenchmark f = f <$> getBenchmark putBenchmark b = modifyBenchmark $ const b modifyBenchmark f = do { b <- getBenchmark; putBenchmark $! f b } getBenchmark :: MonadBench a m => m (Benchmark a) getBenchmark :: MonadBench a m => m (Benchmark a) -- | When verbosity is set or changes, we need to turn benchmarking on or -- off. updateBenchmarkingStatus :: TCM () -- | Bill a computation to a specific account. Works even if the -- computation is aborted by an exception. billTo :: MonadBench a m => Account a -> m c -> m c -- | Bill a pure computation to a specific account. billPureTo :: MonadBench a m => Account a -> c -> m c -- | Resets the account and the timing information. reset :: MonadBench a m => m () -- | Prints the accumulated benchmark results. Does nothing if profiling is -- not activated at level 7. print :: MonadTCM tcm => tcm () -- | Functions which map between module names and file names. -- -- Note that file name lookups are cached in the TCState. The code -- assumes that no Agda source files are added or removed from the -- include directories while the code is being type checked. module Agda.Interaction.FindFile -- | Converts an Agda file name to the corresponding interface file name. toIFile :: AbsolutePath -> AbsolutePath -- | Errors which can arise when trying to find a source file. -- -- Invariant: All paths are absolute. data FindError -- | The file was not found. It should have had one of the given file -- names. NotFound :: [AbsolutePath] -> FindError -- | Several matching files were found. -- -- Invariant: The list of matching files has at least two elements. Ambiguous :: [AbsolutePath] -> FindError -- | Given the module name which the error applies to this function -- converts a FindError to a TypeError. findErrorToTypeError :: TopLevelModuleName -> FindError -> TypeError -- | Finds the source file corresponding to a given top-level module name. -- The returned paths are absolute. -- -- Raises an error if the file cannot be found. findFile :: TopLevelModuleName -> TCM AbsolutePath -- | Tries to find the source file corresponding to a given top-level -- module name. The returned paths are absolute. -- -- SIDE EFFECT: Updates stModuleToSource. findFile' :: TopLevelModuleName -> TCM (Either FindError AbsolutePath) -- | A variant of findFile' which does not require TCM. findFile'' :: [AbsolutePath] -> TopLevelModuleName -> ModuleToSource -> IO (Either FindError AbsolutePath, ModuleToSource) -- | Finds the interface file corresponding to a given top-level module -- name. The returned paths are absolute. -- -- Raises an error if the source file cannot be found, and returns -- Nothing if the source file can be found but not the interface -- file. findInterfaceFile :: TopLevelModuleName -> TCM (Maybe AbsolutePath) -- | Ensures that the module name matches the file name. The file -- corresponding to the module name (according to the include path) has -- to be the same as the given file name. checkModuleName :: TopLevelModuleName -> AbsolutePath -> TCM () -- | Computes the module name of the top-level module in the given file. -- -- Warning! Parses the whole file to get the module name out. Use wisely! moduleName' :: AbsolutePath -> TCM TopLevelModuleName -- | A variant of moduleName' which raises an error if the file name -- does not match the module name. -- -- The file name is interpreted relative to the current working directory -- (unless it is absolute). moduleName :: AbsolutePath -> TCM TopLevelModuleName tests :: IO Bool module Agda.TypeChecking.Serialise.Instances.Common instance Agda.TypeChecking.Serialise.Base.EmbPrj GHC.Base.String instance Agda.TypeChecking.Serialise.Base.EmbPrj Data.ByteString.Lazy.Internal.ByteString instance Agda.TypeChecking.Serialise.Base.EmbPrj GHC.Integer.Type.Integer instance Agda.TypeChecking.Serialise.Base.EmbPrj GHC.Word.Word64 instance Agda.TypeChecking.Serialise.Base.EmbPrj GHC.Int.Int32 instance Agda.TypeChecking.Serialise.Base.EmbPrj GHC.Types.Int instance Agda.TypeChecking.Serialise.Base.EmbPrj GHC.Types.Char instance Agda.TypeChecking.Serialise.Base.EmbPrj GHC.Types.Double instance Agda.TypeChecking.Serialise.Base.EmbPrj Data.Void.Void instance Agda.TypeChecking.Serialise.Base.EmbPrj () instance (Agda.TypeChecking.Serialise.Base.EmbPrj a, Agda.TypeChecking.Serialise.Base.EmbPrj b) => Agda.TypeChecking.Serialise.Base.EmbPrj (a, b) instance (Agda.TypeChecking.Serialise.Base.EmbPrj a, Agda.TypeChecking.Serialise.Base.EmbPrj b, Agda.TypeChecking.Serialise.Base.EmbPrj c) => Agda.TypeChecking.Serialise.Base.EmbPrj (a, b, c) instance (Agda.TypeChecking.Serialise.Base.EmbPrj a, Agda.TypeChecking.Serialise.Base.EmbPrj b) => Agda.TypeChecking.Serialise.Base.EmbPrj (Data.Either.Either a b) instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (GHC.Base.Maybe a) instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Data.Strict.Maybe.Maybe a) instance Agda.TypeChecking.Serialise.Base.EmbPrj GHC.Types.Bool instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Utils.FileName.AbsolutePath instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Position.Position' a) instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Concrete.Name.TopLevelModuleName instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj [a] instance (GHC.Classes.Ord a, GHC.Classes.Ord b, Agda.TypeChecking.Serialise.Base.EmbPrj a, Agda.TypeChecking.Serialise.Base.EmbPrj b) => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Utils.BiMap.BiMap a b) instance (GHC.Classes.Ord a, Agda.TypeChecking.Serialise.Base.EmbPrj a, Agda.TypeChecking.Serialise.Base.EmbPrj b) => Agda.TypeChecking.Serialise.Base.EmbPrj (Data.Map.Base.Map a b) instance (GHC.Classes.Ord a, Agda.TypeChecking.Serialise.Base.EmbPrj a) => Agda.TypeChecking.Serialise.Base.EmbPrj (Data.Set.Base.Set a) instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Data.Sequence.Seq a) instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Position.Interval' a) instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Position.Range instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Serialise.Instances.Common.SerialisedRange instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Concrete.Name.Name instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Concrete.Name.NamePart instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Concrete.Name.QName instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Fixity.Associativity instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Fixity.PrecedenceLevel instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Fixity.Fixity instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Fixity.Fixity' instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Notation.GenPart instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Common.MetaId instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Abstract.Name.QName instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Abstract.Name.AmbiguousQName instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Abstract.Name.ModuleName instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Abstract.Name.Name instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Concrete.FieldAssignment' a) instance (Agda.TypeChecking.Serialise.Base.EmbPrj s, Agda.TypeChecking.Serialise.Base.EmbPrj t) => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Common.Named s t) instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Common.Ranged a) instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Common.ArgInfo instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Common.NameId instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k, Agda.TypeChecking.Serialise.Base.EmbPrj k, Agda.TypeChecking.Serialise.Base.EmbPrj v) => Agda.TypeChecking.Serialise.Base.EmbPrj (Data.HashMap.Base.HashMap k v) instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Common.WithHiding a) instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Common.Arg a) instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Common.Dom a) instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Common.Induction instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Common.Hiding instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Common.Relevance instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Common.ConPOrigin instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Literal.Literal instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Common.IsAbstract instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Common.Delayed module Agda.TypeChecking.Serialise.Instances.Highlighting instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Interaction.Highlighting.Range.Range instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Interaction.Highlighting.Precise.NameKind instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Interaction.Highlighting.Precise.Aspect instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Interaction.Highlighting.Precise.OtherAspect instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Interaction.Highlighting.Precise.Aspects instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Interaction.Highlighting.Precise.CompressedFile -- | Lenses for TCState and more. module Agda.TypeChecking.Monad.State -- | Resets the non-persistent part of the type checking state. resetState :: TCM () -- | Resets all of the type checking state. -- -- Keep only Benchmark information. resetAllState :: TCM () -- | Restore TCState after performing subcomputation. -- -- In contrast to localState, the Benchmark info from the -- subcomputation is saved. localTCState :: TCM a -> TCM a -- | Same as localTCState but also returns the state in which we -- were just before reverting it. localTCStateSaving :: TCM a -> TCM (a, TCState) lensPersistentState :: Lens' PersistentTCState TCState updatePersistentState :: (PersistentTCState -> PersistentTCState) -> (TCState -> TCState) modifyPersistentState :: (PersistentTCState -> PersistentTCState) -> TCM () -- | Lens for stAccumStatistics. lensAccumStatisticsP :: Lens' Statistics PersistentTCState lensAccumStatistics :: Lens' Statistics TCState -- | Get the current scope. getScope :: TCM ScopeInfo -- | Set the current scope. setScope :: ScopeInfo -> TCM () -- | Modify the current scope without updating the inverse maps. modifyScope_ :: (ScopeInfo -> ScopeInfo) -> TCM () -- | Modify the current scope. modifyScope :: (ScopeInfo -> ScopeInfo) -> TCM () -- | Run a computation in a local scope. withScope :: ScopeInfo -> TCM a -> TCM (a, ScopeInfo) -- | Same as withScope, but discard the scope from the computation. withScope_ :: ScopeInfo -> TCM a -> TCM a -- | Discard any changes to the scope by a computation. localScope :: TCM a -> TCM a -- | Scope error. notInScope :: QName -> TCM a -- | Debug print the scope. printScope :: String -> Int -> String -> TCM () modifySignature :: (Signature -> Signature) -> TCM () modifyImportedSignature :: (Signature -> Signature) -> TCM () getSignature :: TCM Signature getImportedSignature :: TCM Signature -- | Update a possibly imported definition. Warning: changes made to -- imported definitions (during type checking) will not persist outside -- the current module. This function is currently used to update the -- compiled representation of a function during compilation. modifyGlobalDefinition :: QName -> (Definition -> Definition) -> TCM () setSignature :: Signature -> TCM () setImportedSignature :: Signature -> TCM () -- | Run some computation in a different signature, restore original -- signature. withSignature :: Signature -> TCM a -> TCM a addRewriteRulesFor :: QName -> RewriteRules -> Signature -> Signature lookupDefinition :: QName -> Signature -> Maybe Definition updateDefinitions :: (Definitions -> Definitions) -> Signature -> Signature updateDefinition :: QName -> (Definition -> Definition) -> Signature -> Signature updateTheDef :: (Defn -> Defn) -> (Definition -> Definition) updateDefType :: (Type -> Type) -> (Definition -> Definition) updateDefArgOccurrences :: ([Occurrence] -> [Occurrence]) -> (Definition -> Definition) updateDefPolarity :: ([Polarity] -> [Polarity]) -> (Definition -> Definition) updateDefCompiledRep :: (CompiledRepresentation -> CompiledRepresentation) -> (Definition -> Definition) updateFunClauses :: ([Clause] -> [Clause]) -> (Defn -> Defn) -- | Set the top-level module. This affects the global module id of freshly -- generated names. setTopLevelModule :: QName -> TCM () -- | Use a different top-level module for a computation. Used when -- generating names for imported modules. withTopLevelModule :: QName -> TCM a -> TCM a -- | Tell the compiler to import the given Haskell module. addHaskellImport :: String -> TCM () -- | Get the Haskell imports. getHaskellImports :: TCM (Set String) -- | Tell the compiler to import the given Haskell module. addHaskellImportUHC :: String -> TCM () -- | Get the Haskell imports. getHaskellImportsUHC :: TCM (Set String) addInlineHaskell :: String -> TCM () getInteractionOutputCallback :: TCM InteractionOutputCallback appInteractionOutputCallback :: Response -> TCM () setInteractionOutputCallback :: InteractionOutputCallback -> TCM () getPatternSyns :: TCM PatternSynDefns setPatternSyns :: PatternSynDefns -> TCM () -- | Lens for stPatternSyns. modifyPatternSyns :: (PatternSynDefns -> PatternSynDefns) -> TCM () getPatternSynImports :: TCM PatternSynDefns lookupPatternSyn :: QName -> TCM PatternSynDefn -- | Lens getter for Benchmark from TCState. theBenchmark :: TCState -> Benchmark -- | Lens map for Benchmark. updateBenchmark :: (Benchmark -> Benchmark) -> TCState -> TCState -- | Lens getter for Benchmark from TCM. getBenchmark :: TCM Benchmark -- | Lens modify for Benchmark. modifyBenchmark :: (Benchmark -> Benchmark) -> TCM () -- | Run a fresh instance of the TCM (with initial state). Benchmark -- info is preserved. freshTCM :: TCM a -> TCM (Either TCErr a) -- | Look through the signature and reconstruct the instance table. addSignatureInstances :: Signature -> TCM () -- | Lens for stInstanceDefs. updateInstanceDefs :: (TempInstanceTable -> TempInstanceTable) -> (TCState -> TCState) modifyInstanceDefs :: (TempInstanceTable -> TempInstanceTable) -> TCM () getAllInstanceDefs :: TCM TempInstanceTable getAnonInstanceDefs :: TCM [QName] -- | Remove all instances whose type is still unresolved. clearAnonInstanceDefs :: TCM () -- | Add an instance whose type is still unresolved. addUnknownInstance :: QName -> TCM () -- | Add instance to some `class'. addNamedInstance :: QName -> QName -> TCM () -- | Lenses for CommandLineOptions and PragmaOptions. -- -- Add as needed. -- -- Nothing smart happening here. module Agda.Interaction.Options.Lenses class LensPragmaOptions a where setPragmaOptions = mapPragmaOptions . const mapPragmaOptions f a = setPragmaOptions (f $ getPragmaOptions a) a getPragmaOptions :: LensPragmaOptions a => a -> PragmaOptions setPragmaOptions :: LensPragmaOptions a => PragmaOptions -> a -> a mapPragmaOptions :: LensPragmaOptions a => (PragmaOptions -> PragmaOptions) -> a -> a modifyPragmaOptions :: (PragmaOptions -> PragmaOptions) -> TCM () class LensVerbosity a where setVerbosity = mapVerbosity . const mapVerbosity f a = setVerbosity (f $ getVerbosity a) a getVerbosity :: LensVerbosity a => a -> Verbosity setVerbosity :: LensVerbosity a => Verbosity -> a -> a mapVerbosity :: LensVerbosity a => (Verbosity -> Verbosity) -> a -> a modifyVerbosity :: (Verbosity -> Verbosity) -> TCM () putVerbosity :: Verbosity -> TCM () class LensCommandLineOptions a where setCommandLineOptions = mapCommandLineOptions . const mapCommandLineOptions f a = setCommandLineOptions (f $ getCommandLineOptions a) a getCommandLineOptions :: LensCommandLineOptions a => a -> CommandLineOptions setCommandLineOptions :: LensCommandLineOptions a => CommandLineOptions -> a -> a mapCommandLineOptions :: LensCommandLineOptions a => (CommandLineOptions -> CommandLineOptions) -> a -> a modifyCommandLineOptions :: (CommandLineOptions -> CommandLineOptions) -> TCM () type SafeMode = Bool class LensSafeMode a where setSafeMode = mapSafeMode . const mapSafeMode f a = setSafeMode (f $ getSafeMode a) a getSafeMode :: LensSafeMode a => a -> SafeMode setSafeMode :: LensSafeMode a => SafeMode -> a -> a mapSafeMode :: LensSafeMode a => (SafeMode -> SafeMode) -> a -> a modifySafeMode :: (SafeMode -> SafeMode) -> TCM () putSafeMode :: SafeMode -> TCM () class LensIncludePaths a where setIncludePaths = mapIncludePaths . const mapIncludePaths f a = setIncludePaths (f $ getIncludePaths a) a setAbsoluteIncludePaths = mapAbsoluteIncludePaths . const mapAbsoluteIncludePaths f a = setAbsoluteIncludePaths (f $ getAbsoluteIncludePaths a) a getIncludePaths :: LensIncludePaths a => a -> [FilePath] setIncludePaths :: LensIncludePaths a => [FilePath] -> a -> a mapIncludePaths :: LensIncludePaths a => ([FilePath] -> [FilePath]) -> a -> a getAbsoluteIncludePaths :: LensIncludePaths a => a -> [AbsolutePath] setAbsoluteIncludePaths :: LensIncludePaths a => [AbsolutePath] -> a -> a mapAbsoluteIncludePaths :: LensIncludePaths a => ([AbsolutePath] -> [AbsolutePath]) -> a -> a modifyIncludePaths :: ([FilePath] -> [FilePath]) -> TCM () putIncludePaths :: [FilePath] -> TCM () modifyAbsoluteIncludePaths :: ([AbsolutePath] -> [AbsolutePath]) -> TCM () putAbsoluteIncludePaths :: [AbsolutePath] -> TCM () type PersistentVerbosity = Verbosity class LensPersistentVerbosity a where setPersistentVerbosity = mapPersistentVerbosity . const mapPersistentVerbosity f a = setPersistentVerbosity (f $ getPersistentVerbosity a) a getPersistentVerbosity :: LensPersistentVerbosity a => a -> PersistentVerbosity setPersistentVerbosity :: LensPersistentVerbosity a => PersistentVerbosity -> a -> a mapPersistentVerbosity :: LensPersistentVerbosity a => (PersistentVerbosity -> PersistentVerbosity) -> a -> a modifyPersistentVerbosity :: (PersistentVerbosity -> PersistentVerbosity) -> TCM () putPersistentVerbosity :: PersistentVerbosity -> TCM () instance Agda.Interaction.Options.Lenses.LensPragmaOptions Agda.Interaction.Options.CommandLineOptions instance Agda.Interaction.Options.Lenses.LensPragmaOptions Agda.TypeChecking.Monad.Base.TCState instance Agda.Interaction.Options.Lenses.LensVerbosity Agda.Interaction.Options.PragmaOptions instance Agda.Interaction.Options.Lenses.LensVerbosity Agda.TypeChecking.Monad.Base.TCState instance Agda.Interaction.Options.Lenses.LensCommandLineOptions Agda.TypeChecking.Monad.Base.PersistentTCState instance Agda.Interaction.Options.Lenses.LensCommandLineOptions Agda.TypeChecking.Monad.Base.TCState instance Agda.Interaction.Options.Lenses.LensSafeMode Agda.Interaction.Options.CommandLineOptions instance Agda.Interaction.Options.Lenses.LensSafeMode Agda.TypeChecking.Monad.Base.PersistentTCState instance Agda.Interaction.Options.Lenses.LensSafeMode Agda.TypeChecking.Monad.Base.TCState instance Agda.Interaction.Options.Lenses.LensIncludePaths Agda.Interaction.Options.CommandLineOptions instance Agda.Interaction.Options.Lenses.LensIncludePaths Agda.TypeChecking.Monad.Base.PersistentTCState instance Agda.Interaction.Options.Lenses.LensIncludePaths Agda.TypeChecking.Monad.Base.TCState instance Agda.Interaction.Options.Lenses.LensPersistentVerbosity Agda.Interaction.Options.PragmaOptions instance Agda.Interaction.Options.Lenses.LensPersistentVerbosity Agda.Interaction.Options.CommandLineOptions instance Agda.Interaction.Options.Lenses.LensPersistentVerbosity Agda.TypeChecking.Monad.Base.PersistentTCState instance Agda.Interaction.Options.Lenses.LensPersistentVerbosity Agda.TypeChecking.Monad.Base.TCState module Agda.TypeChecking.Monad.Closure enterClosure :: Closure a -> (a -> TCM b) -> TCM b module Agda.TypeChecking.Monad.Mutual noMutualBlock :: TCM a -> TCM a inMutualBlock :: TCM a -> TCM a -- | Set the mutual block for a definition setMutualBlock :: MutualId -> QName -> TCM () -- | Get all mutual blocks getMutualBlocks :: TCM [Set QName] -- | Get the current mutual block, if any, otherwise a fresh mutual block -- is returned. currentOrFreshMutualBlock :: TCM MutualId lookupMutualBlock :: MutualId -> TCM (Set QName) mutualBlockOf :: QName -> TCM MutualId findMutualBlock :: QName -> TCM (Set QName) module Agda.TypeChecking.Monad.Options -- | Sets the pragma options. setPragmaOptions :: PragmaOptions -> TCM () -- | Sets the command line options (both persistent and pragma options are -- updated). -- -- Relative include directories are made absolute with respect to the -- current working directory. If the include directories have changed -- (thus, they are Left now, and were previously Right -- something), then the state is reset (completely, see -- setIncludeDirs) . -- -- An empty list of relative include directories (Left -- []) is interpreted as ["."]. setCommandLineOptions :: CommandLineOptions -> TCM () setCommandLineOptions' :: RelativeTo -> CommandLineOptions -> TCM () libToTCM :: LibM a -> TCM a setLibraryPaths :: RelativeTo -> CommandLineOptions -> TCM CommandLineOptions setLibraryIncludes :: CommandLineOptions -> TCM CommandLineOptions addDefaultLibraries :: RelativeTo -> CommandLineOptions -> TCM CommandLineOptions class (Functor m, Applicative m, Monad m) => HasOptions m -- | Returns the pragma options which are currently in effect. pragmaOptions :: HasOptions m => m PragmaOptions -- | Returns the command line options which are currently in effect. commandLineOptions :: HasOptions m => m CommandLineOptions setOptionsFromPragma :: OptionsPragma -> TCM () -- | Disable display forms. enableDisplayForms :: TCM a -> TCM a -- | Disable display forms. disableDisplayForms :: TCM a -> TCM a -- | Check if display forms are enabled. displayFormsEnabled :: TCM Bool -- | Don't eta contract implicit dontEtaContractImplicit :: TCM a -> TCM a -- | Do eta contract implicit doEtaContractImplicit :: MonadTCM tcm => tcm a -> tcm a shouldEtaContractImplicit :: MonadReader TCEnv m => m Bool -- | Don't reify interaction points dontReifyInteractionPoints :: TCM a -> TCM a shouldReifyInteractionPoints :: TCM Bool -- | Gets the include directories. -- -- Precondition: optAbsoluteIncludePaths must be nonempty (i.e. -- setCommandLineOptions must have run). getIncludeDirs :: TCM [AbsolutePath] -- | Which directory should form the base of relative include paths? data RelativeTo -- | The root directory of the "project" containing the given file. The -- file needs to be syntactically correct, with a module name matching -- the file name. ProjectRoot :: AbsolutePath -> RelativeTo -- | The current working directory. CurrentDir :: RelativeTo getProjectRoot :: RelativeTo -> TCM AbsolutePath -- | Makes the given directories absolute and stores them as include -- directories. -- -- If the include directories change, then the state is reset -- (completely, except for the include directories and -- stInteractionOutputCallback). -- -- An empty list is interpreted as ["."]. setIncludeDirs :: [FilePath] -> RelativeTo -> TCM () setInputFile :: FilePath -> TCM () -- | Should only be run if hasInputFile. getInputFile :: TCM AbsolutePath -- | Return the optInputFile as AbsolutePath, if any. getInputFile' :: TCM (Maybe AbsolutePath) hasInputFile :: TCM Bool proofIrrelevance :: TCM Bool hasUniversePolymorphism :: HasOptions m => m Bool sharedFun :: HasOptions m => m (Term -> Term) shared :: HasOptions m => Term -> m Term sharedType :: HasOptions m => Type -> m Type enableCaching :: TCM Bool showImplicitArguments :: TCM Bool showIrrelevantArguments :: TCM Bool -- | Switch on printing of implicit and irrelevant arguments. E.g. for -- reification in with-function generation. withShowAllArguments :: TCM a -> TCM a ignoreInterfaces :: TCM Bool positivityCheckEnabled :: TCM Bool typeInType :: HasOptions m => m Bool etaEnabled :: TCM Bool -- | Retrieve the current verbosity level. getVerbosity :: HasOptions m => m (Trie String Int) type VerboseKey = String -- | Check whether a certain verbosity level is activated. -- -- Precondition: The level must be non-negative. hasVerbosity :: HasOptions m => VerboseKey -> Int -> m Bool -- | Displays a debug message in a suitable way. displayDebugMessage :: MonadTCM tcm => Int -> String -> tcm () -- | Run a computation if a certain verbosity level is activated. -- -- Precondition: The level must be non-negative. verboseS :: MonadTCM tcm => VerboseKey -> Int -> tcm () -> tcm () -- | Conditionally print debug string. reportS :: MonadTCM tcm => VerboseKey -> Int -> String -> tcm () -- | Conditionally println debug string. reportSLn :: MonadTCM tcm => VerboseKey -> Int -> String -> tcm () -- | Conditionally render debug Doc and print it. reportSDoc :: MonadTCM tcm => VerboseKey -> Int -> TCM Doc -> tcm () -- | Print brackets around debug messages issued by a computation. verboseBracket :: MonadTCM tcm => VerboseKey -> Int -> String -> TCM a -> tcm a instance Control.Monad.IO.Class.MonadIO m => Agda.TypeChecking.Monad.Options.HasOptions (Agda.TypeChecking.Monad.Base.TCMT m) -- | The scope monad with operations. module Agda.Syntax.Scope.Monad -- | To simplify interaction between scope checking and type checking (in -- particular when chasing imports), we use the same monad. type ScopeM = TCM isDatatypeModule :: ModuleName -> ScopeM Bool getCurrentModule :: ScopeM ModuleName setCurrentModule :: ModuleName -> ScopeM () withCurrentModule :: ModuleName -> ScopeM a -> ScopeM a withCurrentModule' :: (MonadTrans t, Monad (t ScopeM)) => ModuleName -> t ScopeM a -> t ScopeM a getNamedScope :: ModuleName -> ScopeM Scope getCurrentScope :: ScopeM Scope -- | Create a new module with an empty scope (Bool is True if it is a -- datatype module) createModule :: Bool -> ModuleName -> ScopeM () -- | Apply a function to the scope map. modifyScopes :: (Map ModuleName Scope -> Map ModuleName Scope) -> ScopeM () -- | Apply a function to the given scope. modifyNamedScope :: ModuleName -> (Scope -> Scope) -> ScopeM () setNamedScope :: ModuleName -> Scope -> ScopeM () -- | Apply a monadic function to the top scope. modifyNamedScopeM :: ModuleName -> (Scope -> ScopeM (a, Scope)) -> ScopeM a -- | Apply a function to the current scope. modifyCurrentScope :: (Scope -> Scope) -> ScopeM () modifyCurrentScopeM :: (Scope -> ScopeM (a, Scope)) -> ScopeM a -- | Apply a function to the public or private name space. modifyCurrentNameSpace :: NameSpaceId -> (NameSpace -> NameSpace) -> ScopeM () setContextPrecedence :: Precedence -> ScopeM () getContextPrecedence :: ScopeM Precedence withContextPrecedence :: Precedence -> ScopeM a -> ScopeM a getLocalVars :: ScopeM LocalVars modifyLocalVars :: (LocalVars -> LocalVars) -> ScopeM () setLocalVars :: LocalVars -> ScopeM () -- | Run a computation without changing the local variables. withLocalVars :: ScopeM a -> ScopeM a -- | Create a fresh abstract name from a concrete name. -- -- This function is used when we translate a concrete name in a binder. -- The Range of the concrete name is saved as the -- nameBindingSite of the abstract name. freshAbstractName :: Fixity' -> Name -> ScopeM Name -- |
-- freshAbstractName_ = freshAbstractName noFixity' --freshAbstractName_ :: Name -> ScopeM Name -- | Create a fresh abstract qualified name. freshAbstractQName :: Fixity' -> Name -> ScopeM QName data ResolvedName VarName :: Name -> ResolvedName DefinedName :: Access -> AbstractName -> ResolvedName -- | record fields names need to be distinguished to parse copatterns FieldName :: AbstractName -> ResolvedName ConstructorName :: [AbstractName] -> ResolvedName PatternSynResName :: AbstractName -> ResolvedName UnknownName :: ResolvedName -- | Look up the abstract name referred to by a given concrete name. resolveName :: QName -> ScopeM ResolvedName -- | Look up the abstract name corresponding to a concrete name of a -- certain kind and/or from a given set of names. Sometimes we know -- already that we are dealing with a constructor or pattern synonym -- (e.g. when we have parsed a pattern). Then, we can ignore conflicting -- definitions of that name of a different kind. (See issue 822.) resolveName' :: [KindOfName] -> Maybe (Set Name) -> QName -> ScopeM ResolvedName -- | Look up a module in the scope. resolveModule :: QName -> ScopeM AbstractModule -- | Get the notation of a name. The name is assumed to be in scope. getNotation :: QName -> Set Name -> ScopeM NewNotation -- | Bind a variable. The abstract name is supplied as the second argument. bindVariable :: Name -> Name -> ScopeM () -- | Bind a defined name. Must not shadow anything. bindName :: Access -> KindOfName -> Name -> QName -> ScopeM () -- | Rebind a name. Use with care! Ulf, 2014-06-29: Currently used to -- rebind the name defined by an unquoteDecl, which is a -- QuotableName in the body, but a DefinedName later on. rebindName :: Access -> KindOfName -> Name -> QName -> ScopeM () -- | Bind a module name. bindModule :: Access -> Name -> ModuleName -> ScopeM () -- | Bind a qualified module name. Adds it to the imports field of the -- scope. bindQModule :: Access -> QName -> ModuleName -> ScopeM () -- | Clear the scope of any no names. stripNoNames :: ScopeM () type Out = (Ren ModuleName, Ren QName) type WSM = StateT Out ScopeM -- | Create a new scope with the given name from an old scope. Renames -- public names in the old scope to match the new name and returns the -- renamings. copyScope :: QName -> ModuleName -> Scope -> ScopeM (Scope, (Ren ModuleName, Ren QName)) -- | Apply an import directive and check that all the names mentioned -- actually exist. applyImportDirectiveM :: QName -> ImportDirective -> Scope -> ScopeM (ImportDirective, Scope) -- | A finite map for ImportedNames. lookupImportedName :: (Eq a, Eq b) => ImportedName' a b -> [ImportedName' (a, c) (b, d)] -> ImportedName' c d -- | Translation of ImportDirective. mapImportDir :: (Eq a, Eq b) => [ImportedName' (a, c) (b, d)] -> [ImportedName' (a, c) (b, d)] -> ImportDirective' a b -> ImportDirective' c d -- | Translation of Using or Hiding. mapUsing :: (Eq a, Eq b) => [ImportedName' (a, c) (b, d)] -> Using' a b -> Using' c d -- | Translation of Renaming. mapRenaming :: (Eq a, Eq b) => [ImportedName' (a, c) (b, d)] -> [ImportedName' (a, c) (b, d)] -> Renaming' a b -> Renaming' c d -- | Open a module. openModule_ :: QName -> ImportDirective -> ScopeM ImportDirective instance GHC.Classes.Eq Agda.Syntax.Scope.Monad.ResolvedName instance GHC.Show.Show Agda.Syntax.Scope.Monad.ResolvedName module Agda.Syntax.Abstract.Copatterns translateCopatternClauses :: [Clause] -> ScopeM (Delayed, [Clause]) instance GHC.Classes.Ord Agda.Syntax.Abstract.Copatterns.ProjEntry instance GHC.Classes.Eq Agda.Syntax.Abstract.Copatterns.ProjEntry instance GHC.Base.Functor (Agda.Syntax.Abstract.Copatterns.Path a) instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.Copatterns.ProjEntry instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.Name.QName instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.Name.Name instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.Expr instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.Name.ModuleName instance Agda.Syntax.Abstract.Copatterns.Rename a => Agda.Syntax.Abstract.Copatterns.Rename (Agda.Syntax.Concrete.FieldAssignment' a) instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.LetBinding instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.LamBinding instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.TypedBindings instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.TypedBinding instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.Clause instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.RHS instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.LHS instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.LHSCore instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.Pattern instance Agda.Syntax.Abstract.Copatterns.Rename Agda.Syntax.Abstract.Declaration instance Agda.Syntax.Abstract.Copatterns.Rename a => Agda.Syntax.Abstract.Copatterns.Rename (Agda.Syntax.Common.Arg a) instance Agda.Syntax.Abstract.Copatterns.Rename a => Agda.Syntax.Abstract.Copatterns.Rename (Agda.Syntax.Common.Named n a) instance Agda.Syntax.Abstract.Copatterns.Rename a => Agda.Syntax.Abstract.Copatterns.Rename [a] instance (Agda.Syntax.Abstract.Copatterns.Rename a, Agda.Syntax.Abstract.Copatterns.Rename b) => Agda.Syntax.Abstract.Copatterns.Rename (Data.Either.Either a b) instance (Agda.Syntax.Abstract.Copatterns.Rename a, Agda.Syntax.Abstract.Copatterns.Rename b) => Agda.Syntax.Abstract.Copatterns.Rename (a, b) instance Agda.Syntax.Abstract.Copatterns.Alpha Agda.Syntax.Abstract.Name.Name instance Agda.Syntax.Abstract.Copatterns.Alpha (Agda.Syntax.Abstract.Pattern' e) instance Agda.Syntax.Abstract.Copatterns.Alpha (Agda.Syntax.Abstract.LHSCore' e) instance Agda.Syntax.Abstract.Copatterns.Alpha Agda.Syntax.Abstract.LHS instance Agda.Syntax.Abstract.Copatterns.Alpha a => Agda.Syntax.Abstract.Copatterns.Alpha (Agda.Syntax.Common.Arg a) instance (GHC.Classes.Eq n, Agda.Syntax.Abstract.Copatterns.Alpha a) => Agda.Syntax.Abstract.Copatterns.Alpha (Agda.Syntax.Common.Named n a) instance Agda.Syntax.Abstract.Copatterns.Alpha a => Agda.Syntax.Abstract.Copatterns.Alpha [a] -- | The parser doesn't know about operators and parses everything as -- normal function application. This module contains the functions that -- parses the operators properly. For a stand-alone implementation of -- this see src/prototyping/mixfix/old. -- -- It also contains the function that puts parenthesis back given the -- precedence of the context. module Agda.Syntax.Concrete.Operators -- | Parse a list of expressions into an application. parseApplication :: [Expr] -> ScopeM Expr -- | Parse an expression into a module application (an identifier plus a -- list of arguments). parseModuleApplication :: Expr -> ScopeM (QName, [NamedArg Expr]) -- | Parses a left-hand side, and makes sure that it defined the expected -- name. parseLHS :: QName -> Pattern -> ScopeM LHSCore -- | Parses a pattern. parsePattern :: Pattern -> ScopeM Pattern parsePatternSyn :: Pattern -> ScopeM Pattern instance GHC.Show.Show Agda.Syntax.Concrete.Operators.ExprKind instance GHC.Classes.Eq Agda.Syntax.Concrete.Operators.ExprKind module Agda.TypeChecking.Monad.Context -- | Modify the ctxEntry field of a ContextEntry. modifyContextEntry :: (Dom (Name, Type) -> Dom (Name, Type)) -> ContextEntry -> ContextEntry -- | Modify all ContextEntrys. modifyContextEntries :: (Dom (Name, Type) -> Dom (Name, Type)) -> Context -> Context -- | Modify a Context in a computation. modifyContext :: MonadTCM tcm => (Context -> Context) -> tcm a -> tcm a mkContextEntry :: MonadTCM tcm => Dom (Name, Type) -> tcm ContextEntry -- | Change the context. inContext :: MonadTCM tcm => [Dom (Name, Type)] -> tcm a -> tcm a -- | Change to top (=empty) context. inTopContext :: MonadTCM tcm => tcm a -> tcm a -- | Delete the last n bindings from the context. escapeContext :: MonadTCM tcm => Int -> tcm a -> tcm a -- | addCtx x arg cont add a variable to the context. -- -- Chooses an unused Name. addCtx :: MonadTCM tcm => Name -> Dom Type -> tcm a -> tcm a -- | Various specializations of addCtx. class AddContext b addContext :: (AddContext b, MonadTCM tcm) => b -> tcm a -> tcm a -- | add a bunch of variables with the same type to the context addCtxs :: MonadTCM tcm => [Name] -> Dom Type -> tcm a -> tcm a -- | Turns the string into a name and adds it to the context. addCtxString :: MonadTCM tcm => String -> Dom Type -> tcm a -> tcm a -- | Turns the string into a name and adds it to the context, with dummy -- type. addCtxString_ :: MonadTCM tcm => String -> tcm a -> tcm a addCtxStrings_ :: MonadTCM tcm => [String] -> tcm a -> tcm a -- | Context entries without a type have this dummy type. dummyDom :: Dom Type -- | Go under an abstraction. underAbstraction :: (Subst t a, MonadTCM tcm) => Dom Type -> Abs a -> (a -> tcm b) -> tcm b -- | Go under an abstract without worrying about the type to add to the -- context. underAbstraction_ :: (Subst t a, MonadTCM tcm) => Abs a -> (a -> tcm b) -> tcm b -- | Add a telescope to the context. addCtxTel :: MonadTCM tcm => Telescope -> tcm a -> tcm a -- | Add a let bound variable addLetBinding :: MonadTCM tcm => ArgInfo -> Name -> Term -> Type -> tcm a -> tcm a -- | Get the current context. getContext :: MonadReader TCEnv m => m [Dom (Name, Type)] -- | Get the size of the current context. getContextSize :: (Applicative m, MonadReader TCEnv m) => m Nat -- | Generate [var (n - 1), ..., var 0] for all declarations in -- the context. getContextArgs :: (Applicative m, MonadReader TCEnv m) => m Args -- | Generate [var (n - 1), ..., var 0] for all declarations in -- the context. getContextTerms :: (Applicative m, MonadReader TCEnv m) => m [Term] -- | Get the current context as a Telescope. getContextTelescope :: (Applicative m, MonadReader TCEnv m) => m Telescope -- | Check if we are in a compatible context, i.e. an extension of the -- given context. getContextId :: MonadReader TCEnv m => m [CtxId] -- | Get the names of all declarations in the context. getContextNames :: (Applicative m, MonadReader TCEnv m) => m [Name] -- | get type of bound variable (i.e. deBruijn index) lookupBV :: MonadReader TCEnv m => Nat -> m (Dom (Name, Type)) typeOfBV' :: (Applicative m, MonadReader TCEnv m) => Nat -> m (Dom Type) typeOfBV :: (Applicative m, MonadReader TCEnv m) => Nat -> m Type nameOfBV :: (Applicative m, MonadReader TCEnv m) => Nat -> m Name -- | Get the term corresponding to a named variable. If it is a lambda -- bound variable the deBruijn index is returned and if it is a let bound -- variable its definition is returned. getVarInfo :: MonadReader TCEnv m => Name -> m (Term, Dom Type) instance Agda.TypeChecking.Monad.Context.AddContext a => Agda.TypeChecking.Monad.Context.AddContext [a] instance Agda.TypeChecking.Monad.Context.AddContext (Agda.Syntax.Abstract.Name.Name, Agda.Syntax.Common.Dom Agda.Syntax.Internal.Type) instance Agda.TypeChecking.Monad.Context.AddContext (Agda.Syntax.Common.Dom (Agda.Syntax.Abstract.Name.Name, Agda.Syntax.Internal.Type)) instance Agda.TypeChecking.Monad.Context.AddContext ([Agda.Syntax.Abstract.Name.Name], Agda.Syntax.Common.Dom Agda.Syntax.Internal.Type) instance Agda.TypeChecking.Monad.Context.AddContext ([Agda.Syntax.Common.WithHiding Agda.Syntax.Abstract.Name.Name], Agda.Syntax.Common.Dom Agda.Syntax.Internal.Type) instance Agda.TypeChecking.Monad.Context.AddContext (GHC.Base.String, Agda.Syntax.Common.Dom Agda.Syntax.Internal.Type) instance Agda.TypeChecking.Monad.Context.AddContext (Agda.Syntax.Common.Dom (GHC.Base.String, Agda.Syntax.Internal.Type)) instance Agda.TypeChecking.Monad.Context.AddContext (Agda.Syntax.Common.Dom Agda.Syntax.Internal.Type) instance Agda.TypeChecking.Monad.Context.AddContext Agda.Syntax.Abstract.Name.Name instance Agda.TypeChecking.Monad.Context.AddContext GHC.Base.String instance Agda.TypeChecking.Monad.Context.AddContext Agda.Syntax.Internal.Telescope -- | The translation of abstract syntax to concrete syntax has two -- purposes. First it allows us to pretty print abstract syntax values -- without having to write a dedicated pretty printer, and second it -- serves as a sanity check for the concrete to abstract translation: -- translating from concrete to abstract and then back again should be -- (more or less) the identity. module Agda.Syntax.Translation.AbstractToConcrete class ToConcrete a c | a -> c where toConcrete x = bindToConcrete x return bindToConcrete x ret = ret =<< toConcrete x toConcrete :: ToConcrete a c => a -> AbsToCon c bindToConcrete :: ToConcrete a c => a -> (c -> AbsToCon b) -> AbsToCon b -- | Translate something in a context of the given precedence. toConcreteCtx :: ToConcrete a c => Precedence -> a -> AbsToCon c abstractToConcrete_ :: ToConcrete a c => a -> TCM c abstractToConcreteEnv :: ToConcrete a c => Env -> a -> TCM c runAbsToCon :: AbsToCon c -> TCM c data RangeAndPragma RangeAndPragma :: Range -> Pragma -> RangeAndPragma abstractToConcreteCtx :: ToConcrete a c => Precedence -> a -> TCM c withScope :: ScopeInfo -> AbsToCon a -> AbsToCon a makeEnv :: ScopeInfo -> Env -- | We put the translation into TCM in order to print debug messages. type AbsToCon = ReaderT Env TCM data DontTouchMe a data Env noTakenNames :: AbsToCon a -> AbsToCon a instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a c => Agda.Syntax.Translation.AbstractToConcrete.ToConcrete [a] [c] instance (Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a1 c1, Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a2 c2) => Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (Data.Either.Either a1 a2) (Data.Either.Either c1 c2) instance (Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a1 c1, Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a2 c2) => Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (a1, a2) (c1, c2) instance (Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a1 c1, Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a2 c2, Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a3 c3) => Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (a1, a2, a3) (c1, c2, c3) instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a c => Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (Agda.Syntax.Common.Arg a) (Agda.Syntax.Common.Arg c) instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a c => Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (Agda.Syntax.Common.WithHiding a) (Agda.Syntax.Common.WithHiding c) instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a c => Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (Agda.Syntax.Common.Named name a) (Agda.Syntax.Common.Named name c) instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (Agda.Syntax.Translation.AbstractToConcrete.DontTouchMe a) a instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.Name.Name Agda.Syntax.Concrete.Name.Name instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.Name.QName Agda.Syntax.Concrete.Name.QName instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.Name.ModuleName Agda.Syntax.Concrete.Name.QName instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.Expr Agda.Syntax.Concrete.Expr instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a c => Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (Agda.Syntax.Concrete.FieldAssignment' a) (Agda.Syntax.Concrete.FieldAssignment' c) instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.LamBinding [Agda.Syntax.Concrete.LamBinding] instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.TypedBindings [Agda.Syntax.Concrete.TypedBindings] instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.TypedBinding Agda.Syntax.Concrete.TypedBinding instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.LetBinding [Agda.Syntax.Concrete.Declaration] instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Translation.AbstractToConcrete.AsWhereDecls Agda.Syntax.Concrete.WhereClause instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.RHS (Agda.Syntax.Concrete.RHS, [Agda.Syntax.Concrete.Expr], [Agda.Syntax.Concrete.Expr], [Agda.Syntax.Concrete.Declaration]) instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (GHC.Base.Maybe Agda.Syntax.Abstract.Name.QName) (GHC.Base.Maybe Agda.Syntax.Concrete.Name.Name) instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (Agda.Syntax.Common.Constr Agda.Syntax.Abstract.Constructor) Agda.Syntax.Concrete.Declaration instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a Agda.Syntax.Concrete.LHS => Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (Agda.Syntax.Abstract.Clause' a) [Agda.Syntax.Concrete.Declaration] instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.ModuleApplication Agda.Syntax.Concrete.ModuleApplication instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.Declaration [Agda.Syntax.Concrete.Declaration] instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Translation.AbstractToConcrete.RangeAndPragma Agda.Syntax.Concrete.Pragma instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.SpineLHS Agda.Syntax.Concrete.LHS instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.LHS Agda.Syntax.Concrete.LHS instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.LHSCore Agda.Syntax.Concrete.Pattern instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Abstract.Pattern Agda.Syntax.Concrete.Pattern instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Common.InteractionId Agda.Syntax.Concrete.Expr instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.TypeChecking.Monad.Base.NamedMeta Agda.Syntax.Concrete.Expr module Agda.TypeChecking.Monad.Caching -- | Writes a TypeCheckAction to the current log, using the current -- PostScopeState writeToCurrentLog :: TypeCheckAction -> TCM () -- | Reads the next entry in the cached type check log, if present. readFromCachedLog :: TCM (Maybe (TypeCheckAction, PostScopeState)) -- | Empties the "to read" CachedState. To be used when it gets invalid. cleanCachedLog :: TCM () -- | Caches the current type check log. Discardes the old cache. Does -- nothing if caching is inactive. cacheCurrentLog :: TCM () -- | Makes sure that the stLoadedFileCache is Just, with a -- clean current log. Crashes is stLoadedFileCache is already -- active with a dirty log. Should be called when we start typechecking -- the current file. activateLoadedFileCache :: TCM () -- | To be called before any write or restore calls. cachingStarts :: TCM () restorePostScopeState :: PostScopeState -> TCM () module Agda.TypeChecking.Monad.Constraints -- | Get the current problem currentProblem :: TCM ProblemId -- | Steal all constraints belonging to the given problem and add them to -- the current problem. stealConstraints :: ProblemId -> TCM () solvingProblem :: ProblemId -> TCM a -> TCM a solvingProblems :: [ProblemId] -> TCM a -> TCM a isProblemSolved :: ProblemId -> TCM Bool getConstraintsForProblem :: ProblemId -> TCM Constraints -- | Get the awake constraints getAwakeConstraints :: TCM Constraints wakeConstraints :: (ProblemConstraint -> TCM Bool) -> TCM () partitionM :: (a -> TCM Bool) -> [a] -> TCM ([a], [a]) dropConstraints :: (ProblemConstraint -> Bool) -> TCM () putAllConstraintsToSleep :: TCM () data ConstraintStatus AwakeConstraint :: ConstraintStatus SleepingConstraint :: ConstraintStatus -- | Suspend constraints matching the predicate during the execution of the -- second argument. Caution: held sleeping constraints will not be woken -- up by events that would normally trigger a wakeup call. holdConstraints :: (ConstraintStatus -> ProblemConstraint -> Bool) -> TCM a -> TCM a takeAwakeConstraint :: TCM (Maybe ProblemConstraint) getAllConstraints :: TCM Constraints withConstraint :: (Constraint -> TCM a) -> ProblemConstraint -> TCM a buildProblemConstraint :: ProblemId -> Constraint -> TCM ProblemConstraint buildConstraint :: Constraint -> TCM ProblemConstraint -- | Add new a constraint addConstraint' :: Constraint -> TCM () -- | Add already awake constraints addAwakeConstraints :: Constraints -> TCM () -- | Start solving constraints nowSolvingConstraints :: TCM a -> TCM a isSolvingConstraints :: TCM Bool mapAwakeConstraints :: (Constraints -> Constraints) -> TCState -> TCState mapSleepingConstraints :: (Constraints -> Constraints) -> TCState -> TCState modifyAwakeConstraints :: (Constraints -> Constraints) -> TCM () modifySleepingConstraints :: (Constraints -> Constraints) -> TCM () instance GHC.Show.Show Agda.TypeChecking.Monad.Constraints.ConstraintStatus instance GHC.Classes.Eq Agda.TypeChecking.Monad.Constraints.ConstraintStatus module Agda.TypeChecking.Monad.Sharing updateSharedTerm :: MonadReader TCEnv m => (Term -> m Term) -> Term -> m Term updateSharedTermF :: (MonadReader TCEnv m, Traversable f) => (Term -> m (f Term)) -> Term -> m (f Term) updateSharedTermT :: (MonadTCM tcm, MonadTrans t, Monad (t tcm)) => (Term -> t tcm Term) -> Term -> t tcm Term forceEqualTerms :: Term -> Term -> TCM () -- | Collect statistics. module Agda.TypeChecking.Monad.Statistics -- | Increase specified counter by 1. tick :: String -> TCM () -- | Increase specified counter by n. tickN :: String -> Integer -> TCM () -- | Set the specified counter to the maximum of its current value and -- n. tickMax :: String -> Integer -> TCM () -- | Get the statistics. getStatistics :: TCM Statistics -- | Modify the statistics via given function. modifyStatistics :: (Statistics -> Statistics) -> TCM () -- | Print the given statistics if verbosity "profile" is given. printStatistics :: Int -> Maybe TopLevelModuleName -> Statistics -> TCM () module Agda.TypeChecking.Monad.Trace interestingCall :: Closure Call -> Bool traceCallM :: MonadTCM tcm => tcm Call -> tcm a -> tcm a -- | Record a function call in the trace. traceCall :: MonadTCM tcm => Call -> tcm a -> tcm a traceCallCPS :: MonadTCM tcm => Call -> (r -> tcm a) -> ((r -> tcm a) -> tcm b) -> tcm b traceCallCPS_ :: MonadTCM tcm => Call -> tcm a -> (tcm a -> tcm b) -> tcm b getCurrentRange :: TCM Range -- | Sets the current range (for error messages etc.) to the range of the -- given object, if it has a range (i.e., its range is not -- noRange). setCurrentRange :: HasRange x => x -> TCM a -> TCM a module Agda.TypeChecking.Monad.MetaVars -- | Switch off assignment of metas. dontAssignMetas :: TCM a -> TCM a -- | Get the meta store. getMetaStore :: TCM MetaStore modifyMetaStore :: (MetaStore -> MetaStore) -> TCM () -- | Lookup a meta variable lookupMeta :: MetaId -> TCM MetaVariable updateMetaVar :: MetaId -> (MetaVariable -> MetaVariable) -> TCM () getMetaPriority :: MetaId -> TCM MetaPriority isSortMeta :: MetaId -> TCM Bool isSortMeta_ :: MetaVariable -> Bool getMetaType :: MetaId -> TCM Type -- | Given a meta, return the type applied to the current context. getMetaTypeInContext :: MetaId -> TCM Type -- | Check whether all metas are instantiated. Precondition: argument is a -- meta (in some form) or a list of metas. class IsInstantiatedMeta a isInstantiatedMeta :: IsInstantiatedMeta a => a -> TCM Bool -- | Does not worry about raising. isInstantiatedMeta' :: MetaId -> TCM (Maybe Term) -- | Create MetaInfo in the current environment. createMetaInfo :: TCM MetaInfo createMetaInfo' :: RunMetaOccursCheck -> TCM MetaInfo setValueMetaName :: Term -> MetaNameSuggestion -> TCM () getMetaNameSuggestion :: MetaId -> TCM MetaNameSuggestion setMetaNameSuggestion :: MetaId -> MetaNameSuggestion -> TCM () updateMetaVarRange :: MetaId -> Range -> TCM () modifyInteractionPoints :: (InteractionPoints -> InteractionPoints) -> TCM () -- | Register an interaction point during scope checking. If there is no -- interaction id yet, create one. registerInteractionPoint :: Range -> Maybe Nat -> TCM InteractionId -- | Hook up meta variable to interaction point. connectInteractionPoint :: InteractionId -> MetaId -> TCM () -- | Move an interaction point from the current ones to the old ones. removeInteractionPoint :: InteractionId -> TCM () -- | Get a list of interaction ids. getInteractionPoints :: TCM [InteractionId] -- | Get all metas that correspond to interaction ids. getInteractionMetas :: TCM [MetaId] -- | Get all metas that correspond to interaction ids. getInteractionIdsAndMetas :: TCM [(InteractionId, MetaId)] -- | Does the meta variable correspond to an interaction point? -- -- Time: O(n) where n is the number of interaction -- metas. isInteractionMeta :: MetaId -> TCM (Maybe InteractionId) -- | Get the information associated to an interaction point. lookupInteractionPoint :: InteractionId -> TCM InteractionPoint -- | Get MetaId for an interaction point. Precondition: interaction -- point is connected. lookupInteractionId :: InteractionId -> TCM MetaId -- | Generate new meta variable. newMeta :: MetaInfo -> MetaPriority -> Permutation -> Judgement a -> TCM MetaId -- | Generate a new meta variable with some instantiation given. For -- instance, the instantiation could be a -- PostponedTypeCheckingProblem. newMeta' :: MetaInstantiation -> MetaInfo -> MetaPriority -> Permutation -> Judgement a -> TCM MetaId -- | Get the Range for an interaction point. getInteractionRange :: InteractionId -> TCM Range -- | Get the Range for a meta variable. getMetaRange :: MetaId -> TCM Range getInteractionScope :: InteractionId -> TCM ScopeInfo withMetaInfo' :: MetaVariable -> TCM a -> TCM a withMetaInfo :: Closure Range -> TCM a -> TCM a getInstantiatedMetas :: TCM [MetaId] getOpenMetas :: TCM [MetaId] -- | listenToMeta l m: register l as a listener to -- m. This is done when the type of l is blocked by m. listenToMeta :: Listener -> MetaId -> TCM () -- | Unregister a listener. unlistenToMeta :: Listener -> MetaId -> TCM () -- | Get the listeners to a meta. getMetaListeners :: MetaId -> TCM [Listener] clearMetaListeners :: MetaId -> TCM () -- | Freeze all so far unfrozen metas for the duration of the given -- computation. withFreezeMetas :: TCM a -> TCM a -- | Freeze all meta variables and return the list of metas that got -- frozen. freezeMetas :: TCM [MetaId] -- | Thaw all meta variables. unfreezeMetas :: TCM () -- | Thaw some metas, as indicated by the passed condition. unfreezeMetas' :: (MetaId -> Bool) -> TCM () isFrozen :: MetaId -> TCM Bool -- | Unfreeze meta and its type if this is a meta again. Does not unfreeze -- deep occurrences of metas. class UnFreezeMeta a unfreezeMeta :: UnFreezeMeta a => a -> TCM () instance Agda.TypeChecking.Monad.MetaVars.IsInstantiatedMeta Agda.Syntax.Common.MetaId instance Agda.TypeChecking.Monad.MetaVars.IsInstantiatedMeta Agda.Syntax.Internal.Term instance Agda.TypeChecking.Monad.MetaVars.IsInstantiatedMeta Agda.Syntax.Internal.Level instance Agda.TypeChecking.Monad.MetaVars.IsInstantiatedMeta Agda.Syntax.Internal.PlusLevel instance Agda.TypeChecking.Monad.MetaVars.IsInstantiatedMeta Agda.Syntax.Internal.LevelAtom instance Agda.TypeChecking.Monad.MetaVars.IsInstantiatedMeta a => Agda.TypeChecking.Monad.MetaVars.IsInstantiatedMeta [a] instance Agda.TypeChecking.Monad.MetaVars.IsInstantiatedMeta a => Agda.TypeChecking.Monad.MetaVars.IsInstantiatedMeta (GHC.Base.Maybe a) instance Agda.TypeChecking.Monad.MetaVars.IsInstantiatedMeta a => Agda.TypeChecking.Monad.MetaVars.IsInstantiatedMeta (Agda.Syntax.Common.Arg a) instance Agda.TypeChecking.Monad.MetaVars.IsInstantiatedMeta a => Agda.TypeChecking.Monad.MetaVars.IsInstantiatedMeta (Agda.Syntax.Internal.Abs a) instance Agda.TypeChecking.Monad.MetaVars.UnFreezeMeta Agda.Syntax.Common.MetaId instance Agda.TypeChecking.Monad.MetaVars.UnFreezeMeta Agda.Syntax.Internal.Type instance Agda.TypeChecking.Monad.MetaVars.UnFreezeMeta Agda.Syntax.Internal.Term instance Agda.TypeChecking.Monad.MetaVars.UnFreezeMeta Agda.Syntax.Internal.Sort instance Agda.TypeChecking.Monad.MetaVars.UnFreezeMeta Agda.Syntax.Internal.Level instance Agda.TypeChecking.Monad.MetaVars.UnFreezeMeta Agda.Syntax.Internal.PlusLevel instance Agda.TypeChecking.Monad.MetaVars.UnFreezeMeta Agda.Syntax.Internal.LevelAtom instance Agda.TypeChecking.Monad.MetaVars.UnFreezeMeta a => Agda.TypeChecking.Monad.MetaVars.UnFreezeMeta [a] instance Agda.TypeChecking.Monad.MetaVars.UnFreezeMeta a => Agda.TypeChecking.Monad.MetaVars.UnFreezeMeta (Agda.Syntax.Internal.Abs a) module Agda.TypeChecking.Monad.Signature -- | Add a constant to the signature. Lifts the definition to top level. addConstant :: QName -> Definition -> TCM () -- | Set termination info of a defined function symbol. setTerminates :: QName -> Bool -> TCM () -- | Modify the clauses of a function. modifyFunClauses :: QName -> ([Clause] -> [Clause]) -> TCM () -- | Lifts clauses to the top-level and adds them to definition. addClauses :: QName -> [Clause] -> TCM () ensureNoCompiledHaskell :: QName -> TCM () addHaskellCode :: QName -> HaskellType -> HaskellCode -> TCM () addHaskellExport :: QName -> HaskellType -> String -> TCM () addHaskellType :: QName -> HaskellType -> TCM () addEpicCode :: QName -> EpicCode -> TCM () addJSCode :: QName -> String -> TCM () addCoreCode :: QName -> CoreExpr -> TCM () addCoreConstr :: QName -> CoreConstr -> TCM () addCoreType :: QName -> CoreType -> TCM () markNoSmashing :: QName -> TCM () markStatic :: QName -> TCM () markInline :: QName -> TCM () unionSignatures :: [Signature] -> Signature -- | Add a section to the signature. -- -- The current context will be stored as the cumulative module parameters -- for this section. addSection :: ModuleName -> TCM () -- | Lookup a section. If it doesn't exist that just means that the module -- wasn't parameterised. lookupSection :: (Functor m, ReadTCState m) => ModuleName -> m Telescope addDisplayForms :: QName -> TCM () -- | Module application (followed by module parameter abstraction). applySection :: ModuleName -> Telescope -> ModuleName -> Args -> Ren QName -> Ren ModuleName -> TCM () applySection' :: ModuleName -> Telescope -> ModuleName -> Args -> Ren QName -> Ren ModuleName -> TCM () -- | Add a display form to a definition (could be in this or imported -- signature). addDisplayForm :: QName -> DisplayForm -> TCM () getDisplayForms :: QName -> TCM [Open DisplayForm] -- | Find all names used (recursively) by display forms of a given name. chaseDisplayForms :: QName -> TCM (Set QName) -- | Check if a display form is looping. hasLoopingDisplayForm :: QName -> TCM Bool canonicalName :: QName -> TCM QName sameDef :: QName -> QName -> TCM (Maybe QName) -- | Can be called on either a (co)datatype, a record type or a -- (co)constructor. whatInduction :: QName -> TCM Induction -- | Does the given constructor come from a single-constructor type? -- -- Precondition: The name has to refer to a constructor. singleConstructorType :: QName -> TCM Bool class (Functor m, Applicative m, Monad m) => HasConstInfo m -- | Lookup the definition of a name. The result is a closed thing, all -- free variables have been abstracted over. getConstInfo :: HasConstInfo m => QName -> m Definition -- | Lookup the rewrite rules with the given head symbol. getRewriteRulesFor :: HasConstInfo m => QName -> m RewriteRules defaultGetRewriteRulesFor :: (Monad m) => m TCState -> QName -> m RewriteRules getConInfo :: MonadTCM tcm => ConHead -> tcm Definition -- | Look up the polarity of a definition. getPolarity :: QName -> TCM [Polarity] -- | Look up polarity of a definition and compose with polarity represented -- by Comparison. getPolarity' :: Comparison -> QName -> TCM [Polarity] -- | Set the polarity of a definition. setPolarity :: QName -> [Polarity] -> TCM () -- | Get argument occurrence info for argument i of definition -- d (never fails). getArgOccurrence :: QName -> Nat -> TCM Occurrence setArgOccurrences :: QName -> [Occurrence] -> TCM () modifyArgOccurrences :: QName -> ([Occurrence] -> [Occurrence]) -> TCM () setTreeless :: QName -> TTerm -> TCM () setCompiledArgUse :: QName -> [Bool] -> TCM () getCompiled :: QName -> TCM (Maybe Compiled) getTreeless :: QName -> TCM (Maybe TTerm) getCompiledArgUse :: QName -> TCM [Bool] -- | Get the mutually recursive identifiers. getMutual :: QName -> TCM [QName] -- | Set the mutually recursive identifiers. setMutual :: QName -> [QName] -> TCM () -- | Check whether two definitions are mutually recursive. mutuallyRecursive :: QName -> QName -> TCM Bool -- | Why Maybe? The reason is that we look up all prefixes of a module to -- compute number of parameters, and for hierarchical top-level modules, -- A.B.C say, A and A.B do not exist. getSection :: ModuleName -> TCM (Maybe Section) -- | Get the number of parameters to the current module. getCurrentModuleFreeVars :: TCM Nat -- | Compute the number of free variables of a defined name. This is the -- sum of number of parameters shared with the current module and the -- number of anonymous variables (if the name comes from a let-bound -- module). getDefFreeVars :: (Functor m, Applicative m, ReadTCState m, MonadReader TCEnv m) => QName -> m Nat -- | Compute the context variables to apply a definition to. -- -- We have to insert the module telescope of the common prefix of the -- current module and the module where the definition comes from. -- (Properly raised to the current context.) -- -- Example: module M₁ Γ where module M₁ Δ where f = ... module M₃ Θ -- where ... M₁.M₂.f [insert Γ raised by Θ] freeVarsToApply :: QName -> TCM Args -- | Unless all variables in the context are module parameters, create a -- fresh module to capture the non-module parameters. Used when unquoting -- to make sure generated definitions work properly. inFreshModuleIfFreeParams :: TCM a -> TCM a -- | Instantiate a closed definition with the correct part of the current -- context. instantiateDef :: Definition -> TCM Definition -- | Give the abstract view of a definition. makeAbstract :: Definition -> Maybe Definition -- | Enter abstract mode. Abstract definition in the current module are -- transparent. inAbstractMode :: TCM a -> TCM a -- | Not in abstract mode. All abstract definitions are opaque. inConcreteMode :: TCM a -> TCM a -- | Ignore abstract mode. All abstract definitions are transparent. ignoreAbstractMode :: MonadReader TCEnv m => m a -> m a -- | Enter concrete or abstract mode depending on whether the given -- identifier is concrete or abstract. inConcreteOrAbstractMode :: QName -> TCM a -> TCM a -- | Check whether a name might have to be treated abstractly (either if -- we're inAbstractMode or it's not a local name). Returns true -- for things not declared abstract as well, but for those -- makeAbstract will have no effect. treatAbstractly :: MonadReader TCEnv m => QName -> m Bool -- | Andreas, 2015-07-01: If the current module is a weak suffix -- of the identifier module, we can see through its abstract definition -- if we are abstract. (Then treatAbstractly' returns -- False). -- -- If I am not mistaken, then we cannot see definitions in the -- where block of an abstract function from the perspective of -- the function, because then the current module is a strict prefix of -- the module of the local identifier. This problem is fixed by removing -- trailing anonymous module name parts (underscores) from both names. treatAbstractly' :: QName -> TCEnv -> Bool -- | Get type of a constant, instantiated to the current context. typeOfConst :: QName -> TCM Type -- | Get relevance of a constant. relOfConst :: QName -> TCM Relevance -- | The name must be a datatype. sortOfConst :: QName -> TCM Sort -- | The number of parameters of a definition. defPars :: Definition -> Int -- | The number of dropped parameters for a definition. 0 except for -- projection(-like) functions and constructors. droppedPars :: Definition -> Int -- | Is it the name of a record projection? isProjection :: HasConstInfo m => QName -> m (Maybe Projection) isProjection_ :: Defn -> Maybe Projection -- | Is it a function marked STATIC? isStaticFun :: Defn -> Bool -- | Is it a function marked INLINE? isInlineFun :: Defn -> Bool -- | Returns True if we are dealing with a proper projection, -- i.e., not a projection-like function nor a record field value -- (projection applied to argument). isProperProjection :: Defn -> Bool -- | Number of dropped initial arguments of a projection(-like) function. projectionArgs :: Defn -> Int -- | Check whether a definition uses copatterns. usesCopatterns :: QName -> TCM Bool -- | Apply a function f to its first argument, producing the -- proper postfix projection if f is a projection. applyDef :: QName -> Arg Term -> TCM Term instance Agda.TypeChecking.Monad.Signature.HasConstInfo (Agda.TypeChecking.Monad.Base.TCMT GHC.Types.IO) instance (Agda.TypeChecking.Monad.Signature.HasConstInfo m, Agda.Utils.Except.Error err) => Agda.TypeChecking.Monad.Signature.HasConstInfo (Agda.TypeChecking.Monad.Exception.ExceptionT err m) -- | Stuff for sized types that does not require modules -- Agda.TypeChecking.Reduce or -- Agda.TypeChecking.Constraints (which import -- Agda.TypeChecking.Monad). module Agda.TypeChecking.Monad.SizedTypes -- | Result of querying whether size variable i is bounded by -- another size. data BoundedSize -- | yes i : Size< t BoundedLt :: Term -> BoundedSize BoundedNo :: BoundedSize -- | Check if a type is the primSize type. The argument should be -- reduced. class IsSizeType a isSizeType :: IsSizeType a => a -> TCM (Maybe BoundedSize) isSizeTypeTest :: TCM (Term -> Maybe BoundedSize) getBuiltinDefName :: String -> TCM (Maybe QName) getBuiltinSize :: TCM (Maybe QName, Maybe QName) isSizeNameTest :: TCM (QName -> Bool) isSizeNameTestRaw :: TCM (QName -> Bool) -- | Test whether OPTIONS --sized-types and whether the size built-ins are -- defined. haveSizedTypes :: TCM Bool -- | Add polarity info to a SIZE builtin. builtinSizeHook :: String -> QName -> Type -> TCM () -- | The sort of built-in types SIZE and SIZELT. sizeSort :: Sort -- | The type of built-in types SIZE and SIZELT. sizeUniv :: Type -- | The built-in type SIZE with user-given name. sizeType_ :: QName -> Type -- | The built-in type SIZE. sizeType :: TCM Type -- | The name of SIZESUC. sizeSucName :: TCM (Maybe QName) sizeSuc :: Nat -> Term -> TCM Term sizeSuc_ :: QName -> Term -> Term -- | Transform list of terms into a term build from binary maximum. sizeMax :: [Term] -> TCM Term -- | A useful view on sizes. data SizeView SizeInf :: SizeView SizeSuc :: Term -> SizeView OtherSize :: Term -> SizeView sizeView :: Term -> TCM SizeView type Offset = Nat -- | A deep view on sizes. data DeepSizeView DSizeInf :: DeepSizeView DSizeVar :: Nat -> Offset -> DeepSizeView DSizeMeta :: MetaId -> Elims -> Offset -> DeepSizeView DOtherSize :: Term -> DeepSizeView data SizeViewComparable a NotComparable :: SizeViewComparable a YesAbove :: DeepSizeView -> a -> SizeViewComparable a YesBelow :: DeepSizeView -> a -> SizeViewComparable a -- | sizeViewComparable v w checks whether v >= w -- (then Left) or v <= w (then Right). If -- uncomparable, it returns NotComparable. sizeViewComparable :: DeepSizeView -> DeepSizeView -> SizeViewComparable () sizeViewSuc_ :: QName -> DeepSizeView -> DeepSizeView -- | sizeViewPred k v decrements v by k (must be -- possible!). sizeViewPred :: Nat -> DeepSizeView -> DeepSizeView -- | sizeViewOffset v returns the number of successors or Nothing -- when infty. sizeViewOffset :: DeepSizeView -> Maybe Offset -- | Remove successors common to both sides. removeSucs :: (DeepSizeView, DeepSizeView) -> (DeepSizeView, DeepSizeView) -- | Turn a size view into a term. unSizeView :: SizeView -> TCM Term unDeepSizeView :: DeepSizeView -> TCM Term type SizeMaxView = [DeepSizeView] maxViewMax :: SizeMaxView -> SizeMaxView -> SizeMaxView -- | maxViewCons v ws = max v ws. It only adds v to -- ws if it is not subsumed by an element of ws. maxViewCons :: DeepSizeView -> SizeMaxView -> SizeMaxView -- | sizeViewComparableWithMax v ws tries to find w in -- ws that compares with v and singles this out. -- Precondition: v /= DSizeInv. sizeViewComparableWithMax :: DeepSizeView -> SizeMaxView -> SizeViewComparable SizeMaxView maxViewSuc_ :: QName -> SizeMaxView -> SizeMaxView unMaxView :: SizeMaxView -> TCM Term instance GHC.Base.Functor Agda.TypeChecking.Monad.SizedTypes.SizeViewComparable instance GHC.Show.Show Agda.TypeChecking.Monad.SizedTypes.DeepSizeView instance GHC.Show.Show Agda.TypeChecking.Monad.SizedTypes.BoundedSize instance GHC.Classes.Eq Agda.TypeChecking.Monad.SizedTypes.BoundedSize instance Agda.TypeChecking.Monad.SizedTypes.IsSizeType a => Agda.TypeChecking.Monad.SizedTypes.IsSizeType (Agda.Syntax.Internal.Type' a) instance Agda.TypeChecking.Monad.SizedTypes.IsSizeType Agda.Syntax.Internal.Term module Agda.TypeChecking.Monad -- | A command which calls a compiler module Agda.Compiler.CallCompiler -- | Calls a compiler: -- --
-- f (X x y) (Y z) = term ---- -- Initially, the variables have these indexes: -- --
-- f 0@(X x y) 1@(Y z) = term ---- -- The first case will be on 0, and the variables bound inside -- the X pattern will replace the outer index, so we get -- something like this: -- --
-- f 0 2@(Y z) = case 0 of X 0 1 -> term ---- -- Notice how (Y z) now has index 2. Then the second -- pattern is desugared in the same way: -- --
-- f 0 2 = case 0 of X 0 1 -> case 2 of Y 2 -> term ---- -- This replacement is what is done using the replaceAt function. -- -- CompiledClauses also have default branches for when all branches fail -- (even inner branches), the catchAllBranch. Epic does not support this, -- so we have to add the catchAllBranch to each inner case (here we are -- calling it omniDefault). To avoid code duplication it is first bound -- by a let expression. compileClauses :: QName -> Int -> CompiledClauses -> Compile TCM Fun -- | Translate the actual Agda terms, with an environment of all the bound -- variables from patternmatching. Agda terms are in de Bruijn so we just -- check the new names in the position. substTerm :: [Var] -> Term -> Compile TCM Expr -- | Translate Agda literals to our AUX definition substLit :: Literal -> Compile TCM Lit -- | Translating Agda types to Haskell types. Used to ensure that imported -- Haskell functions have the right type. module Agda.Compiler.HaskellTypes type HaskellKind = String hsStar :: HaskellKind hsKFun :: HaskellKind -> HaskellKind -> HaskellKind hsFun :: HaskellKind -> HaskellKind -> HaskellKind hsUnit :: HaskellType hsVar :: Name -> HaskellType hsApp :: String -> [HaskellType] -> HaskellType hsForall :: String -> HaskellType -> HaskellType notAHaskellType :: Type -> TCM a getHsType :: QName -> TCM HaskellType getHsVar :: Nat -> TCM HaskellCode -- | Note that Inf a b, where Inf is the INFINITY -- builtin, is translated to of b (assuming that all -- coinductive builtins are defined). -- -- Note that if haskellType supported universe polymorphism then -- the special treatment of INFINITY might not be needed. haskellType :: Type -> TCM HaskellType -- | Smash functions which return something that can be inferred (something -- of a type with only one element) module Agda.Compiler.UHC.Smashing module Agda.TypeChecking.CompiledClause.Match matchCompiled :: CompiledClauses -> MaybeReducedArgs -> ReduceM (Reduced (Blocked Args) Term) -- | matchCompiledE c es takes a function given by case tree -- c and and a spine es and tries to apply the function -- to es. matchCompiledE :: CompiledClauses -> MaybeReducedElims -> ReduceM (Reduced (Blocked Elims) Term) -- | A stack entry is a triple consisting of 1. the part of the case tree -- to continue matching, 2. the current argument vector, and 3. a patch -- function taking the current argument vector back to the original -- argument vector. type Frame = (CompiledClauses, MaybeReducedElims, Elims -> Elims) type Stack = [Frame] -- | match' tries to solve the matching problems on the -- Stack. In each iteration, the top problem is removed and -- handled. -- -- If the top problem was a Done, we succeed. -- -- If the top problem was a Case n and the nth argument -- of the problem is not a constructor or literal, we are stuck, thus, -- fail. -- -- If we have a branch for the constructor/literal, we put it on the -- stack to continue. If we do not have a branch, we fall through to the -- next problem, which should be the corresponding catch-all branch. -- -- An empty stack is an exception that can come only from an incomplete -- function definition. match' :: Stack -> ReduceM (Reduced (Blocked Elims) Term) module Agda.TypeChecking.Errors prettyError :: MonadTCM tcm => TCErr -> tcm String tcErrString :: TCErr -> String -- | Warnings. -- -- Invariant: The fields are never empty at the same time. data Warnings Warnings :: [Range] -> Constraints -> Warnings -- | Meta-variable problems are reported as type errors unless -- optAllowUnsolved is True. [unsolvedMetaVariables] :: Warnings -> [Range] -- | Same as unsolvedMetaVariables. [unsolvedConstraints] :: Warnings -> Constraints -- | Turns warnings into an error. Even if several errors are possible only -- one is raised. warningsToError :: Warnings -> TCM a instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.TCErr instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.CallInfo instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.TypeError instance Agda.TypeChecking.Errors.PrettyUnequal Agda.Syntax.Internal.Term instance Agda.TypeChecking.Errors.PrettyUnequal Agda.Syntax.Internal.Type instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.SplitError instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.Call instance Agda.TypeChecking.Errors.Verbalize Agda.Syntax.Common.Hiding instance Agda.TypeChecking.Errors.Verbalize Agda.Syntax.Common.Relevance instance Agda.TypeChecking.Errors.Verbalize a => Agda.TypeChecking.Errors.Verbalize (Agda.TypeChecking.Errors.Indefinite a) -- | Functions for inserting implicit arguments at the right places. module Agda.TypeChecking.Implicit -- | implicitArgs n expand eti t generates up to n -- implicit arguments metas (unbounded if n<0), as long as -- t is a function type and expand holds on the hiding -- info of its domain. If eti is ExplicitToInstance, -- then explicit arguments are considered as instance arguments. implicitArgs :: Int -> (Hiding -> Bool) -> Type -> TCM (Args, Type) -- | implicitNamedArgs n expand eti t generates up to n -- named implicit arguments metas (unbounded if n<0), as long -- as t is a function type and expand holds on the -- hiding and name info of its domain. If eti is -- ExplicitToInstance, then explicit arguments are considered as -- instance arguments. implicitNamedArgs :: Int -> (Hiding -> ArgName -> Bool) -> Type -> TCM (NamedArgs, Type) data ImplicitInsertion -- | this many implicits have to be inserted ImpInsert :: [Hiding] -> ImplicitInsertion -- | hidden argument where there should have been a non-hidden arg BadImplicits :: ImplicitInsertion -- | bad named argument NoSuchName :: ArgName -> ImplicitInsertion NoInsertNeeded :: ImplicitInsertion impInsert :: [Hiding] -> ImplicitInsertion -- | The list should be non-empty. insertImplicit :: NamedArg e -> [Arg ArgName] -> ImplicitInsertion instance GHC.Show.Show Agda.TypeChecking.Implicit.ImplicitInsertion -- | Pattern matcher used in the reducer for clauses that have not been -- compiled to case trees yet. module Agda.TypeChecking.Patterns.Match -- | If matching is inconclusive (DontKnow) we want to know -- whether it is due to a particular meta variable. data Match a Yes :: Simplification -> [a] -> Match a No :: Match a DontKnow :: (Blocked ()) -> Match a -- | Instead of zipWithM, we need to use this lazy version of -- combining pattern matching computations. foldMatch :: forall p v. (p -> v -> ReduceM (Match Term, v)) -> [p] -> [v] -> ReduceM (Match Term, [v]) -- | matchCopatterns ps es matches spine es against -- copattern spine ps. -- -- Returns Yes and a substitution for the pattern variables (in -- form of [Term]) if matching was successful. -- -- Returns No if there was a constructor or projection mismatch. -- -- Returns DontKnow if an argument could not be evaluated to -- constructor form because of a blocking meta variable. -- -- In any case, also returns spine es in reduced form (with all -- the weak head reductions performed that were necessary to come to a -- decision). matchCopatterns :: [NamedArg Pattern] -> [Elim] -> ReduceM (Match Term, [Elim]) -- | Match a single copattern. matchCopattern :: Pattern -> Elim -> ReduceM (Match Term, Elim) matchPatterns :: [NamedArg Pattern] -> [Arg Term] -> ReduceM (Match Term, [Arg Term]) -- | Match a single pattern. matchPattern :: Pattern -> Arg Term -> ReduceM (Match Term, Arg Term) yesSimplification :: (Match a, b) -> (Match a, b) instance GHC.Base.Functor Agda.TypeChecking.Patterns.Match.Match instance Agda.Utils.Null.Null (Agda.TypeChecking.Patterns.Match.Match a) -- | Non-linear matching of the lhs of a rewrite rule against a neutral -- term. -- -- Given a lhs -- -- Δ ⊢ lhs : B -- -- and a candidate term -- -- Γ ⊢ t : A -- -- we seek a substitution Γ ⊢ σ : Δ such that -- -- Γ ⊢ B[σ] = A and Γ ⊢ lhs[σ] = t : A module Agda.TypeChecking.Rewriting.NonLinMatch -- | Turn a term into a non-linear pattern, treating the free variables as -- pattern variables. The first argument is the number of bound variables -- (from pattern lambdas). class PatternFrom a b patternFrom :: PatternFrom a b => Int -> a -> TCM b -- | Monad for non-linear matching. type NLM = ExceptT Blocked_ (StateT NLMState ReduceM) type NLMState = (Sub, PostponedEquations) liftRed :: ReduceM a -> NLM a runNLM :: NLM () -> ReduceM (Either Blocked_ NLMState) traceSDocNLM :: VerboseKey -> Int -> TCM Doc -> NLM a -> NLM a matchingBlocked :: Blocked_ -> NLM () -- | Add substitution i |-> v to result of matching. tellSub :: Int -> Term -> NLM () tellEq :: Telescope -> Telescope -> Term -> Term -> NLM () type Sub = IntMap Term -- | Matching against a term produces a constraint which we have to verify -- after applying the substitution computed by matching. data PostponedEquation PostponedEquation :: Telescope -> Term -> Term -> PostponedEquation -- | Telescope of free variables in the equation [eqFreeVars] :: PostponedEquation -> Telescope -- | Term from pattern, living in pattern context. [eqLhs] :: PostponedEquation -> Term -- | Term from scrutinee, living in context where matching was invoked. [eqRhs] :: PostponedEquation -> Term type PostponedEquations = [PostponedEquation] -- | Match a non-linear pattern against a neutral term, returning a -- substitution. class Match a b match :: Match a b => Telescope -> Telescope -> a -> b -> NLM () makeSubstitution :: Telescope -> Sub -> Substitution checkPostponedEquations :: Substitution -> PostponedEquations -> ReduceM Bool nonLinMatch :: (Match a b) => Telescope -> a -> b -> ReduceM (Either Blocked_ Substitution) -- | Untyped βη-equality, does not handle things like empty record types. equal :: Term -> Term -> ReduceM Bool -- | Raise (bound) variables in a NLPat class RaiseNLP a where raiseNLP = raiseNLPFrom 0 raiseNLPFrom :: RaiseNLP a => Int -> Int -> a -> a raiseNLP :: RaiseNLP a => Int -> a -> a instance Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom a b => Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom [a] [b] instance Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom a b => Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom (Agda.Syntax.Common.Arg a) (Agda.Syntax.Common.Arg b) instance Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom a b => Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom (Agda.Syntax.Internal.Elim' a) (Agda.Syntax.Internal.Elim' b) instance Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom a b => Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom (Agda.Syntax.Common.Dom a) (Agda.Syntax.Common.Dom b) instance Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom a b => Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom (Agda.Syntax.Internal.Type' a) (Agda.Syntax.Internal.Type' b) instance Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.NLPat instance Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom a b => Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom (Agda.Syntax.Internal.Abs a) (Agda.Syntax.Internal.Abs b) instance Agda.TypeChecking.Monad.Options.HasOptions Agda.TypeChecking.Rewriting.NonLinMatch.NLM instance Agda.TypeChecking.Rewriting.NonLinMatch.Match a b => Agda.TypeChecking.Rewriting.NonLinMatch.Match [a] [b] instance Agda.TypeChecking.Rewriting.NonLinMatch.Match a b => Agda.TypeChecking.Rewriting.NonLinMatch.Match (Agda.Syntax.Common.Arg a) (Agda.Syntax.Common.Arg b) instance Agda.TypeChecking.Rewriting.NonLinMatch.Match a b => Agda.TypeChecking.Rewriting.NonLinMatch.Match (Agda.Syntax.Internal.Elim' a) (Agda.Syntax.Internal.Elim' b) instance Agda.TypeChecking.Rewriting.NonLinMatch.Match a b => Agda.TypeChecking.Rewriting.NonLinMatch.Match (Agda.Syntax.Common.Dom a) (Agda.Syntax.Common.Dom b) instance Agda.TypeChecking.Rewriting.NonLinMatch.Match a b => Agda.TypeChecking.Rewriting.NonLinMatch.Match (Agda.Syntax.Internal.Type' a) (Agda.Syntax.Internal.Type' b) instance (Agda.TypeChecking.Rewriting.NonLinMatch.Match a b, Agda.TypeChecking.Substitute.Subst t1 a, Agda.TypeChecking.Substitute.Subst t2 b) => Agda.TypeChecking.Rewriting.NonLinMatch.Match (Agda.Syntax.Internal.Abs a) (Agda.Syntax.Internal.Abs b) instance Agda.TypeChecking.Rewriting.NonLinMatch.Match Agda.TypeChecking.Monad.Base.NLPat Agda.Syntax.Internal.Term instance Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP a => Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP [a] instance Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP a => Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP (Agda.Syntax.Common.Arg a) instance Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP a => Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP (Agda.Syntax.Internal.Elim' a) instance Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP a => Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP (Agda.Syntax.Common.Dom a) instance Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP a => Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP (Agda.Syntax.Internal.Type' a) instance Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP a => Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP (Agda.Syntax.Internal.Abs a) instance Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP Agda.TypeChecking.Monad.Base.NLPat module Agda.TypeChecking.Rules.LHS.Problem type Substitution = [Maybe Term] type FlexibleVars = [FlexibleVar Nat] -- | When we encounter a flexible variable in the unifier, where did it -- come from? The alternatives are ordered such that we will assign the -- higher one first, i.e., first we try to assign a DotFlex, -- then... data FlexibleVarKind -- | From a record pattern (ConP). Saves the FlexibleVarKind -- of its subpatterns. RecordFlex :: [FlexibleVarKind] -> FlexibleVarKind -- | From a hidden formal argument or underscore (WildP). ImplicitFlex :: FlexibleVarKind -- | From a dot pattern (DotP). DotFlex :: FlexibleVarKind -- | Flexible variables are equipped with information where they come from, -- in order to make a choice which one to assign when two flexibles are -- unified. data FlexibleVar a FlexibleVar :: Hiding -> FlexibleVarKind -> a -> FlexibleVar a [flexHiding] :: FlexibleVar a -> Hiding [flexKind] :: FlexibleVar a -> FlexibleVarKind [flexVar] :: FlexibleVar a -> a defaultFlexibleVar :: a -> FlexibleVar a flexibleVarFromHiding :: Hiding -> a -> FlexibleVar a data FlexChoice ChooseLeft :: FlexChoice ChooseRight :: FlexChoice ChooseEither :: FlexChoice ExpandBoth :: FlexChoice class ChooseFlex a chooseFlex :: ChooseFlex a => a -> a -> FlexChoice -- | State of typechecking a LHS; input to split. [Ulf Norell's -- PhD, page. 35] -- -- In Problem ps p delta, ps are the user patterns of -- supposed type delta. p is the pattern resulting from -- the splitting. data Problem' p Problem :: [NamedArg Pattern] -> p -> Telescope -> ProblemRest -> Problem' p -- | User patterns. [problemInPat] :: Problem' p -> [NamedArg Pattern] -- | Patterns after splitting. [problemOutPat] :: Problem' p -> p -- | Type of in patterns. [problemTel] :: Problem' p -> Telescope -- | Patterns that cannot be typed yet. [problemRest] :: Problem' p -> ProblemRest -- | The de Bruijn indices in the pattern refer to positions in the list of -- abstract patterns in the problem, counted from the back. type Problem = Problem' [NamedArg DeBruijnPattern] type ProblemPart = Problem' () -- | User patterns that could not be given a type yet. -- -- Example: f : (b : Bool) -> if b then Nat else Nat -> Nat f -- true = zero f false zero = zero f false (suc n) = n In this -- sitation, for clause 2, we construct an initial problem -- problemInPat = [false] problemTel = (b : Bool) problemRest.restPats = -- [zero] problemRest.restType = if b then Nat else Nat -> Nat -- As we instantiate b to false, the restType -- reduces to Nat -> Nat and we can move pattern -- zero over to problemInPat. data ProblemRest ProblemRest :: [NamedArg Pattern] -> Arg Type -> ProblemRest -- | List of user patterns which could not yet be typed. [restPats] :: ProblemRest -> [NamedArg Pattern] -- | Type eliminated by restPats. Can be Irrelevant to -- indicate that we came by an irrelevant projection and, hence, the rhs -- must be type-checked in irrelevant mode. [restType] :: ProblemRest -> Arg Type data Focus Focus :: QName -> ConPOrigin -> [NamedArg Pattern] -> Range -> [NamedArg DeBruijnPattern] -> QName -> [Arg Term] -> [Arg Term] -> Type -> Focus [focusCon] :: Focus -> QName -- | Do we come from an implicit or record pattern? [focusPatOrigin] :: Focus -> ConPOrigin [focusConArgs] :: Focus -> [NamedArg Pattern] [focusRange] :: Focus -> Range [focusOutPat] :: Focus -> [NamedArg DeBruijnPattern] [focusDatatype] :: Focus -> QName [focusParams] :: Focus -> [Arg Term] [focusIndices] :: Focus -> [Arg Term] -- | Type of variable we are splitting, kept for record patterns. [focusType] :: Focus -> Type LitFocus :: Literal -> [NamedArg DeBruijnPattern] -> Type -> Focus -- | Result of splitProblem: Determines position for the next -- split. data SplitProblem -- | Split on constructor pattern. Split :: ProblemPart -> [Name] -> Arg Focus -> Abs ProblemPart -> SplitProblem -- | The typed user patterns left of the split position. Invariant: -- problemRest == empty. [splitLPats] :: SplitProblem -> ProblemPart -- | The as-bindings for the focus. [splitAsNames] :: SplitProblem -> [Name] -- | How to split the variable at the split position. [splitFocus] :: SplitProblem -> Arg Focus -- | The typed user patterns right of the split position. [splitRPats] :: SplitProblem -> Abs ProblemPart -- | Split on projection pattern. SplitRest :: Arg QName -> Type -> SplitProblem -- | The projection could be belonging to an irrelevant record field. [splitProjection] :: SplitProblem -> Arg QName [splitRestType] :: SplitProblem -> Type -- | Put a typed pattern on the very left of a SplitProblem. consSplitProblem :: NamedArg Pattern -> ArgName -> Dom Type -> SplitProblem -> SplitProblem -- | Instantiations of a dot pattern with a term. `Maybe e` if the user -- wrote a dot pattern .e Nothing if this is an instantiation of -- an implicit argument or an underscore _ data DotPatternInst DPI :: Maybe Expr -> Term -> Dom Type -> DotPatternInst [dotPatternUserExpr] :: DotPatternInst -> Maybe Expr [dotPatternInst] :: DotPatternInst -> Term [dotPatternType] :: DotPatternInst -> Dom Type data AsBinding AsB :: Name -> Term -> Type -> AsBinding -- | State worked on during the main loop of checking a lhs. data LHSState LHSState :: Problem -> PatternSubstitution -> [DotPatternInst] -> [AsBinding] -> LHSState [lhsProblem] :: LHSState -> Problem [lhsSubst] :: LHSState -> PatternSubstitution [lhsDPI] :: LHSState -> [DotPatternInst] [lhsAsB] :: LHSState -> [AsBinding] instance GHC.Show.Show p => GHC.Show.Show (Agda.TypeChecking.Rules.LHS.Problem.Problem' p) instance GHC.Show.Show Agda.TypeChecking.Rules.LHS.Problem.ProblemRest instance GHC.Show.Show Agda.TypeChecking.Rules.LHS.Problem.FlexChoice instance GHC.Classes.Eq Agda.TypeChecking.Rules.LHS.Problem.FlexChoice instance Data.Traversable.Traversable Agda.TypeChecking.Rules.LHS.Problem.FlexibleVar instance Data.Foldable.Foldable Agda.TypeChecking.Rules.LHS.Problem.FlexibleVar instance GHC.Base.Functor Agda.TypeChecking.Rules.LHS.Problem.FlexibleVar instance GHC.Show.Show a => GHC.Show.Show (Agda.TypeChecking.Rules.LHS.Problem.FlexibleVar a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.TypeChecking.Rules.LHS.Problem.FlexibleVar a) instance GHC.Show.Show Agda.TypeChecking.Rules.LHS.Problem.FlexibleVarKind instance GHC.Classes.Eq Agda.TypeChecking.Rules.LHS.Problem.FlexibleVarKind instance Agda.Syntax.Common.LensHiding (Agda.TypeChecking.Rules.LHS.Problem.FlexibleVar a) instance GHC.Base.Monoid Agda.TypeChecking.Rules.LHS.Problem.FlexChoice instance Agda.TypeChecking.Rules.LHS.Problem.ChooseFlex Agda.TypeChecking.Rules.LHS.Problem.FlexibleVarKind instance Agda.TypeChecking.Rules.LHS.Problem.ChooseFlex a => Agda.TypeChecking.Rules.LHS.Problem.ChooseFlex [a] instance Agda.TypeChecking.Rules.LHS.Problem.ChooseFlex Agda.Syntax.Common.Hiding instance Agda.TypeChecking.Rules.LHS.Problem.ChooseFlex GHC.Types.Int instance Agda.TypeChecking.Rules.LHS.Problem.ChooseFlex a => Agda.TypeChecking.Rules.LHS.Problem.ChooseFlex (Agda.TypeChecking.Rules.LHS.Problem.FlexibleVar a) instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Rules.LHS.Problem.ProblemRest instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term (Agda.TypeChecking.Rules.LHS.Problem.Problem' p) instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Rules.LHS.Problem.DotPatternInst instance Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Rules.LHS.Problem.AsBinding instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Rules.LHS.Problem.DotPatternInst instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Rules.LHS.Problem.AsBinding instance Agda.Utils.Null.Null Agda.TypeChecking.Rules.LHS.Problem.ProblemRest instance Agda.Utils.Null.Null a => Agda.Utils.Null.Null (Agda.TypeChecking.Rules.LHS.Problem.Problem' a) -- | This module defines an inlining transformation on clauses that's run -- before termination checking. The purpose is to improve termination -- checking of with clauses (issue 59). The transformation inlines -- generated with-functions expanding the clauses of the parent function -- in such a way that termination checking the expanded clauses -- guarantees termination of the original function, while allowing more -- terminating functions to be accepted. It does in no way pretend to -- preserve the semantics of the original function. -- -- Roughly, the source program -- --
-- f ps with as -- {f ps₁i qsi = bi} ---- -- is represented internally as -- --
-- f ps = f-aux xs as where xs = vars(ps) -- {f-aux ps₂i qsi = bi} where ps₁i = ps[ps₂i/xs] ---- -- The inlining transformation turns this into -- --
-- {f ps = aj} for aj ∈ as -- {f ps₁i qsi = bi} ---- -- The first set of clauses, called withExprClauses, ensure that -- we don't forget any recursive calls in as. The second set of -- clauses, henceforth called inlinedClauses, are the -- surface-level clauses the user sees (and probably reasons about). -- -- The reason this works is that there is a single call site for each -- with-function. -- -- Note that the lhss of the inlined clauses are not type-correct, -- neither with the type of f (since there are additional -- patterns qsi) nor with the type of f-aux (since -- there are the surface-level patterns ps₁i instead of the -- actual patterns ps₂i). module Agda.Termination.Inlining inlineWithClauses :: QName -> Clause -> TCM [Clause] isWithFunction :: MonadTCM tcm => QName -> tcm (Maybe QName) expandWithFunctionCall :: QName -> Elims -> TCM Term module Agda.TypeChecking.Datatypes -- | Get true constructor with record fields. getConHead :: QName -> TCM ConHead -- | Get true constructor as term. getConTerm :: QName -> TCM Term -- | Get true constructor with fields, expanding literals to constructors -- if possible. getConForm :: QName -> TCM ConHead -- | Augment constructor with record fields (preserve constructor name). -- The true constructor might only surface via reduce. getOrigConHead :: QName -> TCM ConHead -- | Analogous to getConTerm. getOrigConTerm :: QName -> TCM Term -- | Get the name of the datatype constructed by a given constructor. -- Precondition: The argument must refer to a constructor getConstructorData :: HasConstInfo m => QName -> m QName -- | getConType c t computes the constructor parameters from type -- t and returns the instantiated type of constructor -- c. Nothing if t is not a data/record type -- or does not have a constructor c. Precondition: t is -- reduced. getConType :: ConHead -> Type -> TCM (Maybe Type) data HasEta NoEta :: HasEta YesEta :: HasEta data ConstructorInfo DataCon :: Nat -> ConstructorInfo RecordCon :: HasEta -> [Arg QName] -> ConstructorInfo -- | Return the number of non-parameter arguments to a data constructor, or -- the field names of a record constructor. -- -- For getting just the arity of constructor c, use either -- id size $ getConstructorArity c. getConstructorInfo :: QName -> TCM ConstructorInfo getConstructorArity :: QName -> TCM Nat -- | Check if a name refers to a datatype or a record with a named -- constructor. isDatatype :: QName -> TCM Bool data DataOrRecord IsData :: DataOrRecord IsRecord :: DataOrRecord -- | Check if a name refers to a datatype or a record. isDataOrRecordType :: QName -> TCM (Maybe DataOrRecord) -- | Precodition: Term is reduced. isDataOrRecord :: Term -> TCM (Maybe QName) getNumberOfParameters :: QName -> TCM (Maybe Nat) instance GHC.Show.Show Agda.TypeChecking.Datatypes.DataOrRecord instance GHC.Classes.Ord Agda.TypeChecking.Datatypes.DataOrRecord instance GHC.Classes.Eq Agda.TypeChecking.Datatypes.DataOrRecord instance GHC.Classes.Eq Agda.TypeChecking.Datatypes.HasEta module Agda.Compiler.Treeless.Erase eraseTerms :: QName -> TTerm -> TCM TTerm instance GHC.Show.Show Agda.Compiler.Treeless.Erase.TypeInfo instance GHC.Classes.Eq Agda.Compiler.Treeless.Erase.TypeInfo module Agda.TypeChecking.InstanceArguments -- | Compute a list of instance candidates. Nothing if type is a -- meta, error if type is not eligible for instance search. initialIFSCandidates :: Type -> TCM (Maybe [Candidate]) -- | findInScope m (v,a)s tries to instantiate on of the types -- as of the candidate terms vs to the type t -- of the metavariable m. If successful, meta m is -- solved with the instantiation of v. If unsuccessful, the -- constraint is regenerated, with possibly reduced candidate set. The -- list of candidates is equal to Nothing when the type of the -- meta wasn't known when the constraint was generated. In that case, try -- to find its type again. findInScope :: MetaId -> Maybe [Candidate] -> TCM () -- | Result says whether we need to add constraint, and if so, the set of -- remaining candidates and an eventual blocking metavariable. findInScope' :: MetaId -> [Candidate] -> TCM (Maybe ([Candidate], Maybe MetaId)) -- | Precondition: type is spine reduced and ends in a Def or a Var. insidePi :: Type -> (Type -> TCM a) -> TCM a -- | A meta _M is rigidly constrained if there is a constraint _M us == D -- vs, for inert D. Such metas can safely be instantiated by recursive -- instance search, since the constraint limits the solution space. rigidlyConstrainedMetas :: TCM [MetaId] isRigid :: MetaId -> TCM Bool -- | Returns True if one of the arguments of t is a meta which -- isn’t rigidly constrained. Note that level metas are never considered -- rigidly constrained (#1865). areThereNonRigidMetaArguments :: Term -> TCM (Maybe MetaId) -- | Apply the computation to every argument in turn by reseting the state -- every time. Return the list of the arguments giving the result True. -- -- If the resulting list contains exactly one element, then the state is -- the same as the one obtained after running the corresponding -- computation. In all the other cases, the state is reseted. filterResetingState :: MetaId -> [Candidate] -> (Candidate -> TCM YesNoMaybe) -> TCM [Candidate] dropSameCandidates :: MetaId -> [(Candidate, Term, Type, a)] -> TCM [(Candidate, Term, Type, a)] data YesNoMaybe Yes :: YesNoMaybe No :: YesNoMaybe Maybe :: YesNoMaybe -- | Given a meta m of type t and a list of candidates -- cands, checkCandidates m t cands returns a refined -- list of valid candidates. checkCandidates :: MetaId -> Type -> [Candidate] -> TCM (Maybe [Candidate]) isIFSConstraint :: Constraint -> Bool -- | To preserve the invariant that a constructor is not applied to its -- parameter arguments, we explicitly check whether function term we are -- applying to arguments is a unapplied constructor. In this case we drop -- the first conPars arguments. See Issue670a. Andreas, 2013-11-07 -- Also do this for projections, see Issue670b. applyDroppingParameters :: Term -> Args -> TCM Term instance GHC.Classes.Eq Agda.TypeChecking.InstanceArguments.YesNoMaybe instance GHC.Show.Show Agda.TypeChecking.InstanceArguments.YesNoMaybe module Agda.TypeChecking.Polarity -- | Infimum on the information lattice. Invariant is bottom -- (dominant for inf), Nonvariant is top (neutral for inf). (/\) :: Polarity -> Polarity -> Polarity -- | Polarity negation, swapping monotone and antitone. neg :: Polarity -> Polarity -- | What is the polarity of a function composition? composePol :: Polarity -> Polarity -> Polarity polFromOcc :: Occurrence -> Polarity -- | Get the next polarity from a list, Invariant if empty. nextPolarity :: [Polarity] -> (Polarity, [Polarity]) -- | Replace Nonvariant by Covariant. (Arbitrary bias, but -- better than Invariant, see issue 1596). purgeNonvariant :: [Polarity] -> [Polarity] -- | Main function of this module. computePolarity :: QName -> TCM () -- | Data and record parameters are used as phantom arguments all over the -- test suite (and possibly in user developments). -- enablePhantomTypes turns Nonvariant parameters to -- Covariant to enable phantoms. enablePhantomTypes :: Defn -> [Polarity] -> [Polarity] -- | Make arguments Invariant if the type of a not-Nonvariant -- later argument depends on it. Also, enable phantom types by turning -- Nonvariant into something else if it is a data/record parameter -- but not a size argument. [See issue 1596] -- -- Precondition: the "phantom" polarity list has the same length as the -- polarity list. dependentPolarity :: Type -> [Polarity] -> [Polarity] -> TCM [Polarity] -- | Check whether a variable is relevant in a type expression, ignoring -- domains of non-variant arguments. relevantInIgnoringNonvariant :: Nat -> Type -> [Polarity] -> TCM Bool -- | Record information that an argument is unused in Relevance. mkUnused :: Relevance -> Relevance -- | Improve Relevance information in a type by polarity -- information. Nonvariant becomes UnusedArg. nonvariantToUnusedArg :: [Polarity] -> Type -> TCM Type -- | Propagate Nonvariant Polarity to Relevance -- information in Args of a defined symbol. nonvariantToUnusedArgInDef :: [Polarity] -> Defn -> Defn nonvariantToUnusedArgInClause :: [Polarity] -> Clause -> Clause -- | Hack for polarity of size indices. As a side effect, this sets the -- positivity of the size index. See -- testsucceedPolaritySizeSucData.agda for a case where this is -- needed. sizePolarity :: QName -> [Polarity] -> TCM [Polarity] -- | checkSizeIndex d np i a checks that constructor target type -- a has form d ps (↑ i) idxs where |ps| = np. -- -- Precondition: a is reduced and of form d ps idxs0. checkSizeIndex :: QName -> Nat -> Nat -> Type -> TCM Bool -- | polarities i a computes the list of polarities of de Bruijn -- index i in syntactic entity a. class HasPolarity a polarities :: HasPolarity a => Nat -> a -> TCM [Polarity] -- | polarity i a computes the polarity of de Bruijn index -- i in syntactic entity a by taking the infimum of all -- polarities. polarity :: HasPolarity a => Nat -> a -> TCM Polarity instance Agda.TypeChecking.Polarity.HasPolarity a => Agda.TypeChecking.Polarity.HasPolarity (Agda.Syntax.Common.Arg a) instance Agda.TypeChecking.Polarity.HasPolarity a => Agda.TypeChecking.Polarity.HasPolarity (Agda.Syntax.Common.Dom a) instance Agda.TypeChecking.Polarity.HasPolarity a => Agda.TypeChecking.Polarity.HasPolarity (Agda.Syntax.Internal.Abs a) instance Agda.TypeChecking.Polarity.HasPolarity a => Agda.TypeChecking.Polarity.HasPolarity [a] instance (Agda.TypeChecking.Polarity.HasPolarity a, Agda.TypeChecking.Polarity.HasPolarity b) => Agda.TypeChecking.Polarity.HasPolarity (a, b) instance Agda.TypeChecking.Polarity.HasPolarity Agda.Syntax.Internal.Type instance Agda.TypeChecking.Polarity.HasPolarity a => Agda.TypeChecking.Polarity.HasPolarity (Agda.Syntax.Internal.Elim' a) instance Agda.TypeChecking.Polarity.HasPolarity Agda.Syntax.Internal.Term instance Agda.TypeChecking.Polarity.HasPolarity Agda.Syntax.Internal.Level instance Agda.TypeChecking.Polarity.HasPolarity Agda.Syntax.Internal.PlusLevel instance Agda.TypeChecking.Polarity.HasPolarity Agda.Syntax.Internal.LevelAtom module Agda.TypeChecking.Quote data QuotingKit QuotingKit :: (Term -> ReduceM Term) -> (Type -> ReduceM Term) -> (Clause -> ReduceM Term) -> (Dom Type -> ReduceM Term) -> (Definition -> ReduceM Term) -> (forall a. (a -> ReduceM Term) -> [a] -> ReduceM Term) -> QuotingKit [quoteTermWithKit] :: QuotingKit -> Term -> ReduceM Term [quoteTypeWithKit] :: QuotingKit -> Type -> ReduceM Term [quoteClauseWithKit] :: QuotingKit -> Clause -> ReduceM Term [quoteDomWithKit] :: QuotingKit -> Dom Type -> ReduceM Term [quoteDefnWithKit] :: QuotingKit -> Definition -> ReduceM Term [quoteListWithKit] :: QuotingKit -> forall a. (a -> ReduceM Term) -> [a] -> ReduceM Term quotingKit :: TCM QuotingKit quoteString :: String -> Term quoteName :: QName -> Term quoteNat :: Integer -> Term quoteConName :: ConHead -> Term quoteMeta :: AbsolutePath -> MetaId -> Term quoteTerm :: Term -> TCM Term quoteType :: Type -> TCM Term quoteDom :: Dom Type -> TCM Term quoteDefn :: Definition -> TCM Term quoteList :: [Term] -> TCM Term module Agda.TypeChecking.Records -- | Order the fields of a record construction. Use the second argument for -- missing fields. orderFields :: QName -> a -> [Name] -> [(Name, a)] -> TCM [a] -- | A record field assignment record{xs = es} might not mention -- all visible fields. insertMissingFields inserts placeholders -- for the missing visible fields and returns the values in order of the -- fields in the record declaration. insertMissingFields :: QName -> (Name -> a) -> [FieldAssignment' a] -> [Arg Name] -> TCM [NamedArg a] -- | The name of the module corresponding to a record. recordModule :: QName -> ModuleName -- | Get the definition for a record. Throws an exception if the name does -- not refer to a record or the record is abstract. getRecordDef :: QName -> TCM Defn -- | Get the record name belonging to a field name. getRecordOfField :: QName -> TCM (Maybe QName) -- | Get the field names of a record. getRecordFieldNames :: QName -> TCM [Arg Name] recordFieldNames :: Defn -> [Arg Name] -- | Find all records with at least the given fields. findPossibleRecords :: [Name] -> TCM [QName] -- | Get the field types of a record. getRecordFieldTypes :: QName -> TCM Telescope -- | Get the field names belonging to a record type. getRecordTypeFields :: Type -> TCM [Arg QName] -- | Get the original name of the projection (the current one could be from -- a module application). getOriginalProjection :: QName -> TCM QName -- | Get the type of the record constructor. getRecordConstructorType :: QName -> TCM Type -- | Returns the given record type's constructor name (with an empty -- range). getRecordConstructor :: QName -> TCM ConHead -- | Check if a name refers to a record. If yes, return record definition. isRecord :: HasConstInfo m => QName -> m (Maybe Defn) -- | Reduce a type and check whether it is a record type. Succeeds only if -- type is not blocked by a meta var. If yes, return its name, -- parameters, and definition. isRecordType :: Type -> TCM (Maybe (QName, Args, Defn)) -- | Reduce a type and check whether it is a record type. Succeeds only if -- type is not blocked by a meta var. If yes, return its name, -- parameters, and definition. If no, return the reduced type (unless it -- is blocked). tryRecordType :: Type -> TCM (Either (Maybe Type) (QName, Args, Defn)) -- | getDefType f t computes the type of (possibly -- projection-(like)) function f whose first argument has type -- t. The parameters for f are extracted from -- t. Nothing if f is projection(like) but -- t is not a datarecordaxiom type. -- -- Precondition: t is reduced. -- -- See also: getConType getDefType :: QName -> Type -> TCM (Maybe Type) -- | The analogue of piApply. If v is a value of record -- type t with field f, then projectTyped v t -- f returns the type of f v. -- -- Works also for projection-like definitions f. -- -- Precondition: t is reduced. projectTyped :: Term -> Type -> QName -> TCM (Maybe (Term, Type)) -- | Check if a name refers to an eta expandable record. isEtaRecord :: HasConstInfo m => QName -> m Bool isEtaCon :: HasConstInfo m => QName -> m Bool -- | Check if a name refers to a record which is not coinductive. -- (Projections are then size-preserving) isInductiveRecord :: QName -> TCM Bool -- | Check if a type is an eta expandable record and return the record -- identifier and the parameters. isEtaRecordType :: Type -> TCM (Maybe (QName, Args)) -- | Check if a name refers to a record constructor. If yes, return record -- definition. isRecordConstructor :: MonadTCM tcm => QName -> tcm (Maybe (QName, Defn)) -- | Check if a constructor name is the internally generated record -- constructor. isGeneratedRecordConstructor :: QName -> TCM Bool -- | Mark record type as unguarded. No eta-expansion. Projections do not -- preserve guardedness. unguardedRecord :: QName -> TCM () -- | Mark record type as recursive. Projections do not preserve -- guardedness. recursiveRecord :: QName -> TCM () -- | Check whether record type is marked as recursive. -- -- Precondition: record type identifier exists in signature. isRecursiveRecord :: QName -> TCM Bool -- | Version of recRecursive with proper internal error. recRecursive_ :: Defn -> Bool -- |
-- etaExpandBoundVar i = (Δ, σ, τ) ---- -- Precondition: The current context is Γ = Γ₁, x:R pars, Γ₂ -- where |Γ₂| = i and R is a eta-expandable record type -- with constructor c and fields Γ'. -- -- Postcondition: Δ = Γ₁, Γ', Γ₂[c Γ'] and Γ ⊢ σ : Δ -- and Δ ⊢ τ : Γ. etaExpandBoundVar :: Int -> TCM (Maybe (Telescope, Substitution, Substitution)) -- |
-- expandRecordVar i Γ = (Δ, σ, τ, Γ') ---- -- Precondition: Γ = Γ₁, x:R pars, Γ₂ where |Γ₂| = i -- and R is a eta-expandable record type with constructor -- c and fields Γ'. -- -- Postcondition: Δ = Γ₁, Γ', Γ₂[c Γ'] and Γ ⊢ σ : Δ -- and Δ ⊢ τ : Γ. expandRecordVar :: Int -> Telescope -> TCM (Maybe (Telescope, Substitution, Substitution, Telescope)) -- | Precondition: variable list is ordered descendingly. Can be empty. expandRecordVarsRecursively :: [Int] -> Telescope -> TCM (Telescope, Substitution, Substitution) -- |
-- curryAt v (Γ (y : R pars) -> B) n = -- ( v -> λ Γ ys → v Γ (c ys) {- curry -} -- , v -> λ Γ y → v Γ (p1 y) ... (pm y) {- uncurry -} -- , Γ (ys : As) → B[c ys / y] -- ) ---- -- where n = size Γ. curryAt :: Type -> Int -> TCM (Term -> Term, Term -> Term, Type) -- | etaExpand r pars u computes the eta expansion of record value -- u at record type r pars. -- -- The first argument r should be the name of a record type. -- Given -- --
-- record R : Set where field x : A; y : B; .z : C ---- -- and r : R, -- --
-- etaExpand R [] r = (tel, [R.x r, R.y r, R.z r]) ---- -- where tel is the record telescope instantiated at the -- parameters pars. etaExpandRecord :: QName -> Args -> Term -> TCM (Telescope, Args) etaExpandRecord_ :: QName -> Args -> Defn -> Term -> TCM (Telescope, ConHead, Args) etaExpandAtRecordType :: Type -> Term -> TCM (Telescope, Term) -- | The fields should be eta contracted already. -- -- We can eta contract if all fields f = ... are irrelevant or -- all fields f are the projection f v of the same -- value v, but we need at least one relevant field to find the -- value v. -- -- TODO: this can be moved out of TCM (but only if ConHead stores also -- the Arg-decoration of the record fields. etaContractRecord :: HasConstInfo m => QName -> ConHead -> Args -> m Term -- | Is the type a hereditarily singleton record type? May return a -- blocking metavariable. -- -- Precondition: The name should refer to a record type, and the -- arguments should be the parameters to the type. isSingletonRecord :: QName -> Args -> TCM (Either MetaId Bool) isSingletonRecordModuloRelevance :: QName -> Args -> TCM (Either MetaId Bool) -- | Return the unique (closed) inhabitant if exists. In case of counting -- irrelevance in, the returned inhabitant contains garbage. isSingletonRecord' :: Bool -> QName -> Args -> TCM (Either MetaId (Maybe Term)) -- | Check whether a type has a unique inhabitant and return it. Can be -- blocked by a metavar. isSingletonType :: Type -> TCM (Either MetaId (Maybe Term)) -- | Check whether a type has a unique inhabitant (irrelevant parts -- ignored). Can be blocked by a metavar. isSingletonTypeModuloRelevance :: (MonadTCM tcm) => Type -> tcm (Either MetaId Bool) isSingletonType' :: Bool -> Type -> TCM (Either MetaId (Maybe Term)) -- | Auxiliary function. emap :: (a -> b) -> Either c (Maybe a) -> Either c (Maybe b) -- | The monad for the termination checker. -- -- The termination monad TerM is an extension of the type -- checking monad TCM by an environment with information needed by -- the termination checker. module Agda.Termination.Monad -- | The mutual block we are checking. -- -- The functions are numbered according to their order of appearance in -- this list. type MutualNames = [QName] -- | The target of the function we are checking. type Target = QName -- | The current guardedness level. type Guarded = Order -- | The termination environment. data TerEnv TerEnv :: Bool -> Bool -> Bool -> Maybe QName -> Maybe QName -> CutOff -> QName -> MutualNames -> [QName] -> Maybe Target -> Delayed -> [Bool] -> Bool -> Int -> MaskedDeBruijnPats -> !Int -> !Guarded -> Bool -> VarSet -> TerEnv -- | Are we mining dot patterns to find evindence of structal descent? [terUseDotPatterns] :: TerEnv -> Bool -- | Do we assume that record and data type constructors preserve -- guardedness? [terGuardingTypeConstructors] :: TerEnv -> Bool -- | Do we inline with functions to enhance termination checking of with? [terInlineWithFunctions] :: TerEnv -> Bool -- | The name of size successor, if any. [terSizeSuc] :: TerEnv -> Maybe QName -- | The name of the delay constructor (sharp), if any. [terSharp] :: TerEnv -> Maybe QName -- | Depth at which to cut off the structural order. [terCutOff] :: TerEnv -> CutOff -- | The name of the function we are currently checking. [terCurrent] :: TerEnv -> QName -- | The names of the functions in the mutual block we are checking. This -- includes the internally generated functions (with, extendedlambda, -- coinduction). [terMutual] :: TerEnv -> MutualNames -- | The list of name actually appearing in the file (abstract syntax). -- Excludes the internally generated functions. [terUserNames] :: TerEnv -> [QName] -- | Target type of the function we are currently termination checking. -- Only the constructors of Target are considered guarding. [terTarget] :: TerEnv -> Maybe Target -- | Are we checking a delayed definition? [terDelayed] :: TerEnv -> Delayed -- | Only consider the notMasked False arguments for -- establishing termination. [terMaskArgs] :: TerEnv -> [Bool] -- | Only consider guardedness if False (not masked). [terMaskResult] :: TerEnv -> Bool -- | How many SIZELT relations do we have in the context (= clause -- telescope). Used to approximate termination for metas in call args. [_terSizeDepth] :: TerEnv -> Int -- | The patterns of the clause we are checking. [terPatterns] :: TerEnv -> MaskedDeBruijnPats -- | Number of additional binders we have gone under (and consequently need -- to raise the patterns to compare to terms). Updated during call graph -- extraction, hence strict. [terPatternsRaise] :: TerEnv -> !Int -- | The current guardedness status. Changes as we go deeper into the term. -- Updated during call graph extraction, hence strict. [terGuarded] :: TerEnv -> !Guarded -- | When extracting usable size variables during construction of the call -- matrix, can we take the variable for use with SIZELT constraints from -- the context? Yes, if we are under an inductive constructor. No, if we -- are under a record constructor. [terUseSizeLt] :: TerEnv -> Bool -- | Pattern variables that can be compared to argument variables using -- SIZELT. [terUsableVars] :: TerEnv -> VarSet -- | An empty termination environment. -- -- Values are set to a safe default meaning that with these initial -- values the termination checker will not miss termination errors it -- would have seen with better settings of these values. -- -- Values that do not have a safe default are set to IMPOSSIBLE. defaultTerEnv :: TerEnv -- | Termination monad service class. class (Functor m, Monad m) => MonadTer m where terAsks f = f <$> terAsk terAsk :: MonadTer m => m TerEnv terLocal :: MonadTer m => (TerEnv -> TerEnv) -> m a -> m a terAsks :: MonadTer m => (TerEnv -> a) -> m a -- | Termination monad. newtype TerM a TerM :: ReaderT TerEnv TCM a -> TerM a [terM] :: TerM a -> ReaderT TerEnv TCM a -- | Generic run method for termination monad. runTer :: TerEnv -> TerM a -> TCM a -- | Run TerM computation in default environment (created from options). runTerDefault :: TerM a -> TCM a terGetGuardingTypeConstructors :: TerM Bool terGetInlineWithFunctions :: TerM Bool terGetUseDotPatterns :: TerM Bool terSetUseDotPatterns :: Bool -> TerM a -> TerM a terGetSizeSuc :: TerM (Maybe QName) terGetCurrent :: TerM QName terSetCurrent :: QName -> TerM a -> TerM a terGetSharp :: TerM (Maybe QName) terGetCutOff :: TerM CutOff terGetMutual :: TerM MutualNames terGetUserNames :: TerM [QName] terGetTarget :: TerM (Maybe Target) terSetTarget :: Maybe Target -> TerM a -> TerM a terGetDelayed :: TerM Delayed terSetDelayed :: Delayed -> TerM a -> TerM a terGetMaskArgs :: TerM [Bool] terSetMaskArgs :: [Bool] -> TerM a -> TerM a terGetMaskResult :: TerM Bool terSetMaskResult :: Bool -> TerM a -> TerM a terGetPatterns :: TerM (MaskedDeBruijnPats) terSetPatterns :: MaskedDeBruijnPats -> TerM a -> TerM a terRaise :: TerM a -> TerM a terGetGuarded :: TerM Guarded terModifyGuarded :: (Order -> Order) -> TerM a -> TerM a terSetGuarded :: Order -> TerM a -> TerM a terUnguarded :: TerM a -> TerM a -- | Should the codomain part of a function type preserve guardedness? terPiGuarded :: TerM a -> TerM a -- | Lens for _terSizeDepth. terSizeDepth :: Lens' Int TerEnv -- | Lens for terUsableVars. terGetUsableVars :: TerM VarSet terModifyUsableVars :: (VarSet -> VarSet) -> TerM a -> TerM a terSetUsableVars :: VarSet -> TerM a -> TerM a -- | Lens for terUseSizeLt. terGetUseSizeLt :: TerM Bool terModifyUseSizeLt :: (Bool -> Bool) -> TerM a -> TerM a terSetUseSizeLt :: Bool -> TerM a -> TerM a -- | Compute usable vars from patterns and run subcomputation. withUsableVars :: UsableSizeVars a => a -> TerM b -> TerM b -- | Set terUseSizeLt when going under constructor c. conUseSizeLt :: QName -> TerM a -> TerM a -- | Set terUseSizeLt for arguments following projection q. -- We disregard j<i after a non-coinductive projection. However, the -- projection need not be recursive (Issue 1470). projUseSizeLt :: QName -> TerM a -> TerM a -- | For termination checking purposes flat should not be considered a -- projection. That is, it flat doesn't preserve either structural order -- or guardedness like other projections do. Andreas, 2012-06-09: the -- same applies to projections of recursive records. isProjectionButNotCoinductive :: MonadTCM tcm => QName -> tcm Bool -- | Check whether a projection belongs to a coinductive record and is -- actually recursive. E.g. @ isCoinductiveProjection (Stream.head) = -- return False -- -- isCoinductiveProjection (Stream.tail) = return True @ isCoinductiveProjection :: MonadTCM tcm => Bool -> QName -> tcm Bool type DeBruijnPats = [DeBruijnPat] -- | Patterns with variables as de Bruijn indices. type DeBruijnPat = DeBruijnPat' Int data DeBruijnPat' a -- | De Bruijn Index. VarDBP :: a -> DeBruijnPat' a -- | The name refers to either an ordinary constructor or the successor -- function on sized types. ConDBP :: QName -> [DeBruijnPat' a] -> DeBruijnPat' a -- | Literal. Also abused to censor part of a pattern. LitDBP :: Literal -> DeBruijnPat' a -- | Part of dot pattern that cannot be converted into a pattern. TermDBP :: Term -> DeBruijnPat' a -- | Projection pattern. ProjDBP :: QName -> DeBruijnPat' a -- | How long is the path to the deepest variable? patternDepth :: DeBruijnPat' a -> Int -- | A dummy pattern used to mask a pattern that cannot be used for -- structural descent. unusedVar :: DeBruijnPat -- | raiseDBP n ps increases each de Bruijn index in ps -- by n. Needed when going under a binder during analysis of a -- term. raiseDBP :: Int -> DeBruijnPats -> DeBruijnPats -- | Extract variables from DeBruijnPats that could witness a -- decrease via a SIZELT constraint. -- -- These variables must be under an inductive constructor (with no record -- constructor in the way), or after a coinductive projection (with no -- inductive one in the way). class UsableSizeVars a usableSizeVars :: UsableSizeVars a => a -> TerM VarSet type MaskedDeBruijnPats = [Masked DeBruijnPat] data Masked a Masked :: Bool -> a -> Masked a -- | True if thing not eligible for structural descent. [getMask] :: Masked a -> Bool -- | Thing. [getMasked] :: Masked a -> a masked :: a -> Masked a notMasked :: a -> Masked a -- | Print masked things in double parentheses. -- | The call information is stored as free monoid over CallInfo. As -- long as we never look at it, only accumulate it, it does not matter -- whether we use Set, (nub) list, or Tree. Internally, -- due to lazyness, it is anyway a binary tree of mappend nodes -- and singleton leafs. Since we define no order on CallInfo -- (expensive), we cannot use a Set or nub list. -- Performance-wise, I could not see a difference between Set and list. newtype CallPath CallPath :: [CallInfo] -> CallPath [callInfos] :: CallPath -> [CallInfo] -- | Only show intermediate nodes. (Drop last CallInfo). -- | A very crude way of estimating the SIZELT chains i > j -- > k in context. Returns 3 in this case. Overapproximates. terSetSizeDepth :: Telescope -> TerM a -> TerM a instance Agda.Syntax.Abstract.AllNames Agda.Termination.Monad.CallPath instance GHC.Base.Monoid Agda.Termination.Monad.CallPath instance GHC.Show.Show Agda.Termination.Monad.CallPath instance Agda.Utils.Benchmark.MonadBench Agda.Benchmarking.Phase Agda.Termination.Monad.TerM instance GHC.Base.Monad Agda.Termination.Monad.TerM instance GHC.Base.Applicative Agda.Termination.Monad.TerM instance GHC.Base.Functor Agda.Termination.Monad.TerM instance Data.Traversable.Traversable Agda.Termination.Monad.Masked instance Data.Foldable.Foldable Agda.Termination.Monad.Masked instance GHC.Base.Functor Agda.Termination.Monad.Masked instance GHC.Show.Show a => GHC.Show.Show (Agda.Termination.Monad.Masked a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Agda.Termination.Monad.Masked a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Termination.Monad.Masked a) instance GHC.Show.Show a => GHC.Show.Show (Agda.Termination.Monad.DeBruijnPat' a) instance GHC.Base.Functor Agda.Termination.Monad.DeBruijnPat' instance Agda.Termination.Monad.MonadTer Agda.Termination.Monad.TerM instance Control.Monad.Reader.Class.MonadReader Agda.TypeChecking.Monad.Base.TCEnv Agda.Termination.Monad.TerM instance Control.Monad.State.Class.MonadState Agda.TypeChecking.Monad.Base.TCState Agda.Termination.Monad.TerM instance Control.Monad.IO.Class.MonadIO Agda.Termination.Monad.TerM instance Agda.TypeChecking.Monad.Base.MonadTCM Agda.Termination.Monad.TerM instance Control.Monad.Error.Class.MonadError Agda.TypeChecking.Monad.Base.TCErr Agda.Termination.Monad.TerM instance Agda.Syntax.Abstract.IsProjP (Agda.Termination.Monad.DeBruijnPat' a) instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Termination.Monad.DeBruijnPat instance Agda.Termination.Monad.UsableSizeVars Agda.Termination.Monad.DeBruijnPat instance Agda.Termination.Monad.UsableSizeVars Agda.Termination.Monad.DeBruijnPats instance Agda.Termination.Monad.UsableSizeVars (Agda.Termination.Monad.Masked Agda.Termination.Monad.DeBruijnPat) instance Agda.Termination.Monad.UsableSizeVars Agda.Termination.Monad.MaskedDeBruijnPats instance Agda.Utils.Functor.Decoration Agda.Termination.Monad.Masked instance Agda.TypeChecking.Pretty.PrettyTCM a => Agda.TypeChecking.Pretty.PrettyTCM (Agda.Termination.Monad.Masked a) instance Agda.Utils.Pretty.Pretty Agda.Termination.Monad.CallPath -- | The occurs check for unification. Does pruning on the fly. -- -- When hitting a meta variable: -- --
-- piAbstractTerm v a b[v] = (w : a) -> b[w] --piAbstractTerm :: Term -> Type -> Type -> TCM Type -- |
-- piAbstract (v, a) b[v] = (w : a) -> b[w] ---- -- For rewrite, it does something special: -- --
-- piAbstract (prf, Eq a v v') b[v,prf] = (w : a) (w' : Eq a w v') -> b[w,w'] --piAbstract :: (Term, EqualityView) -> Type -> TCM Type -- | isPrefixOf u v = Just es if v == u applyE es. class IsPrefixOf a isPrefixOf :: IsPrefixOf a => a -> a -> Maybe Elims abstractTerm :: Type -> Term -> Type -> Term -> TCM Term class AbsTerm a -- |
-- subst u . absTerm u == id --absTerm :: AbsTerm a => Term -> a -> a -- | This swaps var 0 and var 1. swap01 :: (Subst Term a) => a -> a instance Agda.TypeChecking.Abstract.IsPrefixOf Agda.Syntax.Internal.Elims instance Agda.TypeChecking.Abstract.IsPrefixOf Agda.Syntax.Internal.Args instance Agda.TypeChecking.Abstract.IsPrefixOf Agda.Syntax.Internal.Term instance Agda.TypeChecking.Abstract.AbsTerm Agda.Syntax.Internal.Term instance Agda.TypeChecking.Abstract.AbsTerm a => Agda.TypeChecking.Abstract.AbsTerm (Agda.Utils.Pointer.Ptr a) instance Agda.TypeChecking.Abstract.AbsTerm Agda.Syntax.Internal.Type instance Agda.TypeChecking.Abstract.AbsTerm Agda.Syntax.Internal.Sort instance Agda.TypeChecking.Abstract.AbsTerm Agda.Syntax.Internal.Level instance Agda.TypeChecking.Abstract.AbsTerm Agda.Syntax.Internal.PlusLevel instance Agda.TypeChecking.Abstract.AbsTerm Agda.Syntax.Internal.LevelAtom instance Agda.TypeChecking.Abstract.AbsTerm a => Agda.TypeChecking.Abstract.AbsTerm (Agda.Syntax.Internal.Elim' a) instance Agda.TypeChecking.Abstract.AbsTerm a => Agda.TypeChecking.Abstract.AbsTerm (Agda.Syntax.Common.Arg a) instance Agda.TypeChecking.Abstract.AbsTerm a => Agda.TypeChecking.Abstract.AbsTerm (Agda.Syntax.Common.Dom a) instance Agda.TypeChecking.Abstract.AbsTerm a => Agda.TypeChecking.Abstract.AbsTerm [a] instance Agda.TypeChecking.Abstract.AbsTerm a => Agda.TypeChecking.Abstract.AbsTerm (GHC.Base.Maybe a) instance (Agda.TypeChecking.Substitute.Subst Agda.Syntax.Internal.Term a, Agda.TypeChecking.Abstract.AbsTerm a) => Agda.TypeChecking.Abstract.AbsTerm (Agda.Syntax.Internal.Abs a) instance (Agda.TypeChecking.Abstract.AbsTerm a, Agda.TypeChecking.Abstract.AbsTerm b) => Agda.TypeChecking.Abstract.AbsTerm (a, b) -- | Reconstruct dropped parameters from constructors. Used by -- with-abstraction to avoid ill-typed abstractions (#745). Note that the -- term in invalid after parameter reconstruction. Parameters need to be -- dropped again before using it. module Agda.TypeChecking.ReconstructParameters reconstructParametersInType :: Type -> TCM Type reconstructParametersInTel :: Telescope -> TCM Telescope reconstructParametersInEqView :: EqualityView -> TCM EqualityView reconstructParameters :: Type -> Term -> TCM Term dropParameters :: TermLike a => a -> TCM a -- | A constructor argument is forced if it appears as pattern variable in -- an index of the target. -- -- For instance x is forced in sing and n is -- forced in zero and suc: -- --
-- data Sing {a}{A : Set a} : A -> Set where -- sing : (x : A) -> Sing x -- -- data Fin : Nat -> Set where -- zero : (n : Nat) -> Fin (suc n) -- suc : (n : Nat) (i : Fin n) -> Fin (suc n) ---- -- At runtime, forced constructor arguments may be erased as they can be -- recovered from dot patterns. In the epic backend, unsing : {A : -- Set} (x : A) -> Sing x -> A unsing .x (sing x) = x becomes -- unsing x sing = x and proj : (n : Nat) (i : Fin n) -- -> Nat proj .(suc n) (zero n) = n proj .(suc n) (suc n i) = n -- becomes proj (suc n) zero = n proj (suc n) (suc i) = n -- -- Forcing is a concept from pattern matching and thus builds on the -- concept of equality (I) used there (closed terms, extensional) which -- is different from the equality (II) used in conversion checking and -- the constraint solver (open terms, intensional). -- -- Up to issue 1441 (Feb 2015), the forcing analysis here relied on the -- wrong equality (II), considering type constructors as injective. This -- is unsound for Epic's program extraction, but ok if forcing is only -- used to decide which arguments to skip during conversion checking. -- -- From now on, forcing uses equality (I) and does not search for forced -- variables under type constructors. This may lose some savings during -- conversion checking. If this turns out to be a problem, the old -- forcing could be brought back, using a new modality Skip to -- indicate that this is a relevant argument but still can be skipped -- during conversion checking as it is forced by equality (II). module Agda.TypeChecking.Forcing -- | Given the type of a constructor (excluding the parameters), decide -- which arguments are forced. Update the relevance info in the domains -- accordingly. Precondition: the type is of the form Γ → D vs -- and the vs are in normal form. addForcingAnnotations :: Type -> TCM Type -- | Compute the pattern variables of a term or term-like thing. class ForcedVariables a forcedVariables :: ForcedVariables a => a -> [Nat] -- | Assumes that the term is in normal form. -- | force s xs t marks the domains xs in function type -- t as forced. Domains bigger than s are marked as -- Forced Big, others as Forced -- Small. Counting left-to-right, starting with 0. -- Precondition: function type is exposed. force :: Sort -> [Nat] -> Type -> TCM Type instance (Agda.TypeChecking.Forcing.ForcedVariables a, Data.Foldable.Foldable t) => Agda.TypeChecking.Forcing.ForcedVariables (t a) instance Agda.TypeChecking.Forcing.ForcedVariables Agda.Syntax.Internal.Term -- | Rewriting with arbitrary rules. -- -- The user specifies a relation symbol by the pragma {--} -- where rel should be of type Δ → (lhs rhs : A) → Set -- i. -- -- Then the user can add rewrite rules by the pragma {--} -- where q should be a closed term of type Γ → rel us lhs -- rhs. -- -- We then intend to add a rewrite rule Γ ⊢ lhs ↦ rhs : B to -- the signature where B = A[us/Δ]. -- -- To this end, we normalize lhs, which should be of the form -- f ts for a Def-symbol f (postulate, -- function, data, record, constructor). Further, FV(ts) = -- dom(Γ). The rule q :: Γ ⊢ f ts ↦ rhs : B is added to the -- signature to the definition of f. -- -- When reducing a term Ψ ⊢ f vs is stuck, we try the rewrites -- for f, by trying to unify vs with ts. This -- is for now done by substituting fresh metas Xs for the bound variables -- in ts and checking equality with vs Ψ ⊢ (f -- ts)[XsΓ] = f vs : B[XsΓ] If successful (no open -- metas/constraints), we replace f vs by rhs[Xs/Γ] and -- continue reducing. module Agda.TypeChecking.Rewriting requireOptionRewriting :: TCM () -- | Check that the name given to the BUILTIN REWRITE is actually a -- relation symbol. I.e., its type should be of the form Δ → (lhs rhs -- : A) → Set ℓ. Note: we do not care about hiding/non-hiding of lhs -- and rhs. verifyBuiltinRewrite :: Term -> Type -> TCM () -- | Deconstructing a type into Δ → t → t' → core. data RelView RelView :: Telescope -> ListTel -> Type -> Type -> Type -> RelView -- | The whole telescope Δ, t, t'. [relViewTel] :: RelView -> Telescope -- | Δ. [relViewDelta] :: RelView -> ListTel -- | t. [relViewType] :: RelView -> Type -- | t'. [relViewType'] :: RelView -> Type -- | core. [relViewCore] :: RelView -> Type -- | Deconstructing a type into Δ → t → t' → core. Returns -- Nothing if not enough argument types. relView :: Type -> TCM (Maybe RelView) -- | Add q : Γ → rel us lhs rhs as rewrite rule Γ ⊢ lhs ↦ rhs -- : B to the signature where B = A[us/Δ]. Remember that -- rel : Δ → A → A → Set i, so rel us : (lhs rhs : A[us/Δ]) -- → Set i. addRewriteRule :: QName -> TCM () -- | Append rewrite rules to a definition. addRewriteRules :: QName -> RewriteRules -> TCM () -- | rewriteWith t v rew tries to rewrite v : t with -- rew, returning the reduct if successful. rewriteWith :: Maybe Type -> Term -> RewriteRule -> ReduceM (Either (Blocked Term) Term) -- | rewrite t tries to rewrite a reduced term. rewrite :: Blocked Term -> ReduceM (Either (Blocked Term) Term) class NLPatVars a nlPatVars :: NLPatVars a => a -> IntSet rewArity :: RewriteRule -> Int -- | Erase the CtxId's of rewrite rules class KillCtxId a killCtxId :: KillCtxId a => a -> a instance (Data.Foldable.Foldable f, Agda.TypeChecking.Rewriting.NLPatVars a) => Agda.TypeChecking.Rewriting.NLPatVars (f a) instance Agda.TypeChecking.Rewriting.NLPatVars Agda.TypeChecking.Monad.Base.NLPat instance (GHC.Base.Functor f, Agda.TypeChecking.Rewriting.KillCtxId a) => Agda.TypeChecking.Rewriting.KillCtxId (f a) instance Agda.TypeChecking.Rewriting.KillCtxId Agda.TypeChecking.Monad.Base.RewriteRule instance Agda.TypeChecking.Rewriting.KillCtxId Agda.TypeChecking.Monad.Base.NLPat module Agda.TypeChecking.Rules.Data -- | Type check a datatype definition. Assumes that the type has already -- been checked. checkDataDef :: DefInfo -> QName -> [LamBinding] -> [Constructor] -> TCM () -- | A parameter is small if its sort fits into the data sort. -- smallParams overapproximates the small parameters (in doubt: -- small). smallParams :: Telescope -> Sort -> TCM [Int] -- | Type check a constructor declaration. Checks that the constructor -- targets the datatype and that it fits inside the declared sort. -- Returns the non-linear parameters. checkConstructor :: QName -> Telescope -> Nat -> Sort -> Constructor -> TCM [Int] -- | Bind the parameters of a datatype. bindParameters :: [LamBinding] -> Type -> (Telescope -> Type -> TCM a) -> TCM a -- | Check that the arguments to a constructor fits inside the sort of the -- datatype. The first argument is the type of the constructor. fitsIn :: Type -> Sort -> TCM () -- | Return the parameters that share variables with the indices -- nonLinearParameters :: Int -> Type -> TCM [Int] -- nonLinearParameters nPars t = -- -- Check that a type constructs something of the given datatype. The -- first argument is the number of parameters to the datatype. -- -- As a side effect, return the parameters that occur free in indices. -- E.g. in data Eq (A : Set)(a : A) : A -> Set where refl : Eq A a -- a this would include parameter a, but not A. -- -- TODO: what if there's a meta here? constructs :: Int -> Type -> QName -> TCM [Int] -- | Is the type coinductive? Returns Nothing if the answer cannot -- be determined. isCoinductive :: Type -> TCM (Maybe Bool) module Agda.TypeChecking.Rules.LHS.Split -- | Split a problem at the first constructor pattern which is actually of -- datatype type. -- -- Or, if there is no constructor pattern left and the rest type is a -- record type and the first rest pattern is a projection pattern, split -- the rest type. -- -- Implicit patterns should have been inserted. splitProblem :: Maybe QName -> Problem -> ListT TCM SplitProblem module Agda.TypeChecking.Rules.LHS.Unify -- | Result of unifyIndices. type UnificationResult = UnificationResult' (Telescope, PatternSubstitution) data UnificationResult' a -- | Unification succeeded. Unifies :: a -> UnificationResult' a -- | Terms are not unifiable. NoUnify :: TCErr -> UnificationResult' a -- | Some other error happened, unification got stuck. DontKnow :: TCErr -> UnificationResult' a unifyIndices :: MonadTCM tcm => Telescope -> FlexibleVars -> Type -> Args -> Args -> tcm UnificationResult -- | Unify indices. -- -- In unifyIndices_ flex a us vs, -- -- a is the type eliminated by us and vs -- (usally the type of a constructor), need not be reduced, -- -- us and vs are the argument lists to unify, -- -- flex is the set of flexible (instantiable) variabes in -- us and vs. -- -- The result is the most general unifier of us and vs. unifyIndices_ :: MonadTCM tcm => Telescope -> FlexibleVars -> Type -> Args -> Args -> tcm (Telescope, PatternSubstitution) instance GHC.Show.Show Agda.TypeChecking.Rules.LHS.Unify.UnifyStep instance GHC.Show.Show Agda.TypeChecking.Rules.LHS.Unify.UnifyState instance Data.Traversable.Traversable Agda.TypeChecking.Rules.LHS.Unify.UnificationResult' instance Data.Foldable.Foldable Agda.TypeChecking.Rules.LHS.Unify.UnificationResult' instance GHC.Base.Functor Agda.TypeChecking.Rules.LHS.Unify.UnificationResult' instance GHC.Show.Show a => GHC.Show.Show (Agda.TypeChecking.Rules.LHS.Unify.UnificationResult' a) instance Agda.TypeChecking.Reduce.Reduce Agda.TypeChecking.Rules.LHS.Unify.Equality instance Agda.TypeChecking.Reduce.Reduce Agda.TypeChecking.Rules.LHS.Unify.UnifyState instance Agda.TypeChecking.Reduce.Normalise Agda.TypeChecking.Rules.LHS.Unify.UnifyState instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Rules.LHS.Unify.UnifyState instance GHC.Base.Monoid Agda.TypeChecking.Rules.LHS.Unify.UnifyOutput module Agda.Compiler.Epic.Forcing -- | Returns how many parameters a datatype has dataParameters :: QName -> Compile TCM Nat -- | Returns how many parameters a datatype has dataParametersTCM :: QName -> TCM Nat report :: Int -> TCM Doc -> Compile TCM () piApplyM' :: Type -> Args -> TCM Type -- | insertTele i xs t tele tpos tele := Gamma ; (i : T as) ; Delta n := -- parameters T xs' := xs apply (take n as) becomes tpos ( Gamma ; -- xs' ; Delta[i := t] --note that Delta still reference Gamma correctly -- , T as ^ (size xs') ) -- -- we raise the type since we have added xs' new bindings before Gamma, -- and as can only bind to Gamma. insertTele :: (QName, Args) -> Int -> Maybe Type -> Term -> Telescope -> Compile TCM (Telescope, (Telescope, Type, Type)) mkCon :: QName -> Int -> Term unifyI :: Telescope -> FlexibleVars -> Type -> Args -> Args -> Compile TCM [Maybe Term] takeTele :: Int -> Telescope -> Telescope -- | Main function for removing pattern matching on forced variables remForced :: [Fun] -> Compile TCM [Fun] -- | For a given expression, in a certain telescope (the list of Var) is a -- mapping of variable name to the telescope. forcedExpr :: [Var] -> Telescope -> Expr -> Compile TCM Expr -- | replace the forcedVar with pattern matching from the outside. replaceForced :: ([Var], [Var]) -> Telescope -> [Var] -> [Maybe Term] -> Expr -> Compile TCM Expr -- | Given a term containg the forced var, dig out the variable by -- inserting the proper case-expressions. buildTerm :: Var -> Nat -> Term -> Compile TCM (Expr -> Expr, Var) -- | Find the location where a certain Variable index is by searching the -- constructors aswell. i.e find a term that can be transformed into a -- pattern that contains the same value the index. This fails if no such -- term is present. findPosition :: Nat -> [Maybe Term] -> Compile TCM (Maybe (Nat, Term)) -- | Coverage checking, case splitting, and splitting for refine tactics. module Agda.TypeChecking.Coverage data SplitClause SClause :: Telescope -> [NamedArg DeBruijnPattern] -> PatternSubstitution -> Maybe (Arg Type) -> SplitClause -- | Type of variables in scPats. [scTel] :: SplitClause -> Telescope -- | The patterns leading to the currently considered branch of the split -- tree. [scPats] :: SplitClause -> [NamedArg DeBruijnPattern] -- | Substitution from scTel to old context. Only needed directly -- after split on variable: * To update scTarget * To rename other -- split variables when splitting on multiple variables. scSubst -- is not `transitive', i.e., does not record the substitution -- from the original context to scTel over a series of splits. It -- is freshly computed after each split by computeNeighborhood; -- also splitResult, which does not split on a variable, should -- reset it to the identity idS, lest it be applied to -- scTarget again, leading to Issue 1294. [scSubst] :: SplitClause -> PatternSubstitution -- | The type of the rhs, living in context scTel. This invariant is -- broken before calls to fixTarget; there, scTarget lives -- in the old context. fixTarget moves scTarget to the new -- context by applying substitution scSubst. [scTarget] :: SplitClause -> Maybe (Arg Type) -- | Create a split clause from a clause in internal syntax. clauseToSplitClause :: Clause -> SplitClause -- | Update the target type, add more patterns to split clause if target -- becomes a function type. Returns the domains of the function type (if -- any). fixTarget :: SplitClause -> TCM (Telescope, SplitClause) -- | A Covering is the result of splitting a SplitClause. data Covering Covering :: Arg Nat -> [(QName, SplitClause)] -> Covering -- | De Bruijn level (counting dot patterns) of argument we split on. [covSplitArg] :: Covering -> Arg Nat -- | Covering clauses, indexed by constructor these clauses share. [covSplitClauses] :: Covering -> [(QName, SplitClause)] -- | Project the split clauses out of a covering. splitClauses :: Covering -> [SplitClause] -- | Top-level function for checking pattern coverage. coverageCheck :: QName -> Type -> [Clause] -> TCM SplitTree -- | Entry point from Interaction.MakeCase. splitClauseWithAbsurd :: SplitClause -> Nat -> TCM (Either SplitError (Either SplitClause Covering)) -- | Entry point from TypeChecking.Empty and -- Interaction.BasicOps. splitLast CoInductive is used -- in the refine tactics. splitLast :: Induction -> Telescope -> [NamedArg DeBruijnPattern] -> TCM (Either SplitError Covering) -- |
-- splitResult f sc = return res ---- -- If the target type of sc is a record type, a covering set of -- split clauses is returned (sc extended by all valid -- projection patterns), otherwise res == Nothing. Note that the -- empty set of split clauses is returned if the record has no fields. splitResult :: QName -> SplitClause -> TCM (Maybe Covering) instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Coverage.SplitClause module Agda.TypeChecking.CompiledClause.Compile -- | Process function clauses into case tree. This involves: 1. Coverage -- checking, generating a split tree. 2. Translation of lhs record -- patterns into rhs uses of projection. Update the split tree. 3. -- Generating a case tree from the split tree. Phases 1. and 2. are -- skipped if Nothing. compileClauses :: Maybe (QName, Type) -> [Clause] -> TCM CompiledClauses -- | Stripped-down version of Clause used in clause compiler. data Cl Cl :: [Arg Pattern] -> ClauseBody -> Cl [clPats] :: Cl -> [Arg Pattern] [clBody] :: Cl -> ClauseBody type Cls = [Cl] compileWithSplitTree :: (Term -> Term) -> SplitTree -> Cls -> CompiledClauses compile :: (Term -> Term) -> Cls -> CompiledClauses -- | Get the index of the next argument we need to split on. This the -- number of the first pattern that does a match in the first clause. nextSplit :: Cls -> Maybe (Bool, Arg Int) -- | Is is not a variable pattern? And if yes, is it a record pattern? properSplit :: Pattern -> Maybe Bool -- | Is this a variable pattern? -- -- Maintain invariant: isVar = isNothing . properSplit! isVar :: Pattern -> Bool -- | splitOn single n cs will force expansion of catch-alls if -- single. splitOn :: Bool -> Int -> Cls -> Case Cls splitC :: Int -> Cl -> Case Cl -- | Expand catch-alls that appear before actual matches. -- -- Example: -- --
-- true y -- x false -- false y ---- -- will expand the catch-all x to false. -- -- Catch-alls need also to be expanded if they come before/after a record -- pattern, otherwise we get into trouble when we want to eliminate -- splits on records later. -- -- Another example (see Issue 1650): f (x, (y, z)) true = a f _ -- false = b Split tree: 0 (first argument of f) - 1 (second -- component of the pair) - 3 (last argument of f) -- true -> a - -- false -> b We would like to get the following case tree: -- case 0 of _,_ -> case 1 of _,_ -> case 3 of true -> a; false -- -> b _ -> case 3 of true -> a; false -> b _ -> case 3 -- of true -> a; false -> b expandCatchAlls :: Bool -> Int -> Cls -> Cls substBody :: Int -> Int -> Term -> ClauseBody -> ClauseBody instance GHC.Show.Show Agda.TypeChecking.CompiledClause.Compile.Cl instance Agda.Utils.Pretty.Pretty Agda.TypeChecking.CompiledClause.Compile.Cl module Agda.TypeChecking.Empty -- | Check whether a type is empty. This check may be postponed as -- emptiness constraint. isEmptyType :: Range -> Type -> TCM () module Agda.TypeChecking.Rules.LHS -- | Compute the set of flexible patterns in a list of patterns. The result -- is the deBruijn indices of the flexible patterns. flexiblePatterns :: [NamedArg Pattern] -> TCM FlexibleVars -- | A pattern is flexible if it is dotted or implicit, or a record pattern -- with only flexible subpatterns. class IsFlexiblePattern a where isFlexiblePattern p = isJust <$> runMaybeT (maybeFlexiblePattern p) maybeFlexiblePattern :: IsFlexiblePattern a => a -> MaybeT TCM FlexibleVarKind isFlexiblePattern :: IsFlexiblePattern a => a -> TCM Bool -- | Lists of flexible patterns are RecordFlex. -- | Update the in patterns according to the given substitution, collecting -- new dot pattern instantiations in the process. updateInPatterns :: [Dom Type] -> [NamedArg Pattern] -> [Arg DeBruijnPattern] -> TCM ([NamedArg Pattern], [DotPatternInst]) -- | Check if a problem is solved. That is, if the patterns are all -- variables. isSolvedProblem :: Problem -> Bool -- | For each user-defined pattern variable in the Problem, check -- that the corresponding data type (if any) does not contain a -- constructor of the same name (which is not in scope); this "shadowing" -- could indicate an error, and is not allowed. -- -- Precondition: The problem has to be solved. noShadowingOfConstructors :: Call -> Problem -> TCM () -- | Check that a dot pattern matches it's instantiation. checkDotPattern :: DotPatternInst -> TCM () -- | Checks whether the dot patterns left over after splitting can be -- covered by shuffling around the dots from implicit positions. Returns -- the updated user patterns (without dot patterns). checkLeftoverDotPatterns :: [NamedArg Pattern] -> [Int] -> [Dom Type] -> [DotPatternInst] -> TCM () -- | Bind the variables in a left hand side and check that Hiding of -- the patterns matches the hiding info in the type. -- -- Precondition: the patterns should all be VarP, WildP, or -- AbsurdP and the telescope should have the same size as the -- pattern list. There could also be ConPs resulting from eta -- expanded implicit record patterns. bindLHSVars :: [NamedArg Pattern] -> Telescope -> TCM a -> TCM a -- | Bind as patterns bindAsPatterns :: [AsBinding] -> TCM a -> TCM a -- | Result of checking the LHS of a clause. data LHSResult LHSResult :: Telescope -> [NamedArg Pattern] -> Arg Type -> Permutation -> LHSResult -- | Δ : The types of the pattern variables, in internal dependency order. -- Corresponds to clauseTel. [lhsVarTele] :: LHSResult -> Telescope -- | The patterns in internal syntax. [lhsPatterns] :: LHSResult -> [NamedArg Pattern] -- | The type of the body. Is bσ if Γ is defined. -- Irrelevant to indicate the rhs must be checked in irrelevant -- mode. [lhsBodyType] :: LHSResult -> Arg Type -- | The permutation from pattern vars to Δ. Corresponds to -- clausePerm. [lhsPermutation] :: LHSResult -> Permutation -- | Check a LHS. Main function. -- -- checkLeftHandSide a ps a ret checks that user patterns -- ps eliminate the type a of the defined function, and -- calls continuation ret if successful. checkLeftHandSide :: Call -> Maybe QName -> [NamedArg Pattern] -> Type -> (LHSResult -> TCM a) -> TCM a -- | The loop (tail-recursive): split at a variable in the problem until -- problem is solved checkLHS :: Maybe QName -> LHSState -> TCM LHSState -- | Ensures that we are not performing pattern matching on codata. noPatternMatchingOnCodata :: [NamedArg DeBruijnPattern] -> TCM () instance Agda.TypeChecking.Rules.LHS.IsFlexiblePattern Agda.Syntax.Abstract.Pattern instance Agda.TypeChecking.Rules.LHS.IsFlexiblePattern (Agda.Syntax.Internal.Pattern' a) instance Agda.TypeChecking.Rules.LHS.IsFlexiblePattern a => Agda.TypeChecking.Rules.LHS.IsFlexiblePattern [a] instance Agda.TypeChecking.Rules.LHS.IsFlexiblePattern a => Agda.TypeChecking.Rules.LHS.IsFlexiblePattern (Agda.Syntax.Common.Arg a) instance Agda.TypeChecking.Rules.LHS.IsFlexiblePattern a => Agda.TypeChecking.Rules.LHS.IsFlexiblePattern (Agda.Syntax.Common.Named name a) instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Rules.LHS.LHSResult -- | Solving size constraints under hypotheses. -- -- The size solver proceeds as follows: -- --
-- telFromList . telToList == id --prop_telToListInv :: TermConfiguration -> Property -- | All elements of flattenTel are well-scoped under the original -- telescope. prop_flattenTelScope :: TermConfiguration -> Property -- |
-- unflattenTel . flattenTel == id --prop_flattenTelInv :: TermConfiguration -> Property -- | reorderTel is stable. prop_reorderTelStable :: TermConfiguration -> Property -- | The result of splitting a telescope is well-scoped. prop_splitTelescopeScope :: TermConfiguration -> Property -- | The permutation generated when splitting a telescope preserves -- scoping. prop_splitTelescopePermScope :: TermConfiguration -> Property tests :: IO Bool module Agda.TypeChecking.Unquote agdaTermType :: TCM Type agdaTypeType :: TCM Type qNameType :: TCM Type data Dirty Dirty :: Dirty Clean :: Dirty type UnquoteState = (Dirty, TCState) type UnquoteM = ReaderT Context (StateT UnquoteState (WriterT [QName] (ExceptionT UnquoteError TCM))) type UnquoteRes a = Either UnquoteError ((a, UnquoteState), [QName]) unpackUnquoteM :: UnquoteM a -> Context -> UnquoteState -> TCM (UnquoteRes a) packUnquoteM :: (Context -> UnquoteState -> TCM (UnquoteRes a)) -> UnquoteM a runUnquoteM :: UnquoteM a -> TCM (Either UnquoteError (a, [QName])) liftU :: TCM a -> UnquoteM a liftU1 :: (TCM (UnquoteRes a) -> TCM (UnquoteRes b)) -> UnquoteM a -> UnquoteM b liftU2 :: (TCM (UnquoteRes a) -> TCM (UnquoteRes b) -> TCM (UnquoteRes c)) -> UnquoteM a -> UnquoteM b -> UnquoteM c inOriginalContext :: UnquoteM a -> UnquoteM a isCon :: ConHead -> TCM Term -> UnquoteM Bool isDef :: QName -> TCM Term -> UnquoteM Bool reduceQuotedTerm :: Term -> UnquoteM Term class Unquote a unquote :: Unquote a => Term -> UnquoteM a unquoteH :: Unquote a => Arg Term -> UnquoteM a unquoteN :: Unquote a => Arg Term -> UnquoteM a choice :: Monad m => [(m Bool, m a)] -> m a -> m a ensureDef :: QName -> UnquoteM QName ensureCon :: QName -> UnquoteM QName pickName :: Type -> String unquoteString :: Term -> UnquoteM String unquoteNString :: Arg Term -> UnquoteM String data ErrorPart StrPart :: String -> ErrorPart TermPart :: Term -> ErrorPart NamePart :: QName -> ErrorPart getCurrentPath :: TCM AbsolutePath -- | Argument should be a term of type Term → TCM A for some A. -- Returns the resulting term of type A. The second argument is -- the term for the hole, which will typically be a metavariable. This is -- passed to the computation (quoted). unquoteTCM :: Term -> Term -> UnquoteM Term evalTCM :: Term -> UnquoteM Term instance GHC.Classes.Eq Agda.TypeChecking.Unquote.Dirty instance Agda.TypeChecking.Unquote.Unquote Agda.Syntax.Common.ArgInfo instance Agda.TypeChecking.Unquote.Unquote a => Agda.TypeChecking.Unquote.Unquote (Agda.Syntax.Common.Arg a) instance Agda.TypeChecking.Unquote.Unquote Agda.Syntax.Reflected.Elim instance Agda.TypeChecking.Unquote.Unquote GHC.Integer.Type.Integer instance Agda.TypeChecking.Unquote.Unquote GHC.Types.Double instance Agda.TypeChecking.Unquote.Unquote GHC.Types.Char instance Agda.TypeChecking.Unquote.Unquote Agda.Utils.String.Str instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Unquote.ErrorPart instance Agda.TypeChecking.Unquote.Unquote Agda.TypeChecking.Unquote.ErrorPart instance Agda.TypeChecking.Unquote.Unquote a => Agda.TypeChecking.Unquote.Unquote [a] instance Agda.TypeChecking.Unquote.Unquote Agda.Syntax.Common.Hiding instance Agda.TypeChecking.Unquote.Unquote Agda.Syntax.Common.Relevance instance Agda.TypeChecking.Unquote.Unquote Agda.Syntax.Abstract.Name.QName instance Agda.TypeChecking.Unquote.Unquote a => Agda.TypeChecking.Unquote.Unquote (Agda.Syntax.Reflected.Abs a) instance Agda.TypeChecking.Unquote.Unquote Agda.Syntax.Common.MetaId instance Agda.TypeChecking.Unquote.Unquote a => Agda.TypeChecking.Unquote.Unquote (Agda.Syntax.Common.Dom a) instance Agda.TypeChecking.Unquote.Unquote Agda.Syntax.Reflected.Sort instance Agda.TypeChecking.Unquote.Unquote Agda.Syntax.Literal.Literal instance Agda.TypeChecking.Unquote.Unquote Agda.Syntax.Reflected.Term instance Agda.TypeChecking.Unquote.Unquote Agda.Syntax.Reflected.Pattern instance Agda.TypeChecking.Unquote.Unquote Agda.Syntax.Reflected.Clause module Agda.TypeChecking.Rules.Term -- | Check that an expression is a type. isType :: Expr -> Sort -> TCM Type -- | Check that an expression is a type without knowing the sort. isType_ :: Expr -> TCM Type ptsRule :: (LensSort a, LensSort b) => a -> b -> TCM Sort -- | Ensure that a (freshly created) function type does not inhabit -- SizeUniv. Precondition: When noFunctionsIntoSize t -- tBlame is called, we are in the context of tBlame in -- order to print it correctly. Not being in context of t should -- not matter, as we are only checking whether its sort reduces to -- SizeUniv. noFunctionsIntoSize :: Type -> Type -> TCM () -- | Check that an expression is a type which is equal to a given type. isTypeEqualTo :: Expr -> Type -> TCM Type leqType_ :: Type -> Type -> TCM () -- | Type check a (module) telescope. Binds the variables defined by the -- telescope. checkTelescope :: Telescope -> (Telescope -> TCM a) -> TCM a -- | Type check the telescope of a dependent function type. Binds the -- resurrected variables defined by the telescope. The returned telescope -- is unmodified (not resurrected). checkPiTelescope :: Telescope -> (Telescope -> TCM a) -> TCM a -- | Flag to control resurrection on domains. data LamOrPi -- | We are checking a module telescope. We pass into the type world to -- check the domain type. This resurrects the whole context. LamNotPi :: LamOrPi -- | We are checking a telescope in a Pi-type. We stay in the term world, -- but add resurrected domains to the context to check the remaining -- domains and codomain of the Pi-type. PiNotLam :: LamOrPi -- | Type check a telescope. Binds the variables defined by the telescope. checkTelescope' :: LamOrPi -> Telescope -> (Telescope -> TCM a) -> TCM a -- | Check a typed binding and extends the context with the bound -- variables. The telescope passed to the continuation is valid in the -- original context. -- -- Parametrized by a flag wether we check a typed lambda or a Pi. This -- flag is needed for irrelevance. checkTypedBindings :: LamOrPi -> TypedBindings -> (Telescope -> TCM a) -> TCM a checkTypedBinding :: LamOrPi -> ArgInfo -> TypedBinding -> (ListTel -> TCM a) -> TCM a -- | Type check a lambda expression. checkLambda :: Arg TypedBinding -> Expr -> Type -> TCM Term -- | Checking a lambda whose domain type has already been checked. checkPostponedLambda :: Arg ([WithHiding Name], Maybe Type) -> Expr -> Type -> TCM Term -- | Insert hidden lambda until the hiding info of the domain type matches -- the expected hiding info. Throws WrongHidingInLambda insertHiddenLambdas :: Hiding -> Type -> (MetaId -> Type -> TCM Term) -> (Type -> TCM Term) -> TCM Term -- | checkAbsurdLambda i h e t checks absurd lambda against type -- t. Precondition: e = AbsurdLam i h checkAbsurdLambda :: ExprInfo -> Hiding -> Expr -> Type -> TCM Term -- | checkExtendedLambda i di qname cs e t check pattern matching -- lambda. Precondition: e = ExtendedLam i di qname cs checkExtendedLambda :: ExprInfo -> DefInfo -> QName -> [Clause] -> Expr -> Type -> TCM Term -- | Run a computation. -- --
-- checkRecDef i name con ps contel fields ---- --
-- stripWithClausePatterns parent f t qs π ps = ps' ---- --
-- record Stream (A : Set) : Set where -- coinductive -- constructor delay -- field force : A × Stream A -- -- record SEq (s t : Stream A) : Set where -- coinductive -- field -- ~force : let a , as = force s -- b , bs = force t -- in a ≡ b × SEq as bs -- -- test : (s : Nat × Stream Nat) (t : Stream Nat) → SEq (delay s) t → SEq t (delay s) -- ~force (test (a , as) t p) with force t -- ~force (test (suc n , as) t p) | b , bs = {!!} ---- -- With function: -- --
-- f : (t : Stream Nat) (w : Nat × Stream Nat) (a : Nat) (as : Stream Nat) -- (p : SEq (delay (a , as)) t) → (fst w ≡ a) × SEq (snd w) as -- -- Δ = t a as p -- reorder to bring with-relevant (= needed) vars first -- π = a as t p → Δ -- qs = (a , as) t p ~force -- ps = (suc n , as) t p ~force -- ps' = (suc n) as t p ---- -- Resulting with-function clause is: -- --
-- f t (b , bs) (suc n) as t p ---- -- Note: stripWithClausePatterns factors ps through qs, -- thus -- --
-- ps = qs[ps'] ---- -- where [..] is to be understood as substitution. The -- projection patterns have vanished from ps' (as they are -- already in qs). stripWithClausePatterns :: QName -> QName -> Type -> [NamedArg Pattern] -> Permutation -> [NamedArg Pattern] -> TCM [NamedArg Pattern] -- | Construct the display form for a with function. It will display -- applications of the with function as applications to the original -- function. For instance, -- --
-- aux a b c -- ---- -- as -- --
-- f (suc a) (suc b) | c -- --withDisplayForm :: QName -> QName -> Telescope -> Telescope -> Nat -> [NamedArg Pattern] -> Permutation -> Permutation -> TCM DisplayForm patsToElims :: Permutation -> [NamedArg Pattern] -> [Elim' DisplayTerm] module Agda.TypeChecking.Rules.Def checkFunDef :: Delayed -> DefInfo -> QName -> [Clause] -> TCM () -- | A single clause without arguments and without type signature is an -- alias. isAlias :: [Clause] -> Type -> Maybe (Expr, MetaId) -- | Check a trivial definition of the form f = e checkAlias :: Type -> ArgInfo -> Delayed -> DefInfo -> QName -> Expr -> TCM () -- | Type check a definition by pattern matching. checkFunDef' :: Type -> ArgInfo -> Delayed -> Maybe ExtLamInfo -> Maybe QName -> DefInfo -> QName -> [Clause] -> TCM () -- | Set funTerminates according to termination info in -- TCEnv, which comes from a possible termination pragma. useTerPragma :: Definition -> TCM Definition -- | Insert some patterns in the in with-clauses LHS of the given RHS insertPatterns :: [Pattern] -> RHS -> RHS -- | Parameters for creating a with-function. data WithFunctionProblem NoWithFunction :: WithFunctionProblem WithFunction :: QName -> QName -> Type -> Telescope -> Telescope -> [Term] -> [EqualityView] -> Type -> [NamedArg Pattern] -> Permutation -> Permutation -> Permutation -> [Clause] -> WithFunctionProblem -- | Parent function name. [wfParentName] :: WithFunctionProblem -> QName -- | With function name. [wfName] :: WithFunctionProblem -> QName -- | Type of the parent function. [wfParentType] :: WithFunctionProblem -> Type -- | Types of arguments to the with function before the with expressions -- (needed vars). [wfBeforeTel] :: WithFunctionProblem -> Telescope -- | Types of arguments to the with function after the with expressions -- (unneeded vars). [wfAfterTel] :: WithFunctionProblem -> Telescope -- | With and rewrite expressions. [wfExprs] :: WithFunctionProblem -> [Term] -- | Types of the with and rewrite expressions. [wfExprTypes] :: WithFunctionProblem -> [EqualityView] -- | Type of the right hand side. [wfRHSType] :: WithFunctionProblem -> Type -- | Parent patterns. [wfParentPats] :: WithFunctionProblem -> [NamedArg Pattern] -- | Permutation resulting from splitting the telescope into needed and -- unneeded vars. [wfPermSplit] :: WithFunctionProblem -> Permutation -- | Permutation reordering the variables in the parent pattern. [wfPermParent] :: WithFunctionProblem -> Permutation -- | Final permutation (including permutation for the parent clause). [wfPermFinal] :: WithFunctionProblem -> Permutation -- | The given clauses for the with function [wfClauses] :: WithFunctionProblem -> [Clause] -- | Create a clause body from a term. -- -- As we have type checked the term in the clause telescope, but the -- final body should have bindings in the order of the pattern variables, -- we need to apply the permutation to the checked term. mkBody :: Permutation -> Term -> ClauseBody -- | Type check a function clause. checkClause :: Type -> SpineClause -> TCM Clause -- | Type check the with and rewrite lhss and/or the rhs. checkRHS :: LHSInfo -> QName -> [NamedArg Pattern] -> Type -> LHSResult -> RHS -> TCM (ClauseBody, WithFunctionProblem) checkWithRHS :: QName -> QName -> Type -> LHSResult -> [Term] -> [EqualityView] -> [Clause] -> TCM (ClauseBody, WithFunctionProblem) checkWithFunction :: WithFunctionProblem -> TCM () -- | Type check a where clause. checkWhere :: Type -> [Declaration] -> TCM a -> TCM a -- | Check if a pattern contains an absurd pattern. For instance, suc -- () containsAbsurdPattern :: Pattern -> Bool module Agda.TypeChecking.Rules.Builtin -- | Bind a builtin thing to an expression. bindBuiltin :: String -> Expr -> TCM () -- | Bind a builtin thing to a new name. bindBuiltinNoDef :: String -> QName -> TCM () -- | bindPostulatedName builtin e m checks that e is a -- postulated name q, and binds the builtin builtin to -- the term m q def, where def is the current -- Definition of q. bindPostulatedName :: String -> Expr -> (QName -> Definition -> TCM Term) -> TCM () isUntypedBuiltin :: String -> Bool bindUntypedBuiltin :: String -> Expr -> TCM () -- | Translation from Agda.Syntax.Concrete to -- Agda.Syntax.Abstract. Involves scope analysis, figuring out -- infix operator precedences and tidying up definitions. module Agda.Syntax.Translation.ConcreteToAbstract -- | Things that can be translated to abstract syntax are instances of this -- class. class ToAbstract concrete abstract | concrete -> abstract toAbstract :: ToAbstract concrete abstract => concrete -> ScopeM abstract -- | This operation does not affect the scope, i.e. the original scope is -- restored upon completion. localToAbstract :: ToAbstract c a => c -> (a -> ScopeM b) -> ScopeM b concreteToAbstract_ :: ToAbstract c a => c -> ScopeM a concreteToAbstract :: ToAbstract c a => ScopeInfo -> c -> ScopeM a newtype NewModuleQName NewModuleQName :: QName -> NewModuleQName newtype OldName a OldName :: a -> OldName a -- | Temporary data type to scope check a file. data TopLevel a TopLevel :: AbsolutePath -> a -> TopLevel a -- | The file path from which we loaded this module. [topLevelPath] :: TopLevel a -> AbsolutePath -- | The file content. [topLevelTheThing] :: TopLevel a -> a data TopLevelInfo TopLevelInfo :: [Declaration] -> ScopeInfo -> TopLevelInfo [topLevelDecls] :: TopLevelInfo -> [Declaration] -- | as seen from inside the module [topLevelScope] :: TopLevelInfo -> ScopeInfo -- | The top-level module name. topLevelModuleName :: TopLevelInfo -> ModuleName data AbstractRHS data NewModuleName data OldModuleName data NewName a data OldQName data LeftHandSide data RightHandSide data PatName data APatName data LetDef data LetDefs instance (Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract c1 a1, Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract c2 a2) => Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (c1, c2) (a1, a2) instance (Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract c1 a1, Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract c2 a2, Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract c3 a3) => Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (c1, c2, c3) (a1, a2, a3) instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract c a => Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract [c] [a] instance (Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract c1 a1, Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract c2 a2) => Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (Data.Either.Either c1 c2) (Data.Either.Either a1 a2) instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract c a => Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (GHC.Base.Maybe c) (GHC.Base.Maybe a) instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (Agda.Syntax.Translation.ConcreteToAbstract.NewName Agda.Syntax.Concrete.Name.Name) Agda.Syntax.Abstract.Name.Name instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (Agda.Syntax.Translation.ConcreteToAbstract.NewName Agda.Syntax.Concrete.BoundName) Agda.Syntax.Abstract.Name.Name instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Translation.ConcreteToAbstract.OldQName Agda.Syntax.Abstract.Expr instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Translation.ConcreteToAbstract.PatName Agda.Syntax.Translation.ConcreteToAbstract.APatName instance Agda.Syntax.Translation.ConcreteToAbstract.ToQName Agda.Syntax.Concrete.Name.Name instance Agda.Syntax.Translation.ConcreteToAbstract.ToQName Agda.Syntax.Concrete.Name.QName instance (GHC.Show.Show a, Agda.Syntax.Translation.ConcreteToAbstract.ToQName a) => Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (Agda.Syntax.Translation.ConcreteToAbstract.OldName a) Agda.Syntax.Abstract.Name.QName instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Translation.ConcreteToAbstract.NewModuleName Agda.Syntax.Abstract.Name.ModuleName instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Translation.ConcreteToAbstract.NewModuleQName Agda.Syntax.Abstract.Name.ModuleName instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Translation.ConcreteToAbstract.OldModuleName Agda.Syntax.Abstract.Name.ModuleName instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Concrete.Expr Agda.Syntax.Abstract.Expr instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Concrete.ModuleAssignment (Agda.Syntax.Abstract.Name.ModuleName, [Agda.Syntax.Abstract.LetBinding]) instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract c a => Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (Agda.Syntax.Concrete.FieldAssignment' c) (Agda.Syntax.Concrete.FieldAssignment' a) instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Concrete.LamBinding Agda.Syntax.Abstract.LamBinding instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Concrete.TypedBindings Agda.Syntax.Abstract.TypedBindings instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Concrete.TypedBinding Agda.Syntax.Abstract.TypedBinding instance Agda.Syntax.Translation.ConcreteToAbstract.EnsureNoLetStms Agda.Syntax.Concrete.TypedBinding instance Agda.Syntax.Translation.ConcreteToAbstract.EnsureNoLetStms a => Agda.Syntax.Translation.ConcreteToAbstract.EnsureNoLetStms (Agda.Syntax.Concrete.LamBinding' a) instance Agda.Syntax.Translation.ConcreteToAbstract.EnsureNoLetStms a => Agda.Syntax.Translation.ConcreteToAbstract.EnsureNoLetStms (Agda.Syntax.Concrete.TypedBindings' a) instance Agda.Syntax.Translation.ConcreteToAbstract.EnsureNoLetStms a => Agda.Syntax.Translation.ConcreteToAbstract.EnsureNoLetStms [a] instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (Agda.Syntax.Translation.ConcreteToAbstract.TopLevel [Agda.Syntax.Concrete.Declaration]) Agda.Syntax.Translation.ConcreteToAbstract.TopLevelInfo instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract [Agda.Syntax.Concrete.Declaration] [Agda.Syntax.Abstract.Declaration] instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Translation.ConcreteToAbstract.LetDefs [Agda.Syntax.Abstract.LetBinding] instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Translation.ConcreteToAbstract.LetDef [Agda.Syntax.Abstract.LetBinding] instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (Agda.Syntax.Translation.ConcreteToAbstract.Blind a) (Agda.Syntax.Translation.ConcreteToAbstract.Blind a) instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Concrete.Definitions.NiceDeclaration Agda.Syntax.Abstract.Declaration instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Translation.ConcreteToAbstract.ConstrDecl Agda.Syntax.Abstract.Declaration instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Concrete.Pragma [Agda.Syntax.Abstract.Pragma] instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Concrete.Definitions.Clause Agda.Syntax.Abstract.Clause instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Translation.ConcreteToAbstract.AbstractRHS Agda.Syntax.Abstract.RHS instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Translation.ConcreteToAbstract.RightHandSide Agda.Syntax.Translation.ConcreteToAbstract.AbstractRHS instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Concrete.RHS Agda.Syntax.Translation.ConcreteToAbstract.AbstractRHS instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Translation.ConcreteToAbstract.LeftHandSide Agda.Syntax.Abstract.LHS instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Concrete.LHSCore (Agda.Syntax.Abstract.LHSCore' Agda.Syntax.Concrete.Expr) instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract c a => Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (Agda.Syntax.Common.WithHiding c) (Agda.Syntax.Common.WithHiding a) instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract c a => Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (Agda.Syntax.Common.Arg c) (Agda.Syntax.Common.Arg a) instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract c a => Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (Agda.Syntax.Common.Named name c) (Agda.Syntax.Common.Named name a) instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (Agda.Syntax.Abstract.LHSCore' Agda.Syntax.Concrete.Expr) (Agda.Syntax.Abstract.LHSCore' Agda.Syntax.Abstract.Expr) instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract (Agda.Syntax.Abstract.Pattern' Agda.Syntax.Concrete.Expr) (Agda.Syntax.Abstract.Pattern' Agda.Syntax.Abstract.Expr) instance Agda.Syntax.Translation.ConcreteToAbstract.ToAbstract Agda.Syntax.Concrete.Pattern (Agda.Syntax.Abstract.Pattern' Agda.Syntax.Concrete.Expr) -- | Handling of the INFINITY, SHARP and FLAT builtins. module Agda.TypeChecking.Rules.Builtin.Coinduction -- | The type of ∞. typeOfInf :: TCM Type -- | The type of ♯_. typeOfSharp :: TCM Type -- | The type of ♭. typeOfFlat :: TCM Type -- | Binds the INFINITY builtin, but does not change the type's definition. bindBuiltinInf :: Expr -> TCM () -- | Binds the SHARP builtin, and changes the definitions of INFINITY and -- SHARP. bindBuiltinSharp :: Expr -> TCM () -- | Binds the FLAT builtin, and changes its definition. bindBuiltinFlat :: Expr -> TCM () module Agda.TypeChecking.Rules.Decl -- | Cached checkDecl checkDeclCached :: Declaration -> TCM () -- | Type check a sequence of declarations. checkDecls :: [Declaration] -> TCM () -- | Type check a single declaration. checkDecl :: Declaration -> TCM () mutualChecks :: MutualInfo -> Declaration -> [Declaration] -> MutualId -> Set QName -> TCM () type FinalChecks = Maybe (TCM ()) checkUnquoteDecl :: MutualInfo -> [DefInfo] -> [QName] -> Expr -> TCM FinalChecks checkUnquoteDef :: [DefInfo] -> [QName] -> Expr -> TCM () -- | Run a reflected TCM computatation expected to define a given list of -- names. unquoteTop :: [QName] -> Expr -> TCM [QName] -- | Instantiate all metas in Definition associated to QName. -- Makes sense after freezing metas. Some checks, like free variable -- analysis, are not in TCM, so they will be more precise (see -- issue 1099) after meta instantiation. Precondition: name has been -- added to signature already. instantiateDefinitionType :: QName -> TCM () -- | Highlight a declaration. highlight_ :: Declaration -> TCM () -- | Termination check a declaration. checkTermination_ :: MutualId -> Declaration -> TCM () -- | Check a set of mutual names for positivity. checkPositivity_ :: MutualInfo -> Set QName -> TCM () -- | Check that all coinductive records are actually recursive. (Otherwise, -- one can implement invalid recursion schemes just like for the old -- coinduction.) checkCoinductiveRecords :: [Declaration] -> TCM () -- | Check a set of mutual names for constructor-headedness. checkInjectivity_ :: Set QName -> TCM () -- | Check a set of mutual names for projection likeness. -- -- Only a single, non-abstract function can be projection-like. Making an -- abstract function projection-like would break the invariant that the -- type of the principle argument of a projection-like function is always -- inferable. checkProjectionLikeness_ :: Set QName -> TCM () -- | Type check an axiom. checkAxiom :: Axiom -> DefInfo -> ArgInfo -> QName -> Expr -> TCM () -- | Type check a primitive function declaration. checkPrimitive :: DefInfo -> QName -> Expr -> TCM () assertCurrentModule :: QName -> String -> TCM () -- | Check a pragma. checkPragma :: Range -> Pragma -> TCM () -- | Type check a bunch of mutual inductive recursive definitions. -- -- All definitions which have so far been assigned to the given mutual -- block are returned. checkMutual :: MutualInfo -> [Declaration] -> TCM (MutualId, Set QName) -- | Type check the type signature of an inductive or recursive definition. checkTypeSignature :: TypeSignature -> TCM () -- | Type check a module. checkSection :: ModuleInfo -> ModuleName -> Telescope -> [Declaration] -> TCM () -- | Helper for checkSectionApplication. -- -- Matches the arguments of the module application with the module -- parameters. -- -- Returns the remaining module parameters as an open telescope. Warning: -- the returned telescope is not the final result, an actual -- instantiation of the parameters does not occur. checkModuleArity :: ModuleName -> Telescope -> [NamedArg Expr] -> TCM Telescope -- | Check an application of a section (top-level function, includes -- traceCall). checkSectionApplication :: ModuleInfo -> ModuleName -> ModuleApplication -> Ren QName -> Ren ModuleName -> TCM () -- | Check an application of a section. checkSectionApplication' :: ModuleInfo -> ModuleName -> ModuleApplication -> Ren QName -> Ren ModuleName -> TCM () -- | Type check an import declaration. Actually doesn't do anything, since -- all the work is done when scope checking. checkImport :: ModuleInfo -> ModuleName -> TCM () class ShowHead a showHead :: ShowHead a => a -> String debugPrintDecl :: Declaration -> TCM () instance Agda.TypeChecking.Rules.Decl.ShowHead Agda.Syntax.Abstract.Declaration module Agda.TheTypeChecker -- | Type check a sequence of declarations. checkDecls :: [Declaration] -> TCM () -- | Type check a single declaration. checkDecl :: Declaration -> TCM () -- | Cached checkDecl checkDeclCached :: Declaration -> TCM () -- | Infer the type of an expression. Implemented by checking against a -- meta variable. Except for neutrals, for them a polymorphic type is -- inferred. inferExpr :: Expr -> TCM (Term, Type) -- | Type check an expression. checkExpr :: Expr -> Type -> TCM Term module Agda.Interaction.BasicOps -- | Parses an expression. parseExpr :: Range -> String -> TCM Expr parseExprIn :: InteractionId -> Range -> String -> TCM Expr giveExpr :: MetaId -> Expr -> TCM Expr -- | Try to fill hole by expression. -- -- Returns the given expression unchanged (for convenient generalization -- to refine). give :: InteractionId -> Maybe Range -> Expr -> TCM Expr -- | Try to refine hole by expression e. -- -- This amounts to successively try to give e, e ?, -- e ? ?, ... Returns the successfully given expression. refine :: InteractionId -> Maybe Range -> Expr -> TCM Expr -- | Evaluate the given expression in the current environment evalInCurrent :: Expr -> TCM Expr evalInMeta :: InteractionId -> Expr -> TCM Expr data Rewrite AsIs :: Rewrite Instantiated :: Rewrite HeadNormal :: Rewrite Simplified :: Rewrite Normalised :: Rewrite normalForm :: Rewrite -> Type -> TCM Type data OutputForm a b OutputForm :: Range -> ProblemId -> (OutputConstraint a b) -> OutputForm a b data OutputConstraint a b OfType :: b -> a -> OutputConstraint a b CmpInType :: Comparison -> a -> b -> b -> OutputConstraint a b CmpElim :: [Polarity] -> a -> [b] -> [b] -> OutputConstraint a b JustType :: b -> OutputConstraint a b CmpTypes :: Comparison -> b -> b -> OutputConstraint a b CmpLevels :: Comparison -> b -> b -> OutputConstraint a b CmpTeles :: Comparison -> b -> b -> OutputConstraint a b JustSort :: b -> OutputConstraint a b CmpSorts :: Comparison -> b -> b -> OutputConstraint a b Guard :: (OutputConstraint a b) -> ProblemId -> OutputConstraint a b Assign :: b -> a -> OutputConstraint a b TypedAssign :: b -> a -> a -> OutputConstraint a b PostponedCheckArgs :: b -> [a] -> a -> a -> OutputConstraint a b IsEmptyType :: a -> OutputConstraint a b SizeLtSat :: a -> OutputConstraint a b FindInScopeOF :: b -> a -> [(a, a)] -> OutputConstraint a b -- | A subset of OutputConstraint. data OutputConstraint' a b OfType' :: b -> a -> OutputConstraint' a b [ofName] :: OutputConstraint' a b -> b [ofExpr] :: OutputConstraint' a b -> a outputFormId :: OutputForm a b -> b showComparison :: Comparison -> String getConstraints :: TCM [OutputForm Expr Expr] -- | getSolvedInteractionPoints True returns all solutions, even -- if just solved by another, non-interaction meta. -- -- getSolvedInteractionPoints False only returns metas that are -- solved by a non-meta. getSolvedInteractionPoints :: Bool -> TCM [(InteractionId, MetaId, Expr)] typeOfMetaMI :: Rewrite -> MetaId -> TCM (OutputConstraint Expr NamedMeta) typeOfMeta :: Rewrite -> InteractionId -> TCM (OutputConstraint Expr InteractionId) typeOfMeta' :: Rewrite -> (InteractionId, MetaId) -> TCM (OutputConstraint Expr InteractionId) typesOfVisibleMetas :: Rewrite -> TCM [OutputConstraint Expr InteractionId] typesOfHiddenMetas :: Rewrite -> TCM [OutputConstraint Expr NamedMeta] metaHelperType :: Rewrite -> InteractionId -> Range -> String -> TCM (OutputConstraint' Expr Expr) contextOfMeta :: InteractionId -> Rewrite -> TCM [OutputConstraint' Expr Name] -- | Returns the type of the expression in the current environment We wake -- up irrelevant variables just in case the user want to invoke that -- command in an irrelevant context. typeInCurrent :: Rewrite -> Expr -> TCM Expr typeInMeta :: InteractionId -> Rewrite -> Expr -> TCM Expr withInteractionId :: InteractionId -> TCM a -> TCM a withMetaId :: MetaId -> TCM a -> TCM a introTactic :: Bool -> InteractionId -> TCM [String] -- | Runs the given computation as if in an anonymous goal at the end of -- the top-level module. -- -- Sets up current module, scope, and context. atTopLevel :: TCM a -> TCM a -- | Parse a name. parseName :: Range -> String -> TCM QName -- | Check whether an expression is a (qualified) identifier. isQName :: Expr -> Maybe QName -- | Returns the contents of the given module or record. moduleContents :: Rewrite -> Range -> String -> TCM ([Name], [(Name, Type)]) -- | Returns the contents of the given record identifier. getRecordContents :: Rewrite -> Expr -> TCM ([Name], [(Name, Type)]) -- | Returns the contents of the given module. getModuleContents :: Rewrite -> QName -> TCM ([Name], [(Name, Type)]) whyInScope :: String -> TCM (Maybe LocalVar, [AbstractName], [AbstractModule]) instance GHC.Base.Functor (Agda.Interaction.BasicOps.OutputForm a) instance GHC.Base.Functor (Agda.Interaction.BasicOps.OutputConstraint a) instance GHC.Read.Read Agda.Interaction.BasicOps.Rewrite instance Agda.Syntax.Translation.InternalToAbstract.Reify Agda.TypeChecking.Monad.Base.ProblemConstraint (Agda.TypeChecking.Monad.Base.Closure (Agda.Interaction.BasicOps.OutputForm Agda.Syntax.Abstract.Expr Agda.Syntax.Abstract.Expr)) instance Agda.Syntax.Translation.InternalToAbstract.Reify Agda.TypeChecking.Monad.Base.Constraint (Agda.Interaction.BasicOps.OutputConstraint Agda.Syntax.Abstract.Expr Agda.Syntax.Abstract.Expr) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Agda.Interaction.BasicOps.OutputForm a b) instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Agda.Interaction.BasicOps.OutputConstraint a b) instance (Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a c, Agda.Syntax.Translation.AbstractToConcrete.ToConcrete b d) => Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (Agda.Interaction.BasicOps.OutputForm a b) (Agda.Interaction.BasicOps.OutputForm c d) instance (Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a c, Agda.Syntax.Translation.AbstractToConcrete.ToConcrete b d) => Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (Agda.Interaction.BasicOps.OutputConstraint a b) (Agda.Interaction.BasicOps.OutputConstraint c d) instance (Agda.Utils.Pretty.Pretty a, Agda.Utils.Pretty.Pretty b) => Agda.Utils.Pretty.Pretty (Agda.Interaction.BasicOps.OutputConstraint' a b) instance (Agda.Syntax.Translation.AbstractToConcrete.ToConcrete a c, Agda.Syntax.Translation.AbstractToConcrete.ToConcrete b d) => Agda.Syntax.Translation.AbstractToConcrete.ToConcrete (Agda.Interaction.BasicOps.OutputConstraint' a b) (Agda.Interaction.BasicOps.OutputConstraint' c d) module Agda.Interaction.SearchAbout findMentions :: Rewrite -> Range -> String -> TCM [(Name, Type)] module Agda.Interaction.CommandLine data ExitCode a Continue :: ExitCode a ContinueIn :: TCEnv -> ExitCode a Return :: a -> ExitCode a type Command a = (String, [String] -> TCM (ExitCode a)) matchCommand :: String -> [Command a] -> Either [String] ([String] -> TCM (ExitCode a)) interaction :: String -> [Command a] -> (String -> TCM (ExitCode a)) -> IM a -- | The interaction loop. interactionLoop :: TCM (Maybe Interface) -> IM () continueAfter :: TCM a -> TCM (ExitCode b) -- | Set envCurrentPath to optInputFile. withCurrentFile :: TCM a -> TCM a loadFile :: TCM () -> [String] -> TCM () showConstraints :: [String] -> TCM () showMetas :: [String] -> TCM () showScope :: TCM () metaParseExpr :: InteractionId -> String -> TCM Expr actOnMeta :: [String] -> (InteractionId -> Expr -> TCM a) -> TCM a giveMeta :: [String] -> TCM () refineMeta :: [String] -> TCM () retryConstraints :: TCM () evalIn :: [String] -> TCM () parseExpr :: String -> TCM Expr evalTerm :: String -> TCM (ExitCode a) typeOf :: [String] -> TCM () typeIn :: [String] -> TCM () showContext :: [String] -> TCM () -- | The logo that prints when Agda is started in interactive mode. splashScreen :: String -- | The help message help :: [Command a] -> IO () -- | This module deals with finding imported modules and loading their -- interface files. module Agda.Interaction.Imports -- | Are we loading the interface for the user-loaded file or for an -- import? data MainInterface -- | Interface for main file. MainInterface :: MainInterface -- | Interface for imported file. NotMainInterface :: MainInterface -- | Merge an interface into the current proof state. mergeInterface :: Interface -> TCM () addImportedThings :: Signature -> BuiltinThings PrimFun -> Set String -> Set String -> PatternSynDefns -> DisplayForms -> TCM () -- | Scope checks the given module. A proper version of the module name -- (with correct definition sites) is returned. scopeCheckImport :: ModuleName -> TCM (ModuleName, Map ModuleName Scope) data MaybeWarnings NoWarnings :: MaybeWarnings SomeWarnings :: Warnings -> MaybeWarnings hasWarnings :: MaybeWarnings -> Bool -- | If the module has already been visited (without warnings), then its -- interface is returned directly. Otherwise the computation is used to -- find the interface and the computed interface is stored for potential -- later use. alreadyVisited :: TopLevelModuleName -> TCM (Interface, MaybeWarnings) -> TCM (Interface, MaybeWarnings) -- | Type checks the main file of the interaction. This could be the file -- loaded in the interacting editor (emacs), or the file passed on the -- command line. -- -- First, the primitive modules are imported. Then, -- getInterface' is called to do the main work. typeCheckMain :: AbsolutePath -> TCM (Interface, MaybeWarnings) -- | Tries to return the interface associated to the given (imported) -- module. The time stamp of the relevant interface file is also -- returned. Calls itself recursively for the imports of the given -- module. May type check the module. An error is raised if a warning is -- encountered. -- -- Do not use this for the main file, use typeCheckMain instead. getInterface :: ModuleName -> TCM Interface -- | See getInterface. getInterface_ :: TopLevelModuleName -> TCM Interface -- | A more precise variant of getInterface. If warnings are -- encountered then they are returned instead of being turned into -- errors. getInterface' :: TopLevelModuleName -> MainInterface -> TCM (Interface, MaybeWarnings) -- | Print the highlighting information contained in the given interface. highlightFromInterface :: Interface -> AbsolutePath -> TCM () readInterface :: FilePath -> TCM (Maybe Interface) -- | Writes the given interface to the given file. Returns the file's new -- modification time stamp, or Nothing if the write failed. writeInterface :: FilePath -> Interface -> TCM () removePrivates :: ScopeInfo -> ScopeInfo -- | Tries to type check a module and write out its interface. The function -- only writes out an interface file if it does not encounter any -- warnings. -- -- If appropriate this function writes out syntax highlighting -- information. createInterface :: AbsolutePath -> TopLevelModuleName -> TCM (Interface, MaybeWarnings) constructIScope :: Interface -> Interface -- | Builds an interface for the current module, which should already have -- been successfully type checked. buildInterface :: AbsolutePath -> TopLevelInfo -> HighlightingInfo -> Set String -> Set String -> [OptionsPragma] -> TCM Interface -- | Returns (iSourceHash, iFullHash) getInterfaceFileHashes :: FilePath -> TCM (Maybe (Hash, Hash)) moduleHash :: ModuleName -> TCM Hash -- | True if the first file is newer than the second file. If a file -- doesn't exist it is considered to be infinitely old. isNewerThan :: FilePath -> FilePath -> IO Bool instance GHC.Show.Show Agda.Interaction.Imports.MainInterface instance GHC.Classes.Eq Agda.Interaction.Imports.MainInterface module Agda.Compiler.Common data IsMain IsMain :: IsMain NotMain :: IsMain doCompile :: IsMain -> Interface -> (IsMain -> Interface -> TCM ()) -> TCM () setInterface :: Interface -> TCM () curIF :: TCM Interface curSig :: TCM Signature curMName :: TCM ModuleName curDefs :: TCM Definitions sortDefs :: Definitions -> [(QName, Definition)] sigMName :: Signature -> ModuleName compileDir :: TCM FilePath repl :: [String] -> String -> String -- | Copy pasted from MAlonzo.... Move somewhere else! conArityAndPars :: QName -> TCM (Nat, Nat) -- | Sets up the compilation environment. inCompilerEnv :: Interface -> TCM a -> TCM a topLevelModuleName :: ModuleName -> TCM ModuleName instance GHC.Classes.Eq Agda.Compiler.Common.IsMain module Agda.Compiler.MAlonzo.Misc curHsMod :: TCM ModuleName ihname :: String -> Nat -> Name unqhname :: String -> QName -> Name tlmodOf :: ModuleName -> TCM ModuleName xqual :: QName -> Name -> TCM QName xhqn :: String -> QName -> TCM QName hsName :: String -> QName conhqn :: QName -> TCM QName bltQual :: String -> String -> TCM QName dname :: QName -> Name -- | Name for definition stripped of unused arguments duname :: QName -> Name hsPrimOp :: String -> QOp hsPrimOpApp :: String -> Exp -> Exp -> Exp hsInt :: Integer -> Exp hsTypedInt :: Integer -> Exp hspLet :: Pat -> Exp -> Exp -> Exp hsLet :: Name -> Exp -> Exp -> Exp hsVarUQ :: Name -> Exp hsAppView :: Exp -> [Exp] hsOpToExp :: QOp -> Exp hsLambda :: [Pat] -> Exp -> Exp hsMapAlt :: (Exp -> Exp) -> Alt -> Alt hsMapRHS :: (Exp -> Exp) -> Rhs -> Rhs mazstr :: String mazName :: Name mazMod' :: String -> ModuleName mazMod :: ModuleName -> ModuleName mazerror :: String -> a mazCoerceName :: String mazErasedName :: String mazCoerce :: Exp mazIncompleteMatch :: Exp rtmIncompleteMatch :: QName -> Exp mazUnreachableError :: Exp rtmUnreachableError :: Exp mazRTE :: ModuleName rtmQual :: String -> QName rtmVar :: String -> Exp rtmError :: String -> Exp unsafeCoerceMod :: ModuleName fakeD :: Name -> String -> Decl fakeDS :: String -> String -> Decl fakeDQ :: QName -> String -> Decl fakeType :: String -> Type fakeExp :: String -> Exp fakeDecl :: String -> Decl dummy :: a emptyBinds :: Maybe Binds module Agda.Compiler.MAlonzo.Encode -- | Haskell module names have to satisfy the Haskell (including the -- hierarchical module namespace extension) lexical syntax: -- --
-- modid -> [modid.] large {small | large | digit | ' } ---- -- encodeModuleName is an injective function into the set of -- module names defined by modid. The function preserves -- .s, and it also preserves module names whose first name part -- is not mazstr. -- -- Precondition: The input must not start or end with ., and no -- two .s may be adjacent. encodeModuleName :: ModuleName -> ModuleName -- | All the properties. tests :: IO Bool instance GHC.Show.Show Agda.Compiler.MAlonzo.Encode.M instance Test.QuickCheck.Arbitrary.Arbitrary Agda.Compiler.MAlonzo.Encode.M module Agda.Compiler.MAlonzo.Pretty -- | Encodes module names just before pretty-printing. prettyPrint :: (Pretty a, TransformBi ModuleName (Wrap a)) => a -> String -- | A wrapper type used to avoid orphan instances. newtype Wrap a Wrap :: a -> Wrap a [unwrap] :: Wrap a -> a instance Data.Generics.Geniplate.TransformBi Language.Haskell.Exts.Syntax.ModuleName (Agda.Compiler.MAlonzo.Pretty.Wrap Language.Haskell.Exts.Syntax.QName) instance Data.Generics.Geniplate.TransformBi Language.Haskell.Exts.Syntax.ModuleName (Agda.Compiler.MAlonzo.Pretty.Wrap Language.Haskell.Exts.Syntax.ModuleName) instance Data.Generics.Geniplate.TransformBi Language.Haskell.Exts.Syntax.ModuleName (Agda.Compiler.MAlonzo.Pretty.Wrap Language.Haskell.Exts.Syntax.Module) instance Data.Generics.Geniplate.TransformBi Language.Haskell.Exts.Syntax.ModuleName (Agda.Compiler.MAlonzo.Pretty.Wrap Language.Haskell.Exts.Syntax.Exp) -- | Responsible for running all internal tests. module Agda.Tests testSuite :: IO Bool module Agda.Compiler.MAlonzo.Primitives -- | Check that the main function has type IO a, for some a. checkTypeOfMain :: QName -> Type -> TCM [Decl] -> TCM [Decl] importsForPrim :: TCM [ModuleName] xForPrim :: [(String, TCM [a])] -> TCM [a] primBody :: String -> TCM Exp noCheckCover :: QName -> TCM Bool pconName :: String -> TCM String bltQual' :: String -> String -> TCM String -- | Contains the state monad that the compiler works in and some functions -- for tampering with the state. module Agda.Compiler.UHC.CompileState -- | Compiler monad data CompileT m a type Compile = CompileT TCM -- | Used to run the Agda-to-UHC Core transformation. During this -- transformation, runCompileT :: MonadIO m => ModuleName -> CompileT m a -> m a data CoreMeta addExports :: Monad m => [HsName] -> CompileT m () addMetaCon :: QName -> CDataCon -> Compile () addMetaData :: QName -> ([CDataCon] -> CDeclMeta) -> Compile () getExports :: Compile [CExport] getDeclMetas :: Compile [CDeclMeta] getCoreName :: QName -> Compile HsName getCoreName1 :: QName -> TCM HsName -- | Returns the CTag for a constructor. Not defined for Sharp and magic -- UNIT constructor. getConstrCTag :: QName -> Compile CTag -- | Returns the expression to use to build a value of the given -- datatype/constructor. getConstrFun :: QName -> Compile HsName moduleNameToCoreName :: ModuleName -> HsName moduleNameToCoreNameParts :: ModuleName -> [String] freshLocalName :: Monad m => CompileT m HsName -- | Copy pasted from MAlonzo.... Move somewhere else! conArityAndPars :: QName -> TCM (Nat, Nat) dataRecCons :: Defn -> [QName] instance GHC.Base.Functor m => GHC.Base.Functor (Agda.Compiler.UHC.CompileState.CompileT m) instance GHC.Base.Monad m => GHC.Base.Applicative (Agda.Compiler.UHC.CompileState.CompileT m) instance Control.Monad.Trans.Class.MonadTrans Agda.Compiler.UHC.CompileState.CompileT instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Agda.Compiler.UHC.CompileState.CompileT m) instance GHC.Base.Monad m => GHC.Base.Monad (Agda.Compiler.UHC.CompileState.CompileT m) instance GHC.Base.Monoid Agda.Compiler.UHC.CompileState.CoreMeta instance Control.Monad.Reader.Class.MonadReader r m => Control.Monad.Reader.Class.MonadReader r (Agda.Compiler.UHC.CompileState.CompileT m) instance Control.Monad.State.Class.MonadState s m => Control.Monad.State.Class.MonadState s (Agda.Compiler.UHC.CompileState.CompileT m) instance Agda.TypeChecking.Monad.Base.MonadTCM m => Agda.TypeChecking.Monad.Base.MonadTCM (Agda.Compiler.UHC.CompileState.CompileT m) -- | Defines some primitive functions. module Agda.Compiler.UHC.Primitives primFunNm :: String -> HsName -- | Primitives defined for the UHC backend. Maps primitive names to the -- core expression to be used as function body. primFunctions :: Map String ((CompileT TCM) CExpr) -- | Convert from Agda's internal representation to UHC Core via Treeless. -- -- The coinduction kit is translated the same way as in MAlonzo: flat = -- id sharp = id -> There is no runtime representation of Coinductive -- values. module Agda.Compiler.UHC.FromAgda opts :: EHCOpts -- | Convert from Agda's internal representation to our auxiliary AST. fromAgdaModule :: ModuleName -> [ModuleName] -> Interface -> TCM CModule -- | Translate an Agda definition to an UHC Core function where applicable translateDefn :: (QName, Definition) -> Compile [CBind] runTT :: TT a -> Compile a data TTEnv TTEnv :: [HsName] -> TTEnv [nmEnv] :: TTEnv -> [HsName] type TT = ReaderT TTEnv Compile addToEnv :: [HsName] -> TT a -> TT a data BuiltinKit BuiltinKit :: (QName -> Bool) -> (QName -> Bool) -> BuiltinKit [isNat] :: BuiltinKit -> QName -> Bool [isInt] :: BuiltinKit -> QName -> Bool builtinKit :: TCM BuiltinKit -- | Translate the actual Agda terms, with an environment of all the bound -- variables from patternmatching. Agda terms are in de Bruijn so we just -- check the new names in the position. compileTerm :: TTerm -> TT CExpr buildPrimCases :: CExpr -> CExpr -> [TAlt] -> CExpr -> TT CExpr mkIfThenElse :: CExpr -> CExpr -> CExpr -> CExpr compileConAlt :: TAlt -> TT CAlt makeConAlt :: QName -> ([HsName] -> TT CExpr) -> TT CAlt -- | Constructs an alternative for all constructors not explicitly matched -- by a branch. defaultBranches :: QName -> [TAlt] -> CExpr -> TT [CAlt] litToCore :: Literal -> CExpr getCTagArity :: CTag -> Int coreError :: String -> CExpr compilePrim :: TPrim -> CExpr createMainModule :: ModuleName -> HsName -> CModule -- | Epic compiler backend. module Agda.Compiler.Epic.Compiler -- | Compile an interface into an executable using Epic compilerMain :: Interface -> TCM () module Agda.Compiler.JS.Compiler compilerMain :: Interface -> TCM () compile :: Interface -> TCM () prefix :: [Char] jsMod :: ModuleName -> GlobalId jsFileName :: GlobalId -> String jsMember :: Name -> MemberId global' :: QName -> TCM (Exp, [MemberId]) global :: QName -> TCM (Exp, [MemberId]) reorder :: [Export] -> [Export] reorder' :: Set [MemberId] -> [Export] -> [Export] isTopLevelValue :: Export -> Bool isEmptyObject :: Export -> Bool insertAfter :: Set [MemberId] -> Export -> [Export] -> [Export] curModule :: TCM Module definition :: (QName, Definition) -> TCM Export defn :: QName -> [MemberId] -> Type -> Maybe JSCode -> Defn -> TCM Exp numPars :: [Clause] -> Nat clause :: Clause -> TCM Case mapping :: [Pattern] -> (Nat, Nat, [Exp]) mapping' :: Pattern -> (Nat, Nat, [Exp]) -> (Nat, Nat, [Exp]) pattern :: Pattern -> TCM Patt tag :: QName -> TCM Tag visitorName :: QName -> TCM MemberId body :: ClauseBody -> TCM Exp term :: Term -> TCM Exp isSingleton :: Type -> TCM (Maybe Exp) args :: Int -> Args -> TCM [Exp] qname :: QName -> TCM Exp literal :: Literal -> Exp dummyLambda :: Int -> Exp -> Exp writeModule :: Module -> TCM () compileDir :: TCM FilePath outFile :: GlobalId -> TCM FilePath outFile_ :: TCM FilePath module Agda.Compiler.MAlonzo.Compiler compilerMain :: IsMain -> Interface -> TCM () compile :: Interface -> TCM () imports :: TCM [ImportDecl] definitions :: Definitions -> TCM [Decl] -- | Note that the INFINITY, SHARP and FLAT builtins are translated as -- follows (if a CoinductionKit is given): -- --
-- type Infinity a b = b -- -- sharp :: a -> a -- sharp x = x -- -- flat :: a -> a -- flat x = x --definition :: Maybe CoinductionKit -> Definition -> TCM [Decl] -- | Environment for naming of local variables. Invariant: reverse -- ccCxt ++ ccNameSupply data CCEnv CCEnv :: NameSupply -> CCContext -> CCEnv -- | Supply of fresh names [ccNameSupply] :: CCEnv -> NameSupply -- | Names currently in scope [ccCxt] :: CCEnv -> CCContext type NameSupply = [Name] type CCContext = [Name] mapNameSupply :: (NameSupply -> NameSupply) -> CCEnv -> CCEnv mapContext :: (CCContext -> CCContext) -> CCEnv -> CCEnv -- | Initial environment for expression generation. initCCEnv :: CCEnv -- | Term variables are de Bruijn indices. lookupIndex :: Int -> CCContext -> Name type CC = ReaderT CCEnv TCM freshNames :: Int -> ([Name] -> CC a) -> CC a -- | Introduce n variables into the context. intros :: Int -> ([Name] -> CC a) -> CC a checkConstructorType :: QName -> TCM [Decl] checkCover :: QName -> HaskellType -> Nat -> [QName] -> TCM [Decl] closedTerm :: TTerm -> TCM Exp -- | Extract Agda term to Haskell expression. Erased arguments are -- extracted as (). Types are extracted as (). term :: TTerm -> CC Exp compilePrim :: TPrim -> Exp alt :: Int -> TAlt -> CC Alt literal :: Literal -> TCM Exp hslit :: Literal -> Literal litString :: String -> Exp litqname :: QName -> Exp litqnamepat :: QName -> Pat condecl :: QName -> TCM (Nat, ConDecl) cdecl :: QName -> Nat -> ConDecl tvaldecl :: QName -> Induction -> Nat -> Nat -> [ConDecl] -> Maybe Clause -> [Decl] infodecl :: QName -> [Decl] -> [Decl] hsCast :: Exp -> Exp hsCast' :: Exp -> Exp hsCastApp :: Exp -> Exp hsCoerce :: Exp -> Exp copyRTEModules :: TCM () writeModule :: Module -> TCM () outFile' :: (Pretty a, TransformBi ModuleName (Wrap a)) => a -> TCM (FilePath, FilePath) outFile :: ModuleName -> TCM FilePath outFile_ :: TCM FilePath callGHC :: IsMain -> Interface -> TCM () -- | UHC compiler backend, main entry point. module Agda.Compiler.UHC.Compiler -- | Compile an interface into an executable using UHC compilerMain :: IsMain -> Interface -> TCM () module Agda.Interaction.MakeCase type CaseContext = Maybe ExtLamInfo -- | Find the clause whose right hand side is the given meta BY SEARCHING -- THE WHOLE SIGNATURE. Returns the original clause, before record -- patterns have been translated away. Raises an error if there is no -- matching clause. -- -- Andreas, 2010-09-21: This looks like a SUPER UGLY HACK to me. You are -- walking through the WHOLE signature to find an information you have -- thrown away earlier. (shutter with disgust). This code fails for -- record rhs because they have been eta-expanded, so the MVar is gone. findClause :: MetaId -> TCM (CaseContext, QName, Clause) -- | Parse variables (visible or hidden), returning their de Bruijn -- indices. Used in makeCase. parseVariables :: InteractionId -> Range -> [String] -> TCM [Int] -- | Entry point for case splitting tactic. makeCase :: InteractionId -> Range -> String -> TCM (CaseContext, [Clause]) makeAbsurdClause :: QName -> SplitClause -> TCM Clause -- | Make a clause with a question mark as rhs. makeAbstractClause :: QName -> SplitClause -> TCM Clause deBruijnIndex :: Expr -> TCM Nat module Agda.Auto.NarrowingSearch type Prio = Int class Trav a blk | a -> blk trav :: (Trav a blk, Monad m) => (forall b. Trav b blk => MM b blk -> m ()) -> a -> m () data Term blk Term :: a -> Term blk -- | Result of type-checking. data Prop blk -- | Success. OK :: Prop blk -- | Definite failure. Error :: String -> Prop blk -- | Experimental. AddExtraRef :: String -> (Metavar a blk) -> (Int, RefCreateEnv blk a) -> Prop blk -- | Parallel conjunction of constraints. And :: (Maybe [Term blk]) -> (MetaEnv (PB blk)) -> (MetaEnv (PB blk)) -> Prop blk -- | Experimental, related to mcompoint. First arg is sidecondition. Sidecondition :: (MetaEnv (PB blk)) -> (MetaEnv (PB blk)) -> Prop blk -- | Forking proof on something that is not part of the term language. E.g. -- whether a term will reduce or not. Or :: Prio -> (MetaEnv (PB blk)) -> (MetaEnv (PB blk)) -> Prop blk -- | Obsolete. ConnectHandle :: (OKHandle blk) -> (MetaEnv (PB blk)) -> Prop blk data OKVal OKVal :: OKVal type OKHandle blk = MM OKVal blk type OKMeta blk = Metavar OKVal blk -- | Agsy's meta variables. -- -- a the type of the metavariable (what it can be instantiated -- with). blk the search control information (e.g. the scope of -- the meta). data Metavar a blk Metavar :: IORef (Maybe a) -> IORef Bool -> IORef [(QPB a blk, Maybe (CTree blk))] -> IORef [SubConstraints blk] -> IORef [(Int, RefCreateEnv blk a)] -> Metavar a blk -- | Maybe an instantiation (refinement). It is usually shallow, i.e., just -- one construct(or) with arguments again being metas. [mbind] :: Metavar a blk -> IORef (Maybe a) -- | Does this meta block a principal constraint (i.e., a type-checking -- constraint). [mprincipalpresent] :: Metavar a blk -> IORef Bool -- | List of observers, i.e., constraints blocked by this meta. [mobs] :: Metavar a blk -> IORef [(QPB a blk, Maybe (CTree blk))] -- | Used for experiments with independence of subproofs. [mcompoint] :: Metavar a blk -> IORef [SubConstraints blk] -- | Experimental. [mextrarefs] :: Metavar a blk -> IORef [(Int, RefCreateEnv blk a)] hequalMetavar :: Metavar a1 blk1 -> Metavar a2 bkl2 -> Bool newMeta :: IORef [SubConstraints blk] -> IO (Metavar a blk) initMeta :: IO (Metavar a blk) data CTree blk CTree :: IORef (PrioMeta blk) -> IORef (Maybe (SubConstraints blk)) -> IORef (Maybe (CTree blk)) -> IORef [OKMeta blk] -> CTree blk [ctpriometa] :: CTree blk -> IORef (PrioMeta blk) [ctsub] :: CTree blk -> IORef (Maybe (SubConstraints blk)) [ctparent] :: CTree blk -> IORef (Maybe (CTree blk)) [cthandles] :: CTree blk -> IORef [OKMeta blk] data SubConstraints blk SubConstraints :: IORef Bool -> IORef Int -> CTree blk -> CTree blk -> SubConstraints blk [scflip] :: SubConstraints blk -> IORef Bool [sccomcount] :: SubConstraints blk -> IORef Int [scsub1] :: SubConstraints blk -> CTree blk [scsub2] :: SubConstraints blk -> CTree blk newCTree :: Maybe (CTree blk) -> IO (CTree blk) newSubConstraints :: CTree blk -> IO (SubConstraints blk) data PrioMeta blk PrioMeta :: Prio -> (Metavar a blk) -> PrioMeta blk NoPrio :: Bool -> PrioMeta blk data Restore Restore :: (IORef a) -> a -> Restore type Undo = StateT [Restore] IO ureadIORef :: IORef a -> Undo a uwriteIORef :: IORef a -> a -> Undo () umodifyIORef :: IORef a -> (a -> a) -> Undo () ureadmodifyIORef :: IORef a -> (a -> a) -> Undo a runUndo :: Undo a -> IO a type RefCreateEnv blk = StateT (IORef [SubConstraints blk], Int) IO data Pair a b Pair :: a -> b -> Pair a b class Refinable a blk refinements :: Refinable a blk => blk -> [blk] -> Metavar a blk -> IO [(Int, RefCreateEnv blk a)] newPlaceholder :: RefCreateEnv blk (MM a blk) newOKHandle :: RefCreateEnv blk (OKHandle blk) dryInstantiate :: RefCreateEnv blk a -> IO a type BlkInfo blk = (Bool, Prio, Maybe blk) data MM a blk NotM :: a -> MM a blk Meta :: (Metavar a blk) -> MM a blk type MetaEnv = IO data MB a blk NotB :: a -> MB a blk Blocked :: (Metavar b blk) -> (MetaEnv (MB a blk)) -> MB a blk Failed :: String -> MB a blk data PB blk NotPB :: (Prop blk) -> PB blk PBlocked :: (Metavar b blk) -> (BlkInfo blk) -> (MetaEnv (PB blk)) -> PB blk PDoubleBlocked :: (Metavar b1 blk) -> (Metavar b2 blk) -> (MetaEnv (PB blk)) -> PB blk data QPB b blk QPBlocked :: (BlkInfo blk) -> (MetaEnv (PB blk)) -> QPB b blk QPDoubleBlocked :: (IORef Bool) -> (MetaEnv (PB blk)) -> QPB b blk mmcase :: Refinable a blk => MM a blk -> (a -> MetaEnv (MB b blk)) -> MetaEnv (MB b blk) mmmcase :: MM a blk -> MetaEnv (MB b blk) -> (a -> MetaEnv (MB b blk)) -> MetaEnv (MB b blk) mmpcase :: Refinable a blk => BlkInfo blk -> MM a blk -> (a -> MetaEnv (PB blk)) -> MetaEnv (PB blk) doubleblock :: (Refinable a blk, Refinable b blk) => MM a blk -> MM b blk -> MetaEnv (PB blk) -> MetaEnv (PB blk) mbcase :: MetaEnv (MB a blk) -> (a -> MetaEnv (MB b blk)) -> MetaEnv (MB b blk) mbpcase :: Prio -> Maybe blk -> MetaEnv (MB a blk) -> (a -> MetaEnv (PB blk)) -> MetaEnv (PB blk) mmbpcase :: MetaEnv (MB a blk) -> (forall b. Refinable b blk => MM b blk -> MetaEnv (PB blk)) -> (a -> MetaEnv (PB blk)) -> MetaEnv (PB blk) waitok :: OKHandle blk -> MetaEnv (MB b blk) -> MetaEnv (MB b blk) mbret :: a -> MetaEnv (MB a blk) mbfailed :: String -> MetaEnv (MB a blk) mpret :: Prop blk -> MetaEnv (PB blk) expandbind :: MM a blk -> MetaEnv (MM a blk) type HandleSol = IO () type SRes = Either Bool Int topSearch :: forall blk. IORef Int -> IORef Int -> HandleSol -> blk -> MetaEnv (PB blk) -> Int -> Int -> IO Bool extractblkinfos :: Metavar a blk -> IO [blk] recalcs :: [(QPB a blk, Maybe (CTree blk))] -> Undo Bool seqc :: Undo Bool -> Undo Bool -> Undo Bool recalc :: (QPB a blk, Maybe (CTree blk)) -> Undo Bool reccalc :: MetaEnv (PB blk) -> Maybe (CTree blk) -> Undo Bool calc :: forall blk. MetaEnv (PB blk) -> Maybe (CTree blk) -> Undo (Maybe [OKMeta blk]) choosePrioMeta :: Bool -> PrioMeta blk -> PrioMeta blk -> PrioMeta blk propagatePrio :: CTree blk -> Undo [OKMeta blk] data Choice LeftDisjunct :: Choice RightDisjunct :: Choice choose :: MM Choice blk -> Prio -> MetaEnv (PB blk) -> MetaEnv (PB blk) -> MetaEnv (PB blk) instance Agda.Auto.NarrowingSearch.Trav a blk => Agda.Auto.NarrowingSearch.Trav (Agda.Auto.NarrowingSearch.MM a blk) blk instance GHC.Classes.Eq (Agda.Auto.NarrowingSearch.Metavar a blk) instance GHC.Classes.Eq (Agda.Auto.NarrowingSearch.PrioMeta blk) instance Agda.Auto.NarrowingSearch.Refinable Agda.Auto.NarrowingSearch.Choice blk instance Agda.Auto.NarrowingSearch.Refinable Agda.Auto.NarrowingSearch.OKVal blk module Agda.Auto.Syntax -- | Unique identifiers for variable occurrences in unification. type UId o = Metavar (Exp o) (RefInfo o) data HintMode HMNormal :: HintMode HMRecCall :: HintMode data EqReasoningConsts o EqReasoningConsts :: ConstRef o -> EqReasoningConsts o [eqrcId, eqrcBegin, eqrcStep, eqrcEnd, eqrcSym, eqrcCong] :: EqReasoningConsts o -> ConstRef o data EqReasoningState EqRSNone :: EqReasoningState EqRSChain :: EqReasoningState EqRSPrf1 :: EqReasoningState EqRSPrf2 :: EqReasoningState EqRSPrf3 :: EqReasoningState -- | The concrete instance of the blk parameter in Metavar. -- I.e., the information passed to the search control. data RefInfo o RIEnv :: [(ConstRef o, HintMode)] -> Nat -> Maybe (EqReasoningConsts o) -> RefInfo o [rieHints] :: RefInfo o -> [(ConstRef o, HintMode)] -- | Nat - deffreevars (to make cost of using module parameters correspond -- to that of hints). [rieDefFreeVars] :: RefInfo o -> Nat [rieEqReasoningConsts] :: RefInfo o -> Maybe (EqReasoningConsts o) RIMainInfo :: Nat -> HNExp o -> Bool -> RefInfo o -- | Size of typing context in which meta was created. [riMainCxtLength] :: RefInfo o -> Nat -- | Head normal form of type of meta. [riMainType] :: RefInfo o -> HNExp o -- | True if iota steps performed when normalising target type (used to put -- cost when traversing a definition by construction instantiation). [riMainIota] :: RefInfo o -> Bool RIUnifInfo :: [CAction o] -> (HNExp o) -> RefInfo o RICopyInfo :: (ICExp o) -> RefInfo o RIIotaStep :: Bool -> RefInfo o RIInferredTypeUnknown :: RefInfo o RINotConstructor :: RefInfo o RIUsedVars :: [UId o] -> [Elr o] -> RefInfo o RIPickSubsvar :: RefInfo o RIEqRState :: EqReasoningState -> RefInfo o RICheckElim :: Bool -> RefInfo o RICheckProjIndex :: [ConstRef o] -> RefInfo o type MyPB o = PB (RefInfo o) type MyMB a o = MB a (RefInfo o) type Nat = Int -- | Hiding in Agda. data FMode Hidden :: FMode Instance :: FMode NotHidden :: FMode data MId Id :: String -> MId NoId :: MId stringToMyId :: String -> MId -- | Abstraction with maybe a name. -- -- Different from Agda, where there is also info whether function is -- constant. data Abs a Abs :: MId -> a -> Abs a -- | Constant signatures. data ConstDef o ConstDef :: String -> o -> MExp o -> DeclCont o -> Nat -> ConstDef o -- | For debug printing. [cdname] :: ConstDef o -> String -- | Reference to the Agda constant. [cdorigin] :: ConstDef o -> o -- | Type of constant. [cdtype] :: ConstDef o -> MExp o -- | Constant definition. [cdcont] :: ConstDef o -> DeclCont o -- | Free vars of the module where the constant is defined.. [cddeffreevars] :: ConstDef o -> Nat -- | Constant definitions. data DeclCont o Def :: Nat -> [Clause o] -> (Maybe Nat) -> (Maybe Nat) -> DeclCont o Datatype :: [ConstRef o] -> [ConstRef o] -> DeclCont o Constructor :: Nat -> DeclCont o Postulate :: DeclCont o type Clause o = ([Pat o], MExp o) data Pat o PatConApp :: (ConstRef o) -> [Pat o] -> Pat o PatVar :: String -> Pat o -- | Dot pattern. PatExp :: Pat o type ConstRef o = IORef (ConstDef o) -- | Head of application (elimination). data Elr o Var :: Nat -> Elr o Const :: (ConstRef o) -> Elr o data Sort Set :: Nat -> Sort UnknownSort :: Sort Type :: Sort -- | Agsy's internal syntax. data Exp o App :: Maybe (UId o) -> OKHandle (RefInfo o) -> Elr o -> MArgList o -> Exp o -- | Unique identifier of the head. [appUId] :: Exp o -> Maybe (UId o) -- | This application has been type-checked. [appOK] :: Exp o -> OKHandle (RefInfo o) -- | Head. [appHead] :: Exp o -> Elr o -- | Arguments. [appElims] :: Exp o -> MArgList o -- | Lambda with hiding information. Lam :: FMode -> (Abs (MExp o)) -> Exp o -- | True if possibly dependent (var not known to not occur). -- False if non-dependent. Pi :: (Maybe (UId o)) -> FMode -> Bool -> (MExp o) -> (Abs (MExp o)) -> Exp o Sort :: Sort -> Exp o -- | Absurd lambda with hiding information. AbsurdLambda :: FMode -> Exp o dontCare :: Exp o -- | "Maybe expression": Expression or reference to meta variable. type MExp o = MM (Exp o) (RefInfo o) data ArgList o -- | No more eliminations. ALNil :: ArgList o -- | Application and tail. ALCons :: FMode -> (MExp o) -> (MArgList o) -> ArgList o -- | proj pre args, projfcn idx, tail ALProj :: (MArgList o) -> (MM (ConstRef o) (RefInfo o)) -> FMode -> (MArgList o) -> ArgList o -- | Constructor parameter (missing in Agda). Agsy has monomorphic -- constructors. Inserted to cover glitch of polymorphic constructor -- applications coming from Agda ALConPar :: (MArgList o) -> ArgList o type MArgList o = MM (ArgList o) (RefInfo o) data HNExp o HNApp :: [Maybe (UId o)] -> (Elr o) -> (ICArgList o) -> HNExp o HNLam :: [Maybe (UId o)] -> FMode -> (Abs (ICExp o)) -> HNExp o HNPi :: [Maybe (UId o)] -> FMode -> Bool -> (ICExp o) -> (Abs (ICExp o)) -> HNExp o HNSort :: Sort -> HNExp o -- | Head-normal form of ICArgList. First entry is exposed. -- -- Q: Why are there no projection eliminations? data HNArgList o HNALNil :: HNArgList o HNALCons :: FMode -> (ICExp o) -> (ICArgList o) -> HNArgList o HNALConPar :: (ICArgList o) -> HNArgList o -- | Lazy concatenation of argument lists under explicit substitutions. data ICArgList o CALNil :: ICArgList o CALConcat :: (Clos (MArgList o) o) -> (ICArgList o) -> ICArgList o -- | An expression a in an explicit substitution [CAction -- a]. type ICExp o = Clos (MExp o) o data Clos a o Clos :: [CAction o] -> a -> Clos a o type CExp o = TrBr (ICExp o) o data TrBr a o TrBr :: [MExp o] -> a -> TrBr a o -- | Entry of an explicit substitution. -- -- An explicit substitution is a list of CActions. This is -- isomorphic to the usual presentation where Skip and -- Weak would be constructors of exp. substs. data CAction o -- | Instantation of variable. Sub :: (ICExp o) -> CAction o -- | For going under a binder, often called Lift. Skip :: CAction o -- | Shifting substitution (going to a larger context). Weak :: Nat -> CAction o type Ctx o = [(MId, CExp o)] type EE = IO detecteliminand :: [Clause o] -> Maybe Nat detectsemiflex :: ConstRef o -> [Clause o] -> IO Bool categorizedecl :: ConstRef o -> IO () metaliseokh :: MExp o -> IO (MExp o) expandExp :: MExp o -> IO (MExp o) addtrailingargs :: Clos (MArgList o) o -> ICArgList o -> ICArgList o closify :: MExp o -> CExp o sub :: MExp o -> CExp o -> CExp o subi :: MExp o -> ICExp o -> ICExp o weak :: Nat -> CExp o -> CExp o weaki :: Nat -> Clos a o -> Clos a o weakarglist :: Nat -> ICArgList o -> ICArgList o weakelr :: Nat -> Elr o -> Elr o -- | Substituting for a variable. doclos :: [CAction o] -> Nat -> Either Nat (ICExp o) instance GHC.Classes.Eq Agda.Auto.Syntax.FMode instance GHC.Show.Show Agda.Auto.Syntax.EqReasoningState instance GHC.Classes.Eq Agda.Auto.Syntax.EqReasoningState module Agda.Auto.SearchControl data ExpRefInfo o ExpRefInfo :: Maybe (RefInfo o) -> [RefInfo o] -> Bool -> Maybe ([UId o], [Elr o]) -> Maybe Bool -> Bool -> Maybe EqReasoningState -> ExpRefInfo o [eriMain] :: ExpRefInfo o -> Maybe (RefInfo o) [eriUnifs] :: ExpRefInfo o -> [RefInfo o] [eriInfTypeUnknown, eriIsEliminand] :: ExpRefInfo o -> Bool [eriUsedVars] :: ExpRefInfo o -> Maybe ([UId o], [Elr o]) [eriIotaStep] :: ExpRefInfo o -> Maybe Bool [eriPickSubsVar] :: ExpRefInfo o -> Bool [eriEqRState] :: ExpRefInfo o -> Maybe EqReasoningState getinfo :: [RefInfo o] -> ExpRefInfo o univar :: [CAction o] -> Nat -> Maybe Nat subsvars :: [CAction o] -> [Nat] extraref :: UId o -> [Maybe (UId o)] -> ConstRef o -> (Int, StateT (IORef [SubConstraints (RefInfo o)], Int) IO (Exp o)) costIncrease :: Int costUnificationOccurs :: Int costUnification :: Int costAppVar :: Int costAppVarUsed :: Int costAppHint :: Int costAppHintUsed :: Int costAppRecCall :: Int costAppRecCallUsed :: Int costAppConstructor :: Int costAppConstructorSingle :: Int costAppExtraRef :: Int costLam :: Int costLamUnfold :: Int costPi :: Int costSort :: Int costIotaStep :: Int costInferredTypeUnkown :: Int costAbsurdLam :: Int costEqStep :: Int costEqEnd :: Int costEqSym :: Int costEqCong :: Int prioNo :: Int prioTypeUnknown :: Int prioTypecheckArgList :: Int prioInferredTypeUnknown :: Int prioCompBeta :: Int prioCompBetaStructured :: Int prioCompareArgList :: Int prioCompIota :: Int prioCompChoice :: Int prioCompUnif :: Int prioCompCopy :: Int prioNoIota :: Int prioAbsurdLambda :: Int prioProjIndex :: Int prioTypecheck :: Bool -> Int instance Agda.Auto.NarrowingSearch.Refinable (Agda.Auto.Syntax.ArgList o) (Agda.Auto.Syntax.RefInfo o) instance Agda.Auto.NarrowingSearch.Refinable (Agda.Auto.Syntax.Exp o) (Agda.Auto.Syntax.RefInfo o) instance Agda.Auto.NarrowingSearch.Refinable (Agda.Auto.Syntax.ICExp o) (Agda.Auto.Syntax.RefInfo o) instance Agda.Auto.NarrowingSearch.Refinable (Agda.Auto.Syntax.ConstRef o) (Agda.Auto.Syntax.RefInfo o) instance Agda.Auto.NarrowingSearch.Trav a blk => Agda.Auto.NarrowingSearch.Trav [a] blk instance Agda.Auto.NarrowingSearch.Trav (Agda.Auto.Syntax.MId, Agda.Auto.Syntax.CExp o) (Agda.Auto.Syntax.RefInfo o) instance Agda.Auto.NarrowingSearch.Trav (Agda.Auto.Syntax.TrBr a o) (Agda.Auto.Syntax.RefInfo o) instance Agda.Auto.NarrowingSearch.Trav (Agda.Auto.Syntax.Exp o) (Agda.Auto.Syntax.RefInfo o) instance Agda.Auto.NarrowingSearch.Trav (Agda.Auto.Syntax.ArgList o) (Agda.Auto.Syntax.RefInfo o) module Agda.Auto.Typecheck -- | Typechecker drives the solution of metas. tcExp :: Bool -> Ctx o -> CExp o -> MExp o -> EE (MyPB o) getDatatype :: ICExp o -> EE (MyMB (Maybe (ICArgList o, [ConstRef o])) o) constructorImpossible :: ICArgList o -> ConstRef o -> EE (MyPB o) unequals :: ICArgList o -> ICArgList o -> ([(Nat, HNExp o)] -> EE (MyPB o)) -> [(Nat, HNExp o)] -> EE (MyPB o) unequal :: ICExp o -> ICExp o -> ([(Nat, HNExp o)] -> EE (MyPB o)) -> [(Nat, HNExp o)] -> EE (MyPB o) traversePi :: Int -> ICExp o -> EE (MyMB (HNExp o) o) tcargs :: Nat -> Bool -> Ctx o -> CExp o -> MArgList o -> MExp o -> Bool -> (CExp o -> MExp o -> EE (MyPB o)) -> EE (MyPB o) addend :: FMode -> MExp o -> MM (Exp o) blk -> MM (Exp o) blk copyarg :: MExp o -> Bool type HNNBlks o = [HNExp o] noblks :: HNNBlks o addblk :: HNExp o -> HNNBlks o -> HNNBlks o hnn :: ICExp o -> EE (MyMB (HNExp o) o) hnn_blks :: ICExp o -> EE (MyMB (HNExp o, HNNBlks o) o) hnn_checkstep :: ICExp o -> EE (MyMB (HNExp o, Bool) o) hnn' :: ICExp o -> ICArgList o -> EE (MyMB (HNExp o, HNNBlks o) o) hnb :: ICExp o -> ICArgList o -> EE (MyMB (HNExp o) o) data HNRes o HNDone :: (Maybe (Metavar (Exp o) (RefInfo o))) -> (HNExp o) -> HNRes o HNMeta :: (ICExp o) -> (ICArgList o) -> [Maybe (UId o)] -> HNRes o hnc :: Bool -> ICExp o -> ICArgList o -> [Maybe (UId o)] -> EE (MyMB (HNRes o) o) hnarglist :: ICArgList o -> EE (MyMB (HNArgList o) o) getNArgs :: Nat -> ICArgList o -> EE (MyMB (Maybe ([ICExp o], ICArgList o)) o) getAllArgs :: ICArgList o -> EE (MyMB [ICExp o] o) data PEval o PENo :: (ICExp o) -> PEval o PEConApp :: (ICExp o) -> (ConstRef o) -> [PEval o] -> PEval o iotastep :: Bool -> HNExp o -> EE (MyMB (Either (ICExp o, ICArgList o) (HNNBlks o)) o) noiotastep :: HNExp o -> EE (MyPB o) noiotastep_term :: ConstRef o -> MArgList o -> EE (MyPB o) data CMode o CMRigid :: (Maybe (Metavar (Exp o) (RefInfo o))) -> (HNExp o) -> CMode o CMFlex :: (MM b (RefInfo o)) -> (CMFlex o) -> CMode o data CMFlex o CMFFlex :: (ICExp o) -> (ICArgList o) -> [Maybe (UId o)] -> CMFlex o CMFSemi :: (Maybe (Metavar (Exp o) (RefInfo o))) -> (HNExp o) -> CMFlex o CMFBlocked :: (Maybe (Metavar (Exp o) (RefInfo o))) -> (HNExp o) -> CMFlex o comp' :: forall o. Bool -> CExp o -> CExp o -> EE (MyPB o) checkeliminand :: MExp o -> EE (MyPB o) maybeor :: Bool -> Int -> IO (PB (RefInfo o)) -> IO (PB (RefInfo o)) -> IO (PB (RefInfo o)) iotapossmeta :: ICExp o -> ICArgList o -> EE Bool meta_not_constructor :: ICExp o -> EE (MB Bool (RefInfo o)) calcEqRState :: EqReasoningConsts o -> MExp o -> EE (MyPB o) pickid :: MId -> MId -> MId tcSearch :: Bool -> Ctx o -> CExp o -> MExp o -> EE (MyPB o) module Agda.Auto.CaseSplit abspatvarname :: String costCaseSplitVeryHigh :: Nat costCaseSplitHigh :: Nat costCaseSplitLow :: Nat costAddVarDepth :: Nat data HI a HI :: FMode -> a -> HI a drophid :: [HI a] -> [a] type CSPat o = HI (CSPatI o) type CSCtx o = [HI (MId, MExp o)] data CSPatI o CSPatConApp :: (ConstRef o) -> [CSPat o] -> CSPatI o CSPatVar :: Nat -> CSPatI o CSPatExp :: (MExp o) -> CSPatI o CSWith :: (MExp o) -> CSPatI o CSAbsurd :: CSPatI o CSOmittedArg :: CSPatI o type Sol o = [(CSCtx o, [CSPat o], Maybe (MExp o))] caseSplitSearch :: forall o. IORef Int -> Int -> [ConstRef o] -> Maybe (EqReasoningConsts o) -> Int -> Int -> ConstRef o -> CSCtx o -> MExp o -> [CSPat o] -> IO [Sol o] caseSplitSearch' :: forall o. (Int -> CSCtx o -> MExp o -> ([Nat], Nat, [Nat]) -> IO (Maybe (MExp o))) -> Int -> Int -> ConstRef o -> CSCtx o -> MExp o -> [CSPat o] -> IO [Sol o] infertypevar :: CSCtx o -> Nat -> MExp o replace :: Nat -> Nat -> MExp o -> MExp o -> MExp o betareduce :: MExp o -> MArgList o -> MExp o concatargs :: MM (ArgList o) (RefInfo o) -> MArgList o -> MArgList o eqelr :: Elr o -> Elr o -> Bool replacep :: Nat -> Nat -> CSPatI o -> MExp o -> CSPat o -> CSPat o rm :: MM a b -> a mm :: a -> MM a b unifyexp :: MExp o -> MExp o -> Maybe [(Nat, MExp o)] lift :: Nat -> MExp o -> MExp o removevar :: CSCtx o -> MExp o -> [CSPat o] -> [(Nat, MExp o)] -> (CSCtx o, MExp o, [CSPat o]) notequal :: Nat -> Nat -> MExp o -> MExp o -> IO Bool findperm :: [MExp o] -> Maybe [Nat] freevars :: MExp o -> [Nat] applyperm :: [Nat] -> CSCtx o -> MExp o -> [CSPat o] -> (CSCtx o, MExp o, [CSPat o]) ren :: [Nat] -> Nat -> Int rename :: (Nat -> Nat) -> MExp o -> MExp o renamep :: (Nat -> Nat) -> CSPat o -> CSPat o seqctx :: CSCtx o -> CSCtx o depthofvar :: Nat -> [CSPat o] -> Nat localTerminationEnv :: [CSPat o] -> ([Nat], Nat, [Nat]) localTerminationSidecond :: ([Nat], Nat, [Nat]) -> ConstRef o -> MExp o -> EE (MyPB o) getblks :: MExp o -> IO [Nat] module Agda.Auto.Convert norm :: Normalise t => t -> TCM t type O = (Maybe Int, QName) data TMode TMAll :: TMode type MapS a b = (Map a b, [a]) initMapS :: MapS a b popMapS :: (S -> (a, [b])) -> ((a, [b]) -> S -> S) -> TOM (Maybe b) data S S :: MapS QName (TMode, ConstRef O) -> MapS MetaId (Metavar (Exp O) (RefInfo O), Maybe (MExp O, [MExp O]), [MetaId]) -> MapS Int (Maybe (Bool, MExp O, MExp O)) -> Maybe MetaId -> MetaId -> S [sConsts] :: S -> MapS QName (TMode, ConstRef O) [sMetas] :: S -> MapS MetaId (Metavar (Exp O) (RefInfo O), Maybe (MExp O, [MExp O]), [MetaId]) [sEqs] :: S -> MapS Int (Maybe (Bool, MExp O, MExp O)) [sCurMeta] :: S -> Maybe MetaId [sMainMeta] :: S -> MetaId type TOM = StateT S TCM tomy :: MetaId -> [(Bool, QName)] -> [Type] -> TCM ([ConstRef O], [MExp O], Map MetaId (Metavar (Exp O) (RefInfo O), MExp O, [MExp O], [MetaId]), [(Bool, MExp O, MExp O)], Map QName (TMode, ConstRef O)) getConst :: Bool -> QName -> TMode -> TOM (ConstRef O) getdfv :: MetaId -> QName -> TCM Nat getMeta :: MetaId -> TOM (Metavar (Exp O) (RefInfo O)) getEqs :: TCM [(Bool, Term, Term)] copatternsNotImplemented :: TCM a tomyClauses :: [Clause] -> TOM [([Pat O], MExp O)] tomyClause :: Clause -> TOM (Maybe ([Pat O], MExp O)) tomyPat :: Arg Pattern -> TOM (Pat O) tomyBody :: ClauseBodyF Term -> TOM (Maybe (MExp O, Int)) weaken :: Int -> MExp O -> MExp O weakens :: Int -> MArgList O -> MArgList O tomyType :: Type -> TOM (MExp O) tomyExp :: Term -> TOM (MExp O) tomyExps :: Args -> TOM (MM (ArgList O) (RefInfo O)) tomyIneq :: Comparison -> Bool fmType :: MetaId -> Type -> Bool fmExp :: MetaId -> Term -> Bool fmExps :: MetaId -> Args -> Bool fmLevel :: MetaId -> PlusLevel -> Bool cnvh :: LensHiding a => a -> FMode icnvh :: FMode -> ArgInfo frommy :: MExp O -> ExceptT String IO Term frommyType :: MExp O -> ExceptT String IO Type frommyExp :: MExp O -> ExceptT String IO Term frommyExps :: Nat -> MArgList O -> Term -> ExceptT String IO Term abslamvarname :: String modifyAbstractExpr :: Expr -> Expr modifyAbstractClause :: Clause -> Clause constructPats :: Map QName (TMode, ConstRef O) -> MetaId -> Clause -> TCM ([(FMode, MId)], [CSPat O]) frommyClause :: (CSCtx O, [CSPat O], Maybe (MExp O)) -> ExceptT String IO Clause contains_constructor :: [CSPat O] -> Bool etaContractBody :: ClauseBody -> TCM ClauseBody freeIn :: Nat -> MExp o -> Bool negtype :: ConstRef o -> MExp o -> MExp o findClauseDeep :: MetaId -> TCM (Maybe (QName, Clause, Bool)) matchType :: Int -> Int -> Type -> Type -> Maybe (Nat, Nat) instance GHC.Classes.Eq Agda.Auto.Convert.TMode module Agda.Auto.Auto -- | Entry point for Auto tactic (Agsy). -- --
-- auto ii rng s = return (res, mmsg) ---- -- If mmsg = Just msg, the message msg produced by Agsy -- should be displayed to the user. -- -- The result res of the Auto tactic can be one of the following -- three: -- --