-- 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
--   <tt>agda-mode setup</tt> (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.2

module Agda.Version

-- | The version of Agda.
version :: String

module Agda.VersionCommit
versionWithCommitInfo :: String

-- | Information about current git commit, generated at compile time
commitInfo :: Maybe String


-- | Var field implementation of sets of (small) natural numbers.
module Agda.Utils.VarSet
type VarSet = IntSet

-- | <i>O(n+m)</i>. The union of two sets.
union :: IntSet -> IntSet -> IntSet

-- | The union of a list of sets.
unions :: [IntSet] -> IntSet

-- | <i>O(min(n,W))</i>. Is the value a member of the set?
member :: Key -> IntSet -> Bool

-- | <i>O(1)</i>. The empty set.
empty :: IntSet

-- | <i>O(min(n,W))</i>. Delete a value in the set. Returns the original
--   set when the value was not present.
delete :: Key -> IntSet -> IntSet

-- | <i>O(1)</i>. A set of one element.
singleton :: Key -> IntSet

-- | <i>O(n*min(n,W))</i>. Create a set from a list of integers.
fromList :: [Key] -> IntSet

-- | <i>O(n)</i>. Convert the set to a list of elements. Subject to list
--   fusion.
toList :: IntSet -> [Key]

-- | <i>O(n)</i>. Convert the set to a descending list of elements. Subject
--   to list fusion.
toDescList :: IntSet -> [Key]

-- | <i>O(n+m)</i>. Is this a subset? <tt>(s1 <a>isSubsetOf</a> s2)</tt>
--   tells whether <tt>s1</tt> is a subset of <tt>s2</tt>.
isSubsetOf :: IntSet -> IntSet -> Bool

-- | <i>O(1)</i>. Is the set empty?
null :: IntSet -> Bool

-- | <i>O(n+m)</i>. The intersection of two sets.
intersection :: IntSet -> IntSet -> IntSet

-- | <i>O(n+m)</i>. 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 -*-

-- | <pre>
--   mapFst f = f -*- id
--   </pre>
mapFst :: (a -> c) -> (a, b) -> (c, b)

-- | <pre>
--   mapSnd g = id -*- g
--   </pre>
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 <a>-*-</a>.
mapPairM :: (Applicative m) => (a -> m c) -> (b -> m d) -> (a, b) -> m (c, d)

-- | Monadic <a>mapFst</a>.
mapFstM :: (Applicative m) => (a -> m c) -> (a, b) -> m (c, b)

-- | Monadic <a>mapSnd</a>.
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 <tt>Change</tt> 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 <a>Change</a> 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 <a>Functor</a>, 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 <tt>Bifunctor</tt>, 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


-- | 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 (<a>https://en.wikipedia.org/wiki/Semiring</a>).
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
--   (<a>https://en.wikipedia.org/wiki/Semiring#Star_semirings</a>).
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)


-- | Pretty printing functions.
module Agda.Utils.Pretty

-- | While <a>Show</a> is for rendering data in Haskell syntax,
--   <a>Pretty</a> is for displaying data to the world, i.e., the user and
--   the environment.
--   
--   Atomic data has no inner document structure, so just implement
--   <a>pretty</a> as <tt>pretty a = text $ ... a ...</tt>.
class Pretty a where pretty = prettyPrec 0 prettyPrec = const pretty
pretty :: Pretty a => a -> Doc
prettyPrec :: Pretty a => Int -> a -> Doc

-- | Use instead of <a>show</a> 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

-- | <tt>align max rows</tt> lays out the elements of <tt>rows</tt> in two
--   columns, with the second components aligned. The alignment column of
--   the second components is at most <tt>max</tt> characters to the right
--   of the left-most column.
--   
--   Precondition: <tt>max &gt; 0</tt>.
align :: Int -> [(String, Doc)] -> Doc

-- | Handles strings with newlines properly (preserving indentation)
multiLineText :: String -> 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 <tt>f a</tt> contains many copies of <tt>a</tt> 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
--   <a>PartialOrdering</a>. More precise information is smaller.
--   
--   Includes equality: <tt>x <a>leqPO</a> x == True</tt>.
leqPO :: PartialOrdering -> PartialOrdering -> Bool

-- | Opposites.
--   
--   <tt>related a po b</tt> iff <tt>related b (oppPO po) a</tt>.
oppPO :: PartialOrdering -> PartialOrdering

-- | Combining two pieces of information (picking the least information).
--   Used for the dominance ordering on tuples.
--   
--   <tt>orPO</tt> is associative, commutative, and idempotent.
--   <tt>orPO</tt> has dominant element <tt>POAny</tt>, but no neutral
--   element.
orPO :: PartialOrdering -> PartialOrdering -> PartialOrdering

-- | Chains (transitivity) <tt>x R y S z</tt>.
--   
--   <tt>seqPO</tt> is associative, commutative, and idempotent.
--   <tt>seqPO</tt> has dominant element <tt>POAny</tt> and neutral element
--   (unit) <tt>POEQ</tt>.
seqPO :: PartialOrdering -> PartialOrdering -> PartialOrdering

-- | Partial ordering forms a monoid under sequencing.

-- | Embed <a>Ordering</a>.
fromOrdering :: Ordering -> PartialOrdering

-- | Represent a non-empty disjunction of <a>Ordering</a>s as
--   <a>PartialOrdering</a>.
fromOrderings :: [Ordering] -> PartialOrdering

-- | A <a>PartialOrdering</a> information is a disjunction of
--   <a>Ordering</a> informations.
toOrderings :: PartialOrdering -> [Ordering]
type Comparable a = a -> a -> PartialOrdering

-- | Decidable partial orderings.
class PartialOrd a
comparable :: PartialOrd a => Comparable a

-- | Any <a>Ord</a> is a <a>PartialOrd</a>.
comparableOrd :: Ord a => Comparable a

-- | Are two elements related in a specific way?
--   
--   <tt>related a o b</tt> holds iff <tt>comparable a b</tt> is contained
--   in <tt>o</tt>.
related :: PartialOrd a => a -> PartialOrdering -> a -> Bool

-- | <a>Nothing</a> and <tt><a>Just</a> _</tt> are unrelated.
--   
--   Partial ordering for <tt>Maybe a</tt> is the same as for <tt>Either ()
--   a</tt>.

-- | Partial ordering for disjoint sums: <tt>Left _</tt> and <tt>Right
--   _</tt> are unrelated.

-- | Pointwise partial ordering for tuples.
--   
--   <tt>related (x1,x2) o (y1,y2)</tt> iff <tt>related x1 o x2</tt> and
--   <tt>related y1 o y2</tt>.

-- | 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).
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 Data.Semigroup.Semigroup 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


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: <a>gather</a> 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

-- | <tt>count n p</tt> parses <tt>n</tt> occurrences of <tt>p</tt> in
--   sequence. A list of results is returned.
count :: Int -> ReadP t a -> ReadP t [a]

-- | <tt>between open close p</tt> parses <tt>open</tt>, followed by
--   <tt>p</tt> and finally <tt>close</tt>. Only the value of <tt>p</tt> is
--   returned.
between :: ReadP t open -> ReadP t close -> ReadP t a -> ReadP t a

-- | <tt>option x p</tt> will either parse <tt>p</tt> or return <tt>x</tt>
--   without consuming any input.
option :: a -> ReadP t a -> ReadP t a

-- | <tt>optional p</tt> optionally parses <tt>p</tt> and always returns
--   <tt>()</tt>.
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 <a>many</a>, but discards the result.
skipMany :: ReadP t a -> ReadP t ()

-- | Like <a>many1</a>, but discards the result.
skipMany1 :: ReadP t a -> ReadP t ()

-- | <tt>sepBy p sep</tt> parses zero or more occurrences of <tt>p</tt>,
--   separated by <tt>sep</tt>. Returns a list of values returned by
--   <tt>p</tt>.
sepBy :: ReadP t a -> ReadP t sep -> ReadP t [a]

-- | <tt>sepBy1 p sep</tt> parses one or more occurrences of <tt>p</tt>,
--   separated by <tt>sep</tt>. Returns a list of values returned by
--   <tt>p</tt>.
sepBy1 :: ReadP t a -> ReadP t sep -> ReadP t [a]

-- | <tt>endBy p sep</tt> parses zero or more occurrences of <tt>p</tt>,
--   separated and ended by <tt>sep</tt>.
endBy :: ReadP t a -> ReadP t sep -> ReadP t [a]

-- | <tt>endBy p sep</tt> parses one or more occurrences of <tt>p</tt>,
--   separated and ended by <tt>sep</tt>.
endBy1 :: ReadP t a -> ReadP t sep -> ReadP t [a]

-- | <tt>chainr p op x</tt> parses zero or more occurrences of <tt>p</tt>,
--   separated by <tt>op</tt>. Returns a value produced by a <i>right</i>
--   associative application of all functions returned by <tt>op</tt>. If
--   there are no occurrences of <tt>p</tt>, <tt>x</tt> is returned.
chainr :: ReadP t a -> ReadP t (a -> a -> a) -> a -> ReadP t a

-- | <tt>chainl p op x</tt> parses zero or more occurrences of <tt>p</tt>,
--   separated by <tt>op</tt>. Returns a value produced by a <i>left</i>
--   associative application of all functions returned by <tt>op</tt>. If
--   there are no occurrences of <tt>p</tt>, <tt>x</tt> is returned.
chainl :: ReadP t a -> ReadP t (a -> a -> a) -> a -> ReadP t a

-- | Like <a>chainl</a>, but parses one or more occurrences of <tt>p</tt>.
chainl1 :: ReadP t a -> ReadP t (a -> a -> a) -> ReadP t a

-- | Like <a>chainr</a>, but parses one or more occurrences of <tt>p</tt>.
chainr1 :: ReadP t a -> ReadP t (a -> a -> a) -> ReadP t a

-- | <tt>manyTill p end</tt> parses zero or more occurrences of <tt>p</tt>,
--   until <tt>end</tt> succeeds. Returns a list of values returned by
--   <tt>p</tt>.
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 <tt>undefined.h</tt>.
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 <a>Maybe</a> by common operations for the <a>Maybe</a> type.
--   
--   Note: since this module is usually imported unqualified, we do not use
--   short names, but all names contain <a>Maybe</a>, <a>Just</a>, or
--   'Nothing.
module Agda.Utils.Maybe

-- | <tt>unionWith</tt> for collections of size &lt;= 1.
unionMaybeWith :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a

-- | Unzipping a list of length &lt;= 1.
unzipMaybe :: Maybe (a, b) -> (Maybe a, Maybe b)

-- | Filtering a singleton list.
--   
--   <pre>
--   filterMaybe p a = <a>listToMaybe</a> (<a>filter</a> p [a])
--   </pre>
filterMaybe :: (a -> Bool) -> a -> Maybe a

-- | Version of <a>mapMaybe</a> with different argument ordering.
forMaybe :: [a] -> (a -> Maybe b) -> [b]

-- | Version of <a>maybe</a> with different argument ordering. Often, we
--   want to case on a <a>Maybe</a>, do something interesting in the
--   <a>Just</a> case, but only a default action in the <a>Nothing</a>
--   case. Then, the argument ordering of <tt>caseMaybe</tt> is preferable.
--   
--   <pre>
--   caseMaybe m d f = flip (maybe d) m f
--   </pre>
caseMaybe :: Maybe a -> b -> (a -> b) -> b

-- | Monadic version of <a>maybe</a>.
maybeM :: Monad m => m b -> (a -> m b) -> m (Maybe a) -> m b

-- | Monadic version of <a>fromMaybe</a>.
fromMaybeM :: Monad m => m a -> m (Maybe a) -> m a

-- | Monadic version of <a>caseMaybe</a>. That is, <a>maybeM</a> with a
--   different argument ordering.
caseMaybeM :: Monad m => m (Maybe a) -> m b -> (a -> m b) -> m b

-- | <a>caseMaybeM</a> with flipped branches.
ifJustM :: Monad m => m (Maybe a) -> (a -> m b) -> m b -> m b

-- | A more telling name for <a>forM_</a> for the <a>Maybe</a> collection
--   type. Or: <a>caseMaybe</a> without the <a>Nothing</a> case.
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()

-- | <a>caseMaybe</a> without the <a>Just</a> case.
whenNothing :: Monad m => Maybe a -> m () -> m ()

-- | <a>caseMaybeM</a> without the <a>Nothing</a> case.
whenJustM :: Monad m => m (Maybe a) -> (a -> m ()) -> m ()

-- | <a>caseMaybeM</a> without the <a>Just</a> case.
whenNothingM :: Monad m => m (Maybe a) -> m () -> m ()

-- | Lazy version of <tt>allJust <a>.</a> sequence</tt>. (<tt>allJust =
--   mapM</tt> for the <tt>Maybe</tt> monad.) Only executes monadic effect
--   while <tt>isJust</tt>.
allJustM :: Monad m => [m (Maybe a)] -> m (Maybe [a])

-- | Precondition: list not empty. <tt> allJustsOrNothings [Nothing,
--   Nothing] = Just Nothing allJustsOrNothings [Just 0, Just 1] = Just $
--   Just [0,1] allJustsOrNothings [Just 0, Nothing] = Nothing </tt>
allJustsOrNothings :: [Maybe a] -> Maybe (Maybe [a])


-- | <tt>ListT</tt> done right, see
--   <a>https://www.haskell.org/haskellwiki/ListT_done_right_alternative</a>
--   
--   There is also the <tt>list-t</tt> 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 <tt>ListT m</tt> monad.
concatListT :: Monad m => ListT m (ListT m a) -> ListT m a

-- | We can `<tt>run'</tt> a computation of a <a>ListT</a> 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 <a>ListT</a>.
mapMListT :: (Monad m) => (a -> m b) -> ListT m a -> ListT m b

-- | Alternative implementation using <a>foldListT</a>.
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 => Data.Semigroup.Semigroup (Agda.Utils.ListT.ListT m a)
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)


-- | Utilities for Data.IORef.
module Agda.Utils.IORef

-- | Read <a>IORef</a>, 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.Haskell.Syntax
data Module
Module :: ModuleName -> [ModulePragma] -> [ImportDecl] -> [Decl] -> Module
data ModulePragma
LanguagePragma :: [Name] -> ModulePragma
data ImportDecl
ImportDecl :: ModuleName -> Bool -> Maybe (Bool, [ImportSpec]) -> ImportDecl
[importModule] :: ImportDecl -> ModuleName
[importQualified] :: ImportDecl -> Bool
[importSpecs] :: ImportDecl -> Maybe (Bool, [ImportSpec])
data ImportSpec
IVar :: Name -> ImportSpec
data Decl
TypeDecl :: Name -> [TyVarBind] -> Type -> Decl
DataDecl :: DataOrNew -> Name -> [TyVarBind] -> [ConDecl] -> [Deriving] -> Decl
TypeSig :: [Name] -> Type -> Decl
FunBind :: [Match] -> Decl
FakeDecl :: String -> Decl
data DataOrNew
DataType :: DataOrNew
NewType :: DataOrNew
data ConDecl
ConDecl :: Name -> [Type] -> ConDecl
type Deriving = (QName, [Type])
data Binds
BDecls :: [Decl] -> Binds
data Rhs
UnGuardedRhs :: Exp -> Rhs
GuardedRhss :: [GuardedRhs] -> Rhs
data GuardedRhs
GuardedRhs :: [Stmt] -> Exp -> GuardedRhs
data Match
Match :: Name -> [Pat] -> Rhs -> (Maybe Binds) -> Match
data Type
TyForall :: [TyVarBind] -> Type -> Type
TyFun :: Type -> Type -> Type
TyCon :: QName -> Type
TyVar :: Name -> Type
TyApp :: Type -> Type -> Type
FakeType :: String -> Type
data Pat
PVar :: Name -> Pat
PLit :: Literal -> Pat
PAsPat :: Name -> Pat -> Pat
PWildCard :: Pat
PBangPat :: Pat -> Pat
PApp :: QName -> [Pat] -> Pat
PatTypeSig :: Pat -> Type -> Pat
PIrrPat :: Pat -> Pat
data Stmt
Qualifier :: Exp -> Stmt
Generator :: Pat -> Exp -> Stmt
data Exp
Var :: QName -> Exp
Con :: QName -> Exp
Lit :: Literal -> Exp
InfixApp :: Exp -> QOp -> Exp -> Exp
App :: Exp -> Exp -> Exp
Lambda :: [Pat] -> Exp -> Exp
Let :: Binds -> Exp -> Exp
If :: Exp -> Exp -> Exp -> Exp
Case :: Exp -> [Alt] -> Exp
ExpTypeSig :: Exp -> Type -> Exp
NegApp :: Exp -> Exp
FakeExp :: String -> Exp
data Alt
Alt :: Pat -> Rhs -> (Maybe Binds) -> Alt
data Literal
Int :: Integer -> Literal
Frac :: Rational -> Literal
Char :: Char -> Literal
String :: String -> Literal
data ModuleName
ModuleName :: String -> ModuleName
data QName
Qual :: ModuleName -> Name -> QName
UnQual :: Name -> QName
data Name
Ident :: String -> Name
Symbol :: String -> Name
data QOp
QVarOp :: QName -> QOp
data TyVarBind
UnkindedVar :: Name -> TyVarBind
unit_con :: Exp
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.Stmt
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.GuardedRhs
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.Binds
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.Alt
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.Exp
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.Rhs
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.Match
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.Decl
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.ConDecl
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.Pat
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.Type
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.TyVarBind
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.QOp
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.QName
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.Name
instance GHC.Classes.Ord Agda.Utils.Haskell.Syntax.ModuleName
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.ModuleName
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.Literal
instance GHC.Classes.Eq Agda.Utils.Haskell.Syntax.DataOrNew

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 <tt>for</tt> loop. <a>for</a> is a misnomer, it should
--   be <tt>forA</tt>.
for :: Functor m => m a -> (a -> b) -> m b

-- | Infix version of <a>for</a>.
(<&>) :: Functor m => m a -> (a -> b) -> m b
infix 4 <&>

-- | A decoration is a functor that is traversable into any functor.
--   
--   The <a>Functor</a> superclass is given because of the limitations of
--   the Haskell class system. <tt>traverseF</tt> actually implies
--   functoriality.
--   
--   Minimal complete definition: <tt>traverseF</tt> or
--   <tt>distributeF</tt>.
class Functor t => Decoration t where traverseF f = distributeF . fmap f distributeF = traverseF id

-- | <tt>traverseF</tt> 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 <tt>traverse = traverseF</tt>. Just
--   like any <a>Traversable</a> is a functor, so is any decoration, given
--   by just <tt>traverseF</tt>, a functor.
dmap :: Decoration t => (a -> b) -> t a -> t b

-- | Any decoration is a lens. <tt>set</tt> is a special case of
--   <tt>dmap</tt>.
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 <a>fmap</a>.
--   
--   The name of this operator is an allusion to <tt>$</tt>. Note the
--   similarities between their types:
--   
--   <pre>
--    ($)  ::              (a -&gt; b) -&gt;   a -&gt;   b
--   (&lt;$&gt;) :: Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
--   </pre>
--   
--   Whereas <tt>$</tt> is function application, <a>&lt;$&gt;</a> is
--   function application lifted over a <a>Functor</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Convert from a <tt><tt>Maybe</tt> <tt>Int</tt></tt> to a
--   <tt><tt>Maybe</tt> <tt>String</tt></tt> using <tt>show</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Nothing
--   Nothing
--   
--   &gt;&gt;&gt; show &lt;$&gt; Just 3
--   Just "3"
--   </pre>
--   
--   Convert from an <tt><tt>Either</tt> <tt>Int</tt> <tt>Int</tt></tt> to
--   an <tt><tt>Either</tt> <tt>Int</tt></tt> <tt>String</tt> using
--   <tt>show</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Left 17
--   Left 17
--   
--   &gt;&gt;&gt; show &lt;$&gt; Right 17
--   Right "17"
--   </pre>
--   
--   Double each element of a list:
--   
--   <pre>
--   &gt;&gt;&gt; (*2) &lt;$&gt; [1,2,3]
--   [2,4,6]
--   </pre>
--   
--   Apply <tt>even</tt> to the second element of a pair:
--   
--   <pre>
--   &gt;&gt;&gt; even &lt;$&gt; (2,2)
--   (2,True)
--   </pre>
(<$>) :: 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 <tt>i</tt> of structure <tt>o</tt> as designated by
--   <tt>Lens' i o</tt>.
(^.) :: o -> Lens' i o -> i
infixl 8 ^.

-- | Set inner part <tt>i</tt> of structure <tt>o</tt> as designated by
--   <tt>Lens' i o</tt>.
set :: Lens' i o -> i -> o -> o

-- | Modify inner part <tt>i</tt> of structure <tt>o</tt> using a function
--   <tt>i -&gt; i</tt>.
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 <a>for</a>.
(<&>) :: 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
memoUnsafe :: Ord a => (a -> b) -> (a -> b)
memoUnsafeH :: (Eq a, Hashable a) => (a -> b) -> (a -> b)


-- | Examples how to use <a>Agda.Utils.Lens</a>.
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 <tt>f :: a -&gt; (b, a)</tt> with output
--   <tt>b</tt> while condition <tt>cond</tt> on the output is true. Return
--   all intermediate results and the final result where <tt>cond</tt> is
--   <tt>False</tt>.
--   
--   Postconditions (when it terminates): <tt>fst (last (iterWhile cond f
--   a)) == False</tt>. <tt>all fst (init (interWhile cond f a))</tt>.
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 <a>repeatWhile</a>.
repeatWhileM :: (Monad m) => (a -> m (Bool, a)) -> a -> m a

-- | A version of the trampoline function.
--   
--   The usual function iterates <tt>f :: a -&gt; Maybe a</tt> as long as
--   <tt>Just{}</tt> is returned, and returns the last value of <tt>a</tt>
--   upon <tt>Nothing</tt>.
--   
--   <tt>usualTrampoline f = trampolineWhile $ a -&gt; maybe (False,a)
--   (True,) (f a)</tt>.
--   
--   <tt>trampolineWhile</tt> is very similar to <tt>repeatWhile</tt>, only
--   that it discards the state on which the condition went <tt>False</tt>,
--   and returns the last state on which the condition was <tt>True</tt>.
trampolineWhile :: (a -> (Bool, a)) -> a -> a

-- | Monadic version of <a>trampolineWhile</a>.
trampolineWhileM :: (Monad m) => (a -> m (Bool, a)) -> a -> m a

-- | More general trampoline, which allows some final computation from
--   iteration state <tt>a</tt> into result type <tt>b</tt>.
trampoline :: (a -> Either b a) -> a -> b

-- | Monadic version of <a>trampoline</a>.
trampolineM :: Monad m => (a -> m (Either b a)) -> a -> m b

-- | Iteration to fixed-point.
--   
--   <tt>iterateUntil r f a0</tt> iterates endofunction <tt>f</tt>,
--   starting with <tt>a0</tt>, until <tt>r</tt> relates its result to its
--   input, i.e., <tt>f a <tt>r</tt> a</tt>.
--   
--   This is the generic pattern behind saturation algorithms.
--   
--   If <tt>f</tt> is monotone with regard to <tt>r</tt>, meaning <tt>a
--   <tt>r</tt> b</tt> implies <tt>f a <tt>r</tt> f b</tt>, and
--   <tt>f</tt>-chains starting with <tt>a0</tt> are finite then iteration
--   is guaranteed to terminate.
--   
--   A typical instance will work on sets, and <tt>r</tt> could be set
--   inclusion, and <tt>a0</tt> the empty set, and <tt>f</tt> the step
--   function of a saturation algorithm.
iterateUntil :: (a -> a -> Bool) -> (a -> a) -> a -> a

-- | Monadic version of <a>iterateUntil</a>.
iterateUntilM :: Monad m => (a -> a -> Bool) -> (a -> m a) -> a -> m a

-- | <tt><a>iterate'</a> n f x</tt> applies <tt>f</tt> to <tt>x</tt>
--   <tt>n</tt> times and returns the result.
--   
--   The applications are calculated strictly.
iterate' :: Integral i => i -> (a -> a) -> a -> a

-- | <tt>applyWhen b f a</tt> applies <tt>f</tt> to <tt>a</tt> when
--   <tt>b</tt>.
applyWhen :: Bool -> (a -> a) -> a -> a

-- | <tt>applyUnless b f a</tt> applies <tt>f</tt> to <tt>a</tt> unless
--   <tt>b</tt>.
applyUnless :: Bool -> (a -> a) -> a -> a

-- | Monadic version of <tt>applyWhen</tt>
applyWhenM :: (Monad m) => m Bool -> (m a -> m a) -> m a -> m a

-- | Monadic version of <tt>applyUnless</tt>
applyUnlessM :: (Monad m) => m Bool -> (m a -> m a) -> m a -> m a

module Agda.Utils.Suffix

-- | Is the character one of the subscripts <tt>'₀'</tt>-<tt>'₉'</tt>?
isSubscriptDigit :: Char -> Bool

-- | Converts <tt>'0'</tt>-<tt>'9'</tt> to <tt>'₀'</tt>-<tt>'₉'</tt>.
--   
--   Precondition: The digit needs to be in range.
toSubscriptDigit :: Char -> Char

-- | Converts <tt>'₀'</tt>-<tt>'₉'</tt> to <tt>'0'</tt>-<tt>'9'</tt>.
--   
--   Precondition: The digit needs to be in range.
fromSubscriptDigit :: Char -> Char

-- | Classification of identifier variants.
data Suffix
NoSuffix :: Suffix

-- | Identifier ends in <tt>Int</tt> many primes.
Prime :: Int -> Suffix

-- | Identifier ends in number <tt>Int</tt> (ordinary digits).
Index :: Int -> Suffix

-- | Identifier ends in number <tt>Int</tt> (subscript digits).
Subscript :: Int -> Suffix

-- | Increase the suffix by one. If no suffix yet, put a subscript
--   <tt>1</tt>.
nextSuffix :: Suffix -> Suffix

-- | Parse suffix.
suffixView :: String -> (String, Suffix)

-- | Print suffix.
addSuffix :: String -> Suffix -> String

-- | Add first available <tt>Suffix</tt> to a name.
nameVariant :: (String -> Bool) -> String -> String


-- | 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.
--   
--   <tt>ExceptT</tt> constructs a monad parameterized over two things:
--   
--   <ul>
--   <li>e - The exception type.</li>
--   <li>m - The inner monad.</li>
--   </ul>
--   
--   The <a>return</a> function yields a computation that produces the
--   given value, while <tt>&gt;&gt;=</tt> sequences two subcomputations,
--   exiting on the first exception.
data ExceptT e (m :: * -> *) a :: * -> (* -> *) -> * -> *

-- | We cannot define data constructors synonymous, so we define the
--   <tt>mkExceptT</tt> function to be used instead of the data constructor
--   <tt>ExceptT</tt>.
mkExceptT :: m (Either e a) -> ExceptT e m a

-- | The strategy of combining computations that can throw exceptions by
--   bypassing bound functions from the point an exception is thrown to the
--   point that it is handled.
--   
--   Is parameterized over the type of error information and the monad type
--   constructor. It is common to use <tt><a>Either</a> String</tt> as the
--   monad type constructor for an error monad in which error descriptions
--   take the form of strings. In that case and many other common cases the
--   resulting monad is already defined as an instance of the
--   <a>MonadError</a> class. You can also define your own error type
--   and/or use a monad type constructor other than <tt><a>Either</a>
--   <tt>String</tt></tt> or <tt><a>Either</a> <tt>IOError</tt></tt>. In
--   these cases you will have to explicitly define instances of the
--   <a>Error</a> and/or <a>MonadError</a> classes.
class Monad m => MonadError e (m :: * -> *) | m -> e

-- | Is used within a monadic computation to begin exception processing.
throwError :: MonadError e m => e -> m a

-- | A handler function to handle previous errors and return to normal
--   execution. A common idiom is:
--   
--   <pre>
--   do { action1; action2; action3 } `catchError` handler
--   </pre>
--   
--   where the <tt>action</tt> functions can call <a>throwError</a>. Note
--   that <tt>handler</tt> and the do-block must have the same return type.
catchError :: MonadError e m => m a -> (e -> m a) -> m a

-- | The inverse of <a>ExceptT</a>.
runExceptT :: ExceptT e m a -> m (Either e a)

-- | Map the unwrapped computation using the given function.
--   
--   <ul>
--   <li><pre><a>runExceptT</a> (<a>mapExceptT</a> f m) = f
--   (<a>runExceptT</a> m)</pre></li>
--   </ul>
mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b
instance Agda.Utils.Except.Error GHC.Base.String


-- | Expand environment variables in strings
module Agda.Utils.Environment
expandEnvironmentVariables :: String -> IO String
instance GHC.Show.Show Agda.Utils.Environment.Token
instance GHC.Classes.Eq Agda.Utils.Environment.Token


-- | An empty type with some useful instances.
module Agda.Utils.Empty
data Empty
absurd :: Empty -> a
instance GHC.Classes.Eq Agda.Utils.Empty.Empty
instance GHC.Classes.Ord Agda.Utils.Empty.Empty
instance GHC.Show.Show Agda.Utils.Empty.Empty


-- | Utilities for the <a>Either</a> type
module Agda.Utils.Either

-- | Loop while we have an exception.
whileLeft :: Monad m => (a -> Either b c) -> (a -> b -> m a) -> (a -> c -> m d) -> a -> m d

-- | Monadic version of <a>either</a> with a different argument ordering.
caseEitherM :: Monad m => m (Either a b) -> (a -> m c) -> (b -> m c) -> m c

-- | <a>Either</a> is a bifunctor.
mapEither :: (a -> c) -> (b -> d) -> Either a b -> Either c d

-- | 'Either _ b' is a functor.
mapLeft :: (a -> c) -> Either a b -> Either c b

-- | 'Either a' is a functor.
mapRight :: (b -> d) -> Either a b -> Either a d

-- | <a>Either</a> is bitraversable.
traverseEither :: Functor f => (a -> f c) -> (b -> f d) -> Either a b -> f (Either c d)

-- | Returns <a>True</a> iff the argument is <tt><a>Left</a> x</tt> for
--   some <tt>x</tt>. Note: from <tt>base &gt;= 4.7.0.0</tt> already
--   present in <tt>Data.Either</tt>.
isLeft :: Either a b -> Bool

-- | Returns <a>True</a> iff the argument is <tt><a>Right</a> x</tt> for
--   some <tt>x</tt>. Note: from <tt>base &gt;= 4.7.0.0</tt> already
--   present in <tt>Data.Either</tt>.
isRight :: Either a b -> Bool

-- | Analogue of <a>fromMaybe</a>.
fromLeft :: (b -> a) -> Either a b -> a

-- | Analogue of <a>fromMaybe</a>.
fromRight :: (a -> b) -> Either a b -> b

-- | Safe projection from <a>Left</a>. <tt> maybeLeft (Left a) = Just a
--   maybeLeft Right{} = Nothing </tt>
maybeLeft :: Either a b -> Maybe a

-- | Safe projection from <a>Right</a>. <tt> maybeRight (Right b) = Just b
--   maybeRight Left{} = Nothing </tt>
maybeRight :: Either a b -> Maybe b

-- | Returns <tt><a>Just</a> <a>with tags stripped</a></tt> if all elements
--   are to the <a>Left</a>, and otherwise <a>Nothing</a>.
allLeft :: [Either a b] -> Maybe [a]

-- | Returns <tt><a>Just</a> <a>with tags stripped</a></tt> if all elements
--   are to the right, and otherwise <a>Nothing</a>.
--   
--   <pre>
--   allRight xs ==
--     if all isRight xs then
--       Just (map ((Right x) -&gt; x) xs)
--      else
--       Nothing
--   </pre>
allRight :: [Either a b] -> Maybe [b]

-- | Convert <a>Maybe</a> to <tt><a>Either</a> ()'</tt>
maybeToEither :: Maybe a -> Either () a


-- | Create clusters of non-overlapping things.
module Agda.Utils.Cluster

-- | Characteristic identifiers.
type C = Int

-- | Given a function <tt>f :: a -&gt; (C,[C])</tt> which returns a
--   non-empty list of characteristics <tt>C</tt> of <tt>a</tt>, partition
--   a list of <tt>a</tt>s 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 <tt>a</tt>s 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]]

module Agda.Utils.Char

-- | Convert a character in <tt>'0'..'9'</tt> into the corresponding digit
--   <tt>0..9</tt>.
decDigit :: Char -> Int

-- | Convert a character in <tt>'0'..'9','A'..'F','a'..'f'</tt> into the
--   corresponding digit <tt>0..15</tt>.
hexDigit :: Char -> Int

-- | Convert a character in <tt>'0'..'7'</tt> into the corresponding digit
--   <tt>0..7</tt>.
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 <a>Char</a> 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 <tt>a</tt> to <tt>b</tt>. 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)]
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)


-- | 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

-- | <tt>bag ! a</tt> finds all elements equal to <tt>a</tt>.
(!) :: 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

-- | <pre>
--   insert a b = union b (singleton a)
--   </pre>
insert :: Ord a => a -> Bag a -> Bag a

-- | <pre>
--   fromList = unions . map singleton
--   </pre>
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)
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 => Data.Semigroup.Semigroup (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


-- | Utitlity functions on lists.
module Agda.Utils.List

-- | Case distinction for lists, with list first. Cf. <a>ifNull</a>.
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.
--   
--   <pre>
--   headWithDefault 42 []      = 42
--   headWithDefault 42 [1,2,3] = 1
--   </pre>
headWithDefault :: a -> [a] -> a

-- | Last element (safe).
lastMaybe :: [a] -> Maybe a

-- | Opposite of cons <tt>(:)</tt>, safe.
uncons :: [a] -> Maybe (a, [a])

-- | Maybe cons. <tt>mcons ma as = maybeToList ma ++ as</tt>
mcons :: Maybe a -> [a] -> [a]

-- | <a>init</a> and <a>last</a> 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]

-- | Update the last element of a list, if it exists.
updateLast :: (a -> a) -> [a] -> [a]

-- | Update nth element of a list, if it exists. Precondition: the index is
--   &gt;= 0.
updateAt :: Int -> (a -> a) -> [a] -> [a]

-- | A generalized version of <tt>partition</tt>. (Cf. <tt>mapMaybe</tt>
--   vs. <tt>filter</tt>).
mapEither :: (a -> Either b c) -> [a] -> ([b], [c])
deal :: (a -> Either b c) -> a -> ([b], [c]) -> ([b], [c])

-- | A generalized version of <tt>takeWhile</tt>. (Cf. <tt>mapMaybe</tt>
--   vs. <tt>filter</tt>).
takeWhileJust :: (a -> Maybe b) -> [a] -> [b]

-- | A generalized version of <tt>span</tt>.
spanJust :: (a -> Maybe b) -> [a] -> ([b], [a])

-- | Partition a list into <a>Nothing</a>s and <a>Just</a>s.
--   <tt><a>mapMaybe</a> f = snd . partitionMaybe f</tt>.
partitionMaybe :: (a -> Maybe b) -> [a] -> ([a], [b])

-- | Like <a>filter</a>, but additionally return the last partition of the
--   list where the predicate is <tt>False</tt> everywhere.
filterAndRest :: (a -> Bool) -> [a] -> ([a], [a])

-- | Like <a>mapMaybe</a>, but additionally return the last partition of
--   the list where the function always returns <tt>Nothing</tt>.
mapMaybeAndRest :: (a -> Maybe b) -> [a] -> ([b], [a])

-- | Drops from both lists simultaneously until one list is empty.
dropCommon :: [a] -> [b] -> ([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.
stripPrefixBy :: (a -> a -> Bool) -> Prefix a -> [a] -> Maybe (Suffix a)

-- | Result of <a>preOrSuffix</a>.
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
--   <tt>words</tt>.
--   
--   <pre>
--   words xs == wordsBy isSpace xs
--   </pre>
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
--   <a>wordsBy</a>, consecutive separator elements will result in an empty
--   segment in the result. &gt; intercalate [x] (chopWhen (== x) xs) == xs
chopWhen :: (a -> Bool) -> [a] -> [[a]]

-- | All ways of removing one element from a list.
holes :: [a] -> [(a, [a])]

-- | Check whether a list is sorted.
--   
--   Assumes that the <a>Ord</a> 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 <a>Eq</a> instance stands for an equivalence
--   relation.
distinct :: Eq a => [a] -> Bool

-- | An optimised version of <a>distinct</a>.
--   
--   Precondition: The list's length must fit in an <a>Int</a>.
fastDistinct :: Ord a => [a] -> Bool

-- | Checks if all the elements in the list are equal. Assumes that the
--   <a>Eq</a> 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 <a>groupBy</a> which applies the predicate to consecutive
--   pairs.
groupBy' :: (a -> a -> Bool) -> [a] -> [[a]]

-- | <tt><a>groupOn</a> f = <a>groupBy</a> ((<a>==</a>) `on` f) <a>.</a>
--   <a>sortBy</a> (<a>compare</a> `on` f)</tt>.
groupOn :: Ord b => (a -> b) -> [a] -> [[a]]

-- | <tt>splitExactlyAt n xs = Just (ys, zs)</tt> iff <tt>xs = ys ++
--   zs</tt> and <tt>genericLength ys = n</tt>.
splitExactlyAt :: Integral n => n -> [a] -> Maybe ([a], [a])

-- | A generalised variant of <a>elemIndex</a>.
genericElemIndex :: (Eq a, Integral i) => a -> [a] -> Maybe i

-- | Requires both lists to have the same length.
zipWith' :: (a -> b -> c) -> [a] -> [b] -> [c]

-- | Efficient variant of <a>nubBy</a> for finite lists.
--   
--   Specification:
--   
--   <pre>
--   nubOn f xs == 'nubBy' ((==) `'on'` f) xs.
--   </pre>
nubOn :: Ord b => (a -> b) -> [a] -> [a]

-- | Efficient variant of <a>nubBy</a> for finite lists.
--   
--   Specification: For each list <tt>xs</tt> there is a list <tt>ys</tt>
--   which is a permutation of <tt>xs</tt> such that
--   
--   <pre>
--   uniqOn f xs == 'nubBy' ((==) `'on'` f) ys.
--   </pre>
--   
--   Furthermore
--   
--   <pre>
--   sortBy (compare `on` f) (uniqOn f xs) == uniqOn f xs.
--   </pre>
uniqOn :: Ord b => (a -> b) -> [a] -> [a]

-- | 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]
editDistanceSpec :: Eq a => [a] -> [a] -> Int
editDistance :: Eq a => [a] -> [a] -> Int

module Agda.Utils.Monad

-- | Binary bind.
(==<<) :: Monad m => (a -> b -> m c) -> (m a, m b) -> m c

-- | <tt>when_</tt> is just <tt>Control.Monad.when</tt> with a more general
--   type.
when_ :: Monad m => Bool -> m a -> m ()

-- | <tt>unless_</tt> is just <tt>Control.Monad.unless</tt> 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 guard.
guardM :: (Monad m, MonadPlus m) => m Bool -> m ()

-- | Monadic if-then-else.
ifM :: Monad m => m Bool -> m a -> m a -> m a

-- | <pre>
--   ifNotM mc = ifM (not <a>$</a> mc)
--   </pre>
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 <tt>Either</tt> truth values.
altM1 :: Monad m => (a -> m (Either err b)) -> [a] -> m (Either err b)

-- | Generalized version of <tt>mapM_ :: Monad m =&gt; (a -&gt; m ()) -&gt;
--   [a] -&gt; m ()</tt> Executes effects and collects results in
--   left-to-right order. Works best with left-associative monoids.
--   
--   Note that there is an alternative
--   
--   <pre>
--   mapM' f t = foldr mappend mempty <a>$</a> mapM f t
--   </pre>
--   
--   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 <tt>forM_ :: Monad m =&gt; [a] -&gt; (a -&gt; m
--   ()) -&gt; m ()</tt>
forM' :: (Foldable t, Monad m, Monoid b) => t a -> (a -> m b) -> m b
type Cont r a = (a -> r) -> r

-- | <a>mapM</a> 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 <tt><a>mapMaybe</a> :: (a -&gt; Maybe b) -&gt;
--   [a] -&gt; [b]</tt>.
mapMaybeM :: Monad m => (a -> m (Maybe b)) -> [a] -> m [b]

-- | The <tt>for</tt> version of <a>mapMaybeM</a>.
forMaybeM :: Monad m => [a] -> (a -> m (Maybe b)) -> m [b]

-- | A monadic version of <tt><a>dropWhile</a> :: (a -&gt; Bool) -&gt; [a]
--   -&gt; [a]</tt>.
dropWhileM :: Monad m => (a -> m Bool) -> [a] -> m [a]

-- | A `<tt>monadic'</tt> version of @<tt>partition</tt> :: (a -&gt; Bool)
--   -&gt; [a] -&gt; ([a],[a])
partitionM :: (Functor m, Applicative m) => (a -> m Bool) -> [a] -> m ([a], [a])

-- | Finally for the <a>Error</a> class. Errors in the finally part take
--   precedence over prior errors.
finally :: MonadError e m => m a -> m b -> m a

-- | Try a computation, return <a>Nothing</a> if an <a>Error</a> occurs.
tryMaybe :: (MonadError e m, Functor m) => m a -> m (Maybe 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 <a>Applicative</a> expressions. For example,
--   
--   <pre>
--   when debug (putStrLn "Debugging")
--   </pre>
--   
--   will output the string <tt>Debugging</tt> if the Boolean value
--   <tt>debug</tt> is <a>True</a>, and otherwise do nothing.
when :: Applicative f => Bool -> f () -> f ()

-- | The reverse of <a>when</a>.
unless :: Applicative f => Bool -> f () -> f ()

-- | Monads that also support choice and failure.
class (Alternative m, Monad m) => MonadPlus (m :: * -> *)

-- | the identity of <a>mplus</a>. It should also satisfy the equations
--   
--   <pre>
--   mzero &gt;&gt;= f  =  mzero
--   v &gt;&gt; mzero   =  mzero
--   </pre>
mzero :: MonadPlus m => m a

-- | an associative operation
mplus :: MonadPlus m => m a -> m a -> m a

-- | An infix synonym for <a>fmap</a>.
--   
--   The name of this operator is an allusion to <tt>$</tt>. Note the
--   similarities between their types:
--   
--   <pre>
--    ($)  ::              (a -&gt; b) -&gt;   a -&gt;   b
--   (&lt;$&gt;) :: Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
--   </pre>
--   
--   Whereas <tt>$</tt> is function application, <a>&lt;$&gt;</a> is
--   function application lifted over a <a>Functor</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Convert from a <tt><tt>Maybe</tt> <tt>Int</tt></tt> to a
--   <tt><tt>Maybe</tt> <tt>String</tt></tt> using <tt>show</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Nothing
--   Nothing
--   
--   &gt;&gt;&gt; show &lt;$&gt; Just 3
--   Just "3"
--   </pre>
--   
--   Convert from an <tt><tt>Either</tt> <tt>Int</tt> <tt>Int</tt></tt> to
--   an <tt><tt>Either</tt> <tt>Int</tt></tt> <tt>String</tt> using
--   <tt>show</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Left 17
--   Left 17
--   
--   &gt;&gt;&gt; show &lt;$&gt; Right 17
--   Right "17"
--   </pre>
--   
--   Double each element of a list:
--   
--   <pre>
--   &gt;&gt;&gt; (*2) &lt;$&gt; [1,2,3]
--   [2,4,6]
--   </pre>
--   
--   Apply <tt>even</tt> to the second element of a pair:
--   
--   <pre>
--   &gt;&gt;&gt; even &lt;$&gt; (2,2)
--   (2,True)
--   </pre>
(<$>) :: 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 <tt><a>fmap</a> . <a>const</a></tt>, but this may be
--   overridden with a more efficient version.
(<$) :: Functor f => forall a b. a -> f b -> f a

-- | A variant of <a>modify</a> in which the computation is strict in the
--   new state.
modify' :: MonadState s m => (s -> s) -> m ()


-- | Operations on file names.
module Agda.Utils.FileName

-- | Paths which are known to be absolute.
--   
--   Note that the <a>Eq</a> and <a>Ord</a> instances do not check if
--   different paths point to the same files or directories.
newtype AbsolutePath
AbsolutePath :: Text -> AbsolutePath

-- | Extract the <a>AbsolutePath</a> to be used as <a>FilePath</a>.
filePath :: AbsolutePath -> FilePath

-- | Constructs <a>AbsolutePath</a>s.
--   
--   Precondition: The path must be absolute and valid.
mkAbsolute :: FilePath -> AbsolutePath

-- | Makes the path absolute.
--   
--   This function may raise an <tt>__IMPOSSIBLE__</tt> error if
--   <a>canonicalizePath</a> 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 <a>doesFileExist</a> 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 insensitively.)
doesFileExistCaseSensitive :: FilePath -> IO Bool
rootPath :: FilePath
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


-- | 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 -> Word64


-- | 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 <tt>S ∷= ε |
--   ε</tt> succeeds twice. This change also means that parsing fails to
--   terminate for some cyclic grammars that would otherwise be handled
--   successfully, such as <tt>S ∷= S | ε</tt>. 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
class (Functor p, Applicative p, Alternative p, Monad p) => ParserClass p k r tok | p -> k, p -> r, p -> tok

-- | Runs the parser.
parse :: ParserClass p k r tok => p a -> [tok] -> [a]

-- | Tries to print the parser, or returns <a>empty</a>, depending on the
--   implementation. This function might not terminate.
grammar :: ParserClass p k r tok => p a -> Doc

-- | Parses a single token.
token :: ParserClass p k r tok => p tok

-- | Parses a token satisfying the given predicate.
sat :: ParserClass p k r tok => (tok -> Bool) -> p tok

-- | Parses a given token.
tok :: (ParserClass p k r tok, Eq tok, Show tok) => tok -> p tok

-- | Uses the given function to modify the printed representation (if any)
--   of the given parser.
annotate :: ParserClass p k r tok => (Doc -> Doc) -> p a -> p a

-- | Memoises the given parser.
--   
--   Every memoised parser must be annotated with a <i>unique</i> key.
--   (Parametrised parsers must use distinct keys for distinct inputs.)
memoise :: (ParserClass p k r tok, Eq k, Hashable k, Show k) => k -> p r -> p r

-- | Memoises the given parser, but only if printing, not if parsing.
--   
--   Every memoised parser must be annotated with a <i>unique</i> key.
--   (Parametrised parsers must use distinct keys for distinct inputs.)
memoiseIfPrinting :: (ParserClass p k r tok, Eq k, Hashable k, Show k) => k -> p r -> p r

-- | The parser type.
--   
--   The parameters of the type <tt>Parser k r tok a</tt> have the
--   following meanings:
--   
--   <ul>
--   <li><i><tt>k</tt></i> Type used for memoisation keys.</li>
--   <li><i><tt>r</tt></i> The type of memoised values. (Yes, all memoised
--   values have to have the same type.)</li>
--   <li><i><tt>tok</tt></i> The token type.</li>
--   <li><i><tt>a</tt></i> The result type.</li>
--   </ul>
data Parser k r tok a

-- | An extended parser type, with some support for printing parsers.
data ParserWithGrammar k r tok a
instance GHC.Base.Monad (Agda.Utils.Parser.MemoisedCPS.Parser k r tok)
instance GHC.Base.Functor (Agda.Utils.Parser.MemoisedCPS.Parser k r tok)
instance GHC.Base.Applicative (Agda.Utils.Parser.MemoisedCPS.Parser k r tok)
instance GHC.Base.Alternative (Agda.Utils.Parser.MemoisedCPS.Parser k r tok)
instance Agda.Utils.Parser.MemoisedCPS.ParserClass (Agda.Utils.Parser.MemoisedCPS.Parser k r tok) k r tok
instance GHC.Base.Monad (Agda.Utils.Parser.MemoisedCPS.ParserWithGrammar k r tok)
instance GHC.Base.Functor (Agda.Utils.Parser.MemoisedCPS.ParserWithGrammar k r tok)
instance GHC.Base.Applicative (Agda.Utils.Parser.MemoisedCPS.ParserWithGrammar k r tok)
instance GHC.Base.Alternative (Agda.Utils.Parser.MemoisedCPS.ParserWithGrammar k r tok)
instance Agda.Utils.Parser.MemoisedCPS.ParserClass (Agda.Utils.Parser.MemoisedCPS.ParserWithGrammar k r tok) k r tok

module Agda.Utils.String

-- | <a>quote</a> adds double quotes around the string, replaces newline
--   characters with <tt>n</tt>, and escapes double quotes and backslashes
--   within the string. This is different from the behaviour of
--   <a>show</a>:
--   
--   <pre>
--   &gt; <a>putStrLn</a> $ <a>show</a> "\x2200"
--   "\8704"
--   &gt; <a>putStrLn</a> $ <a>quote</a> "\x2200"
--   "∀"
--   </pre>
--   
--   (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 <tt>null</tt> and <tt>empty</tt> for collections and
--   sequences.
module Agda.Utils.Null
class Null a where null = (== empty)
empty :: Null a => a

-- | Satisfying <tt>null empty == True</tt>.
null :: Null a => a -> Bool

-- | Satisfying <tt>null empty == True</tt>.
null :: (Null a, Eq a) => a -> Bool

-- | A <a>Maybe</a> is <a>null</a> 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 <tt> import
--   Agda.Utils.Favorites (Favorites) import qualified Agda.Utils.Favorites
--   as Fav </tt>
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 <tt>Set</tt> 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 <tt>null
--   dominated</tt>, then <tt>notDominated</tt> 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 <tt>a</tt> 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
--   <tt>a</tt>.
--   
--   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.)
--   
--   <pre>
--   compareFavorites new old = (new', old')
--   </pre>
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. <tt>insert a l = insertCompared a l
--   (compareWithFavorites a l)</tt>
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

-- | <a>Favorites</a> forms a <a>Monoid</a> under <a>empty</a> and 'union.
instance Agda.Utils.Singleton.Singleton a (Agda.Utils.Favorites.Favorites a)
instance Agda.Utils.Null.Null (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 => Data.Semigroup.Semigroup (Agda.Utils.Favorites.Favorites a)
instance Agda.Utils.PartialOrd.PartialOrd a => GHC.Base.Monoid (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 <tt>n</tt> is
--   the number of nodes in the graph.
--   
--   However, the set of incoming edges can only be obtained in <tt>O(n log
--   n)</tt> or <tt>O(e)</tt> where <tt>e</tt> is the total number of
--   edges.
module Agda.Utils.Graph.AdjacencyMap.Unidirectional

-- | <tt>Graph s t e</tt> is a directed graph with source nodes in
--   <tt>s</tt> target nodes in <tt>t</tt> and edges in <tt>e</tt>.
--   
--   Admits at most one edge between any two nodes. Several edges can be
--   modeled by using a collection type for <tt>e</tt>.
--   
--   Represented as "adjacency list", or rather, adjacency map. This allows
--   to get all outgoing edges for a node in <tt>O(log n)</tt> time where
--   <tt>n</tt> is the number of nodes of the graph.
--   
--   Incoming edges can only be computed in <tt>O(n + e)</tt> time where
--   <tt>e</tt> 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. <tt>O(n + e)</tt>
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 <tt>O(result)</tt>.
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: <tt>O(n * |ts| * log n)</tt>.
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. <tt>O(n)</tt>.
sourceNodes :: Graph s t e -> Set s

-- | Returns all the nodes with incoming edges. Expensive! <tt>O(e)</tt>.
targetNodes :: Ord t => Graph s t e -> Set t

-- | For homogeneous graphs, <tt>(s = t)</tt> we can compute a set of all
--   nodes.
--   
--   Structure <tt>Nodes</tt> 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.
--   <tt>O(n)</tt>.
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): <tt>O(e)</tt>.
discrete :: Null e => Graph s t e -> Bool

-- | Removes <a>Null</a> edges (and empty <a>Map</a>s).
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 <tt>old</tt> edge weight with
--   <tt>new</tt> weight by given function <tt>f</tt> into <tt>f new
--   old</tt>.
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! <tt>O(n log n)</tt>.
removeNode :: Ord n => n -> Graph n n e -> Graph n n e

-- | <tt>removeEdge s t g</tt> removes the edge going from <tt>s</tt> to
--   <tt>t</tt>, if any.
--   
--   <tt>O((log n)^2)</tt>.
removeEdge :: (Ord s, Ord t) => s -> t -> Graph s t e -> Graph s t e

-- | Keep only the edges that satisfy the predicate. <tt>O(e).</tt>
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
--   <a>mapWithKey</a>.
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

-- | <a>DAG</a> 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 <tt>True</tt> iff the graph is acyclic.
acyclic :: Ord n => Graph n n e -> Bool

-- | <tt>reachableFrom g n</tt> is a map containing all nodes reachable
--   from <tt>n</tt> in <tt>g</tt>. 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: <tt>n</tt> must be a node in <tt>g</tt>. The number of
--   nodes in the graph must not be larger than <tt><a>maxBound</a> ::
--   <a>Int</a></tt>.
--   
--   Amortised time complexity (assuming that comparisons take constant
--   time): <i>O(e log n)</i>, 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])

-- | <tt>walkSatisfying every some g from to</tt> determines if there is a
--   walk from <tt>from</tt> to <tt>to</tt> in <tt>g</tt>, in which every
--   edge satisfies the predicate <tt>every</tt>, and some edge satisfies
--   the predicate <tt>some</tt>. If there are several such walks, then a
--   shortest one (in terms of the number of edges) is returned.
--   
--   Precondition: <tt>from</tt> and <tt>to</tt> must be nodes in
--   <tt>g</tt>. The number of nodes in the graph must not be larger than
--   <tt><a>maxBound</a> :: <a>Int</a></tt>.
--   
--   Amortised time complexity (assuming that comparisons and the
--   predicates take constant time to compute): <i>O(e log n)</i>.
walkSatisfying :: Ord n => (e -> Bool) -> (e -> Bool) -> Graph n n e -> n -> n -> Maybe [Edge n n e]

-- | <tt>composeWith times plus g g'</tt> finds all edges <tt>s --c_i--&gt;
--   t_i --d_i--&gt; u</tt> and constructs the result graph from
--   <tt>edge(s,u) = sum_i (c_i times d_i)</tt>.
--   
--   Complexity: for each edge <tt>s --&gt; t</tt> in <tt>g</tt> we lookup
--   up all edges starting in with <tt>t</tt> in <tt>g'</tt>.
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 <a>Agda.Termination.CallGraph</a>.
--   
--   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" <a>http://r6.ca/blog/20110808T035622Z.html</a>),
--   implemented using matrices.
--   
--   The resulting graph does not contain any zero edges.
--   
--   This algorithm should be seen as a reference implementation. In
--   practice <a>gaussJordanFloydWarshallMcNaughtonYamada</a> 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" <a>http://r6.ca/blog/20110808T035622Z.html</a>),
--   implemented using <a>Graph</a>, and with some shortcuts:
--   
--   <ul>
--   <li>Zero edge differences are not added to the graph, thus avoiding
--   some zero edges.</li>
--   <li>Strongly connected components are used to avoid computing some
--   zero edges.</li>
--   </ul>
--   
--   The graph's strongly connected components (in reverse topological
--   order) are returned along with the transitive closure.
gaussJordanFloydWarshallMcNaughtonYamada :: forall n e. (Ord n, Eq e, StarSemiRing e) => Graph n n e -> (Graph n n e, [SCC n])
instance (GHC.Show.Show e, GHC.Show.Show t, GHC.Show.Show s) => GHC.Show.Show (Agda.Utils.Graph.AdjacencyMap.Unidirectional.Edge s t e)
instance GHC.Base.Functor (Agda.Utils.Graph.AdjacencyMap.Unidirectional.Edge s t)
instance (GHC.Classes.Ord e, GHC.Classes.Ord t, GHC.Classes.Ord s) => GHC.Classes.Ord (Agda.Utils.Graph.AdjacencyMap.Unidirectional.Edge s t e)
instance (GHC.Classes.Eq e, GHC.Classes.Eq t, GHC.Classes.Eq s) => GHC.Classes.Eq (Agda.Utils.Graph.AdjacencyMap.Unidirectional.Edge s t e)
instance (GHC.Show.Show e, GHC.Show.Show t, GHC.Show.Show s) => GHC.Show.Show (Agda.Utils.Graph.AdjacencyMap.Unidirectional.Graph s t e)
instance GHC.Base.Functor (Agda.Utils.Graph.AdjacencyMap.Unidirectional.Graph s t)
instance (GHC.Classes.Eq e, GHC.Classes.Eq t, GHC.Classes.Eq s) => GHC.Classes.Eq (Agda.Utils.Graph.AdjacencyMap.Unidirectional.Graph s t e)


-- | A strict version of the <a>Maybe</a> type.
--   
--   Import qualified, as in <tt> import qualified Agda.Utils.Maybe.Strict
--   as Strict </tt>
--   
--   Copyright : (c) 2006-2007 Roman Leshchinskiy (c) 2013 Simon Meier
--   License : BSD-style (see the file LICENSE)
--   
--   Copyright : (c) 2014 Andreas Abel
module Agda.Utils.Maybe.Strict
toStrict :: Maybe a -> Maybe a
toLazy :: Maybe a -> Maybe a

-- | Analogous to <a>listToMaybe</a> in <a>Data.Maybe</a>.
listToMaybe :: [a] -> Maybe a

-- | Analogous to <a>maybeToList</a> in <a>Data.Maybe</a>.
maybeToList :: Maybe a -> [a]

-- | Analogous to <a>catMaybes</a> in <a>Data.Maybe</a>.
catMaybes :: [Maybe a] -> [a]

-- | Analogous to <a>mapMaybe</a> in <a>Data.Maybe</a>.
mapMaybe :: (a -> Maybe b) -> [a] -> [b]

-- | <tt>unionWith</tt> for collections of size &lt;= 1.
unionMaybeWith :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a

-- | Unzipping a list of length &lt;= 1.
unzipMaybe :: Maybe (a, b) -> (Maybe a, Maybe b)

-- | Filtering a singleton list.
--   
--   <pre>
--   filterMaybe p a = <a>listToMaybe</a> (<a>filter</a> p [a])
--   </pre>
filterMaybe :: (a -> Bool) -> a -> Maybe a

-- | Version of <a>mapMaybe</a> with different argument ordering.
forMaybe :: [a] -> (a -> Maybe b) -> [b]

-- | Version of <a>maybe</a> with different argument ordering. Often, we
--   want to case on a <a>Maybe</a>, do something interesting in the
--   <a>Just</a> case, but only a default action in the <a>Nothing</a>
--   case. Then, the argument ordering of <tt>caseMaybe</tt> is preferable.
--   
--   <pre>
--   caseMaybe m err f = flip (maybe err) m f
--   </pre>
caseMaybe :: Maybe a -> b -> (a -> b) -> b

-- | Monadic version of <a>maybe</a>.
maybeM :: Monad m => m b -> (a -> m b) -> m (Maybe a) -> m b

-- | Monadic version of <a>fromMaybe</a>.
fromMaybeM :: Monad m => m a -> m (Maybe a) -> m a

-- | Monadic version of <a>caseMaybe</a>. That is, <a>maybeM</a> with a
--   different argument ordering.
caseMaybeM :: Monad m => m (Maybe a) -> m b -> (a -> m b) -> m b

-- | <a>caseMaybeM</a> with flipped branches.
ifJustM :: Monad m => m (Maybe a) -> (a -> m b) -> m b -> m b

-- | A more telling name for <a>forM</a> for the <a>Maybe</a> collection
--   type. Or: <a>caseMaybe</a> without the <a>Nothing</a> case.
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()

-- | <a>caseMaybeM</a> without the <a>Nothing</a> 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 => Data.Semigroup.Semigroup (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)


-- | Collection size.
--   
--   For <tt>TermSize</tt> see <a>Agda.Syntax.Internal</a>.
module Agda.Utils.Size

-- | The size of a collection (i.e., its length).
--   
--   Should fit into an <tt>Int</tt>. TODO: change to <tt>Int</tt>.
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 <tt>Int</tt>.
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 <a>Data.Map.Strict</a> and
--   <a>Agda.Utils.Maybe.Strict</a>).
module Agda.Utils.Trie

-- | Finite map from <tt>[k]</tt> to <tt>v</tt>.
--   
--   With the strict <a>Maybe</a> type, <a>Trie</a> is also strict in
--   <tt>v</tt>.
data Trie k v
empty :: Null a => a

-- | Singleton trie.
singleton :: [k] -> v -> Trie k v

-- | <tt>everyPrefix k v</tt> is a trie where every prefix of <tt>k</tt>
--   (including <tt>k</tt> itself) is mapped to <tt>v</tt>.
everyPrefix :: [k] -> v -> Trie k v

-- | Insert. Overwrites existing value if present.
--   
--   <pre>
--   insert = insertWith ( new old -&gt; new)
--   </pre>
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.
--   
--   <tt>union = unionWith ( new old -&gt; new)</tt>.
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]

-- | Get the subtrie rooted at the given key.
lookupTrie :: Ord k => [k] -> Trie k v -> Trie k v
instance Data.Foldable.Foldable (Agda.Utils.Trie.Trie k)
instance GHC.Base.Functor (Agda.Utils.Trie.Trie k)
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)


-- | 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 three-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 CPS function to an account. Can't handle exceptions.
billToCPS :: MonadBench a m => Account a -> ((b -> m c) -> m c) -> (b -> 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 <a>lookup</a>.
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 <a>mapKeysMonotonic</a>. 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 <a>+</a> == 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 <tt>n &gt;= 0</tt>.
newtype Offset
O :: Int -> Offset

-- | Fixed size variables <tt>i</tt>.
newtype Rigid
RigidId :: String -> Rigid
[rigidId] :: Rigid -> String

-- | Size meta variables <tt>X</tt> to solve for.
newtype Flex
FlexId :: String -> Flex
[flexId] :: Flex -> String

-- | Size expressions appearing in constraints.
data SizeExpr' rigid flex

-- | Constant number <tt>n</tt>.
Const :: Offset -> SizeExpr' rigid flex
[offset] :: SizeExpr' rigid flex -> Offset

-- | Variable plus offset <tt>i + n</tt>.
Rigid :: rigid -> Offset -> SizeExpr' rigid flex
[rigid] :: SizeExpr' rigid flex -> rigid
[offset] :: SizeExpr' rigid flex -> Offset

-- | Infinity <tt>∞</tt>.
Infty :: SizeExpr' rigid flex

-- | Meta variable <tt>X + n</tt>.
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

-- | <tt>&lt;</tt>.
Lt :: Cmp

-- | <tt>≤</tt>.
Le :: Cmp

-- | Comparison operator is ordered <tt><a>Lt</a> &lt; <a>Le</a></tt>.

-- | Constraint: an inequation between size expressions, e.g. <tt>X &lt;
--   ∞</tt> or <tt>i + 3 ≤ j</tt>.
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 <a>Least</a>.
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 an error message if we have a contradictory constraint.
simplify1 :: (Show f, Show r, Eq r) => CTrans r f -> CTrans r f

-- | <a>Le</a> acts as <a>True</a>, <a>Lt</a> as <a>False</a>.
ifLe :: Cmp -> a -> a -> a

-- | Interpret <a>Cmp</a> as relation on <a>Offset</a>.
compareOffset :: Offset -> Cmp -> Offset -> Bool

-- | Offsets <tt>+ n</tt> 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 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 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.Syntax.Substitute r f a => Agda.TypeChecking.SizedTypes.Syntax.Substitute r f (Data.Map.Base.Map k 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]

-- | <tt>Set.foldl</tt> does not exist in legacy versions of the
--   <tt>containers</tt> 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 <tt>Num</tt>.

-- | Test for negativity, used to detect negative cycles.
class Negative a
negative :: Negative a => a -> Bool

-- | Going from <tt>Lt</tt> to <tt>Le</tt> is <tt>pred</tt>, going from
--   <tt>Le</tt> to <tt>Lt</tt> is <tt>succ</tt>.
--   
--   <tt>X --(R,n)--&gt; Y</tt> means <tt>X (R) Y + n</tt>. [ ... if
--   <tt>n</tt> positive and <tt>X + (-n) (R) Y</tt> if <tt>n</tt>
--   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 <a>Lt</a>.
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 <tt>gs</tt> into those that mention node
--   <tt>n</tt> and those that do not. If <tt>n</tt> 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 <tt>0 -&gt; n -&gt; n -&gt; oo</tt> for
--   all nodes <tt>n</tt>.
reflClos :: (Ord r, Ord f, Dioid a) => Set (Node r f) -> Graph r f a -> Graph r f a

-- | A graph is <a>negative</a> if it contains a negative loop (diagonal
--   edge). Makes sense on transitive graphs.

-- | <tt>h <a>implies</a> g</tt> if any edge in <tt>g</tt> between rigids
--   and constants is implied by a corresponding edge in <tt>h</tt>, which
--   means that the edge in <tt>g</tt> carries at most the information of
--   the one in <tt>h</tt>.
--   
--   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 <tt>X + n &lt;= X</tt> (with n &gt;= 0), we must
--   set <tt>X = oo</tt>.
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

-- | These metas are &lt; ∞.
[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--&gt; 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--&gt; 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 ()

-- | Iterate solver until no more metas can be solved.
--   
--   This might trigger a (wanted) error on the second iteration (see Issue
--   2096) which would otherwise go unnoticed.
iterateSolver :: (Ord r, Ord f, Show r, Show f) => Polarities f -> HypGraph r f -> [Constraint' r f] -> Solution r f -> Either String (Solution r f)
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 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 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)


-- | Semirings.
module Agda.Termination.Semiring

-- | <tt>HasZero</tt> 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
--   <tt>SemiRing</tt> which is definable without the implicit
--   <tt>?cutoff</tt>.
class Eq a => HasZero a
zeroElement :: HasZero 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
integerSemiring :: Semiring Integer
intSemiring :: Semiring Int

-- | The standard semiring on <a>Bool</a>s.
boolSemiring :: Semiring 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: <tt>n log n</tt> where
--   <tt>n</tt> 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 :: Size i -> [(MIx i, b)] -> Matrix i b

-- | Dimensions of the matrix.
[size] :: Matrix i b -> Size i

-- | Association of indices to values.
[unM] :: Matrix i b -> [(MIx i, b)]

-- | Size of a matrix.
data Size i
Size :: i -> i -> Size i

-- | Number of rows, <tt>&gt;= 0</tt>.
[rows] :: Size i -> i

-- | Number of columns, <tt>&gt;= 0</tt>.
[cols] :: Size i -> i

-- | Type of matrix indices (row, column).
data MIx i
MIx :: i -> i -> MIx i

-- | Row index, <tt>1 &lt;= row &lt;= rows</tt>.
[row] :: MIx i -> i

-- | Column index <tt>1 &lt;= col &lt;= cols</tt>.
[col] :: MIx i -> i

-- | <tt><a>fromLists</a> sz rs</tt> constructs a matrix from a list of
--   lists of values (a list of rows). <tt>O(size)</tt> where <tt>size =
--   rows × cols</tt>.
--   
--   Precondition: <tt><a>length</a> rs <a>==</a> <a>rows</a> sz</tt> and
--   <tt><a>all</a> ((<a>cols</a> sz <a>==</a>) . <a>length</a>) rs</tt>.
fromLists :: (Ord i, Num i, Enum i, HasZero b) => Size i -> [[b]] -> Matrix i b

-- | Constructs a matrix from a list of <tt>(index, value)</tt>-pairs.
--   <tt>O(n)</tt> where <tt>n</tt> 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. <tt>O(size)</tt> where
--   <tt>size = rows × cols</tt>.
toLists :: (Integral i, HasZero b) => Matrix i b -> [[b]]

-- | <a>True</a> iff the matrix is square.
square :: Ix i => Matrix i b -> Bool

-- | Returns <a>True</a> 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
--   <tt>b</tt>. <tt>O(1)</tt>.
isSingleton :: (Eq i, Num i, HasZero b) => Matrix i b -> Maybe b

-- | General pointwise combination function for sparse matrices. <tt>O(n1 +
--   n2)</tt>.
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

-- | <tt><a>add</a> (+) m1 m2</tt> adds <tt>m1</tt> and <tt>m2</tt>, using
--   <tt>(+)</tt> to add values. <tt>O(n1 + n2)</tt>.
--   
--   Returns a matrix of size <tt><a>supSize</a> m1 m2</tt>.
add :: (Ord i, HasZero a) => (a -> a -> a) -> Matrix i a -> Matrix i a -> Matrix i a

-- | <tt><a>intersectWith</a> f m1 m2</tt> build the pointwise conjunction
--   <tt>m1</tt> and <tt>m2</tt>. Uses <tt>f</tt> to combine non-zero
--   values. <tt>O(n1 + n2)</tt>.
--   
--   Returns a matrix of size <tt>infSize m1 m2</tt>.
intersectWith :: (Ord i) => (a -> a -> a) -> Matrix i a -> Matrix i a -> Matrix i a

-- | Association list intersection. <tt>O(n1 + n2)</tt>.
--   
--   <pre>
--   interAssocWith f l l' = { (i, f a b) | (i,a) ∈ l and (i,b) ∈ l' }
--   </pre>
--   
--   Used to combine sparse matrices, it might introduce zero elements if
--   <tt>f</tt> can return zero for non-zero arguments.
interAssocWith :: (Ord i) => (a -> a -> a) -> [(i, a)] -> [(i, a)] -> [(i, a)]

-- | <tt><a>mul</a> semiring m1 m2</tt> multiplies matrices <tt>m1</tt> and
--   <tt>m2</tt>. Uses the operations of the semiring <tt>semiring</tt> to
--   perform the multiplication.
--   
--   <tt>O(n1 + n2 log n2 + Σ(i &lt;= r1) Σ(j &lt;= c2) d(i,j))</tt> where
--   <tt>r1</tt> is the number of non-empty rows in <tt>m1</tt> and
--   <tt>c2</tt> is the number of non-empty columns in <tt>m2</tt> and
--   <tt>d(i,j)</tt> is the bigger one of the following two quantifies: the
--   length of sparse row <tt>i</tt> in <tt>m1</tt> and the length of
--   sparse column <tt>j</tt> in <tt>m2</tt>.
--   
--   Given dimensions <tt>m1 : r1 × c1</tt> and <tt>m2 : r2 × c2</tt>, a
--   matrix of size <tt>r1 × c2</tt> is returned. It is not necessary that
--   <tt>c1 == r2</tt>, 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

-- | <tt><a>diagonal</a> m</tt> extracts the diagonal of <tt>m</tt>.
--   
--   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]

-- | Converts a sparse matrix to a sparse list of rows. <tt>O(n)</tt> where
--   <tt>n</tt> is the number of non-zero entries of the matrix.
--   
--   Only non-empty rows are generated.
toSparseRows :: (Eq i) => Matrix i b -> [(i, [(i, b)])]

-- | Compute the matrix size of the union of two matrices.
supSize :: Ord i => Matrix i a -> Matrix i b -> Size i

-- | <tt><a>addRow</a> x m</tt> adds a new row to <tt>m</tt>, after the
--   rows already existing in the matrix. All elements in the new row get
--   set to <tt>x</tt>.
addRow :: (Num i, HasZero b) => b -> Matrix i b -> Matrix i b

-- | <tt><a>addColumn</a> x m</tt> adds a new column to <tt>m</tt>, after
--   the columns already existing in the matrix. All elements in the new
--   column get set to <tt>x</tt>.
addColumn :: (Num i, HasZero b) => b -> Matrix i b -> Matrix i b
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)


-- | Defines <a>CutOff</a> type which is used in
--   <a>Agda.Interaction.Options</a>. This module's purpose is to eliminate
--   the dependency of <a>Agda.TypeChecking.Monad.Base</a> 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

-- | <tt>c &gt;= 0</tt> means: record decrease up to including
--   <tt>c+1</tt>.
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
--   <tt><a>Unknown</a> <a>&lt;=</a> <tt>Le</tt> <a>&lt;=</a>
--   <tt>Lt</tt></tt>.
--   
--   This is generalized to <tt><a>Unknown</a> <a>&lt;=</a> 'Decr k'</tt>
--   where <tt>Decr 1</tt> replaces <tt>Lt</tt> and <tt>Decr 0</tt>
--   replaces <tt>Le</tt>. 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 <tt>cutoff</tt> point
--   which determines how high the termination checker can count. This
--   value should be set by a global or file-wise option.
--   
--   See <tt>Call</tt> for more information.
--   
--   TODO: document orders which are call-matrices themselves.
data Order

-- | Decrease of callee argument wrt. caller parameter.
Decr :: {-# UNPACK #-} !Int -> Order

-- | No relation, infinite increase, or increase beyond termination depth.
Unknown :: Order

-- | Matrix-shaped order, currently UNUSED.
Mat :: {-# UNPACK #-} !(Matrix Int Order) -> Order

-- | Smart constructor for <tt>Decr k :: Order</tt> which cuts off too big
--   values.
--   
--   Possible values for <tt>k</tt>: <tt>- ?cutoff <a>&lt;=</a> k
--   <a>&lt;=</a> ?cutoff + 1</tt>.
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 <a>Order</a>s. (Corresponds to sequential
--   composition.)
(.*.) :: (?cutoff :: CutOff) => Order -> Order -> Order

-- | The supremum of a (possibly empty) list of <a>Order</a>s. More
--   information (i.e., more decrease) is bigger. <a>Unknown</a> is no
--   information, thus, smallest.
supremum :: (?cutoff :: CutOff) => [Order] -> Order

-- | The infimum of a (non empty) list of <a>Order</a>s. Gets the worst
--   information. <a>Unknown</a> is the least element, thus, dominant.
infimum :: (?cutoff :: CutOff) => [Order] -> Order

-- | We use a record for semiring instead of a type class since implicit
--   arguments cannot occur in instance constraints, like <tt>instance
--   (?cutoff :: Int) =&gt; SemiRing Order</tt>.
orderSemiring :: (?cutoff :: CutOff) => Semiring Order

-- | <tt>le</tt>, <tt>lt</tt>, <tt>decreasing</tt>, <tt>unknown</tt>: 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
isOrder :: (?cutoff :: CutOff) => Order -> 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.Semiring.HasZero o, Agda.Termination.Order.NotWorse o) => Agda.Termination.Order.NotWorse (Agda.Termination.SparseMatrix.Matrix i o)
instance Agda.Utils.Pretty.Pretty Agda.Termination.Order.Order

module Agda.Termination.CallMatrix

-- | Call matrix indices = function argument indices.
--   
--   Machine integer <a>Int</a> 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 <tt>f --&gt; g</tt> has dimensions <tt>ar(g)
--   × ar(f)</tt>.
--   
--   Each column corresponds to one formal argument of caller <tt>f</tt>.
--   Each row corresponds to one argument in the call to <tt>g</tt>.
--   
--   In the presence of dot patterns, a call argument can be related to
--   <i>several</i> different formal arguments of <tt>f</tt>.
--   
--   See e.g. <tt>test<i>succeed</i>DotPatternTermination.agda</tt>:
--   
--   <pre>
--   data D : Nat -&gt; Set where
--     cz : D zero
--     c1 : forall n -&gt; D n -&gt; D (suc n)
--     c2 : forall n -&gt; D n -&gt; D n
--   
--   f : forall n -&gt; D n -&gt; Nat
--   f .zero    cz        = zero
--   f .(suc n) (c1  n d) = f n (c2 n d)
--   f n        (c2 .n d) = f n d
--   
--   </pre>
--   
--   Call matrices (without guardedness) are
--   
--   <pre>
--   -1 -1   n &lt; suc n  and       n &lt;  c1 n d
--    ?  =                   c2 n d &lt;= c1 n d
--   
--    = -1   n &lt;= n     and  n &lt; c2 n d
--    ? -1                   d &lt; c2 n d
--   
--   </pre>
--   
--   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 <tt>source</tt>
--   function arguments (patterns). The rows of the matrix stand for
--   <tt>target</tt> function arguments. Element <tt>(i, j)</tt> in the
--   matrix should be computed as follows:
--   
--   <ul>
--   <li><a>lt</a> (less than) if the <tt>j</tt>-th argument to the
--   <tt>target</tt> function is structurally strictly smaller than the
--   <tt>i</tt>-th pattern.</li>
--   <li><a>le</a> (less than or equal) if the <tt>j</tt>-th argument to
--   the <tt>target</tt> function is structurally smaller than the
--   <tt>i</tt>-th pattern.</li>
--   <li><a>unknown</a> otherwise.</li>
--   </ul>
newtype CallMatrix' a
CallMatrix :: Matrix ArgumentIndex a -> CallMatrix' a
[mat] :: CallMatrix' a -> Matrix ArgumentIndex a
type CallMatrix = CallMatrix' Order

-- | Call matrix multiplication and call combination.
class CallComb a
(>*<) :: (CallComb a, ?cutoff :: CutOff) => a -> a -> a

-- | Call matrix multiplication.
--   
--   <tt>f --(m1)--&gt; g --(m2)--&gt; h</tt> is combined to <tt>f --(m2
--   <a>mul</a> m1)--&gt; h</tt>
--   
--   Note the reversed order of multiplication: The matrix <tt>c1</tt> of
--   the second call <tt>g--&gt;h</tt> in the sequence
--   <tt>f--&gt;g--&gt;h</tt> is multiplied with the matrix <tt>c2</tt> of
--   the first call.
--   
--   Preconditions: <tt>m1</tt> has dimensions <tt>ar(g) × ar(f)</tt>.
--   <tt>m2</tt> has dimensions <tt>ar(h) × ar(g)</tt>.
--   
--   Postcondition: <tt>m1 &gt;*&lt; m2</tt> has dimensions <tt>ar(h) ×
--   ar(f)</tt>.

-- | Call matrix augmented with path information.
data CallMatrixAug cinfo
CallMatrixAug :: CallMatrix -> cinfo -> CallMatrixAug cinfo

-- | The matrix of the (composed call).
[augCallMatrix] :: CallMatrixAug cinfo -> CallMatrix

-- | Meta info, like call path.
[augCallInfo] :: CallMatrixAug cinfo -> cinfo

-- | Augmented call matrix multiplication.

-- | Non-augmented call matrix.
noAug :: Monoid cinfo => CallMatrix -> CallMatrixAug cinfo

-- | Sets of incomparable call matrices augmented with path information.
--   Use overloaded <a>null</a>, <a>empty</a>, <a>singleton</a>,
--   <a>mappend</a>.
newtype CMSet cinfo
CMSet :: Favorites (CallMatrixAug cinfo) -> CMSet cinfo
[cmSet] :: CMSet cinfo -> Favorites (CallMatrixAug cinfo)

-- | Call matrix set product is the Cartesian product.

-- | Insert into a call matrix set.
insert :: CallMatrixAug cinfo -> CMSet cinfo -> CMSet cinfo

-- | Union two call matrix sets.
union :: CMSet cinfo -> CMSet cinfo -> CMSet cinfo

-- | Convert into a list of augmented call matrices.
toList :: CMSet cinfo -> [CallMatrixAug cinfo]
instance Agda.Utils.Singleton.Singleton (Agda.Termination.CallMatrix.CallMatrixAug cinfo) (Agda.Termination.CallMatrix.CMSet cinfo)
instance Agda.Utils.Null.Null (Agda.Termination.CallMatrix.CMSet cinfo)
instance GHC.Base.Monoid (Agda.Termination.CallMatrix.CMSet cinfo)
instance Data.Semigroup.Semigroup (Agda.Termination.CallMatrix.CMSet cinfo)
instance GHC.Show.Show cinfo => GHC.Show.Show (Agda.Termination.CallMatrix.CMSet cinfo)
instance GHC.Show.Show cinfo => GHC.Show.Show (Agda.Termination.CallMatrix.CallMatrixAug cinfo)
instance GHC.Classes.Eq cinfo => GHC.Classes.Eq (Agda.Termination.CallMatrix.CallMatrixAug cinfo)
instance Agda.Utils.PartialOrd.PartialOrd a => Agda.Utils.PartialOrd.PartialOrd (Agda.Termination.CallMatrix.CallMatrix' a)
instance Data.Traversable.Traversable Agda.Termination.CallMatrix.CallMatrix'
instance Data.Foldable.Foldable Agda.Termination.CallMatrix.CallMatrix'
instance GHC.Base.Functor Agda.Termination.CallMatrix.CallMatrix'
instance (GHC.Show.Show a, Agda.Termination.Semiring.HasZero a) => GHC.Show.Show (Agda.Termination.CallMatrix.CallMatrix' a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Agda.Termination.CallMatrix.CallMatrix' a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Agda.Termination.CallMatrix.CallMatrix' a)
instance Agda.Termination.Order.NotWorse (Agda.Termination.CallMatrix.CallMatrix' Agda.Termination.Order.Order)
instance Agda.Termination.Semiring.HasZero a => Agda.Termination.SparseMatrix.Diagonal (Agda.Termination.CallMatrix.CallMatrix' a) a
instance Agda.Termination.CallMatrix.CallComb Agda.Termination.CallMatrix.CallMatrix
instance Agda.Termination.SparseMatrix.Diagonal (Agda.Termination.CallMatrix.CallMatrixAug cinfo) Agda.Termination.Order.Order
instance Agda.Utils.PartialOrd.PartialOrd (Agda.Termination.CallMatrix.CallMatrixAug cinfo)
instance Agda.Termination.Order.NotWorse (Agda.Termination.CallMatrix.CallMatrixAug cinfo)
instance GHC.Base.Monoid cinfo => Agda.Termination.CallMatrix.CallComb (Agda.Termination.CallMatrix.CallMatrixAug cinfo)
instance GHC.Base.Monoid cinfo => Agda.Termination.CallMatrix.CallComb (Agda.Termination.CallMatrix.CMSet cinfo)
instance Agda.Utils.Pretty.Pretty Agda.Termination.CallMatrix.CallMatrix
instance Agda.Utils.Pretty.Pretty cinfo => Agda.Utils.Pretty.Pretty (Agda.Termination.CallMatrix.CallMatrixAug cinfo)
instance Agda.Utils.Pretty.Pretty cinfo => Agda.Utils.Pretty.Pretty (Agda.Termination.CallMatrix.CMSet cinfo)


-- | Call graphs and related concepts, more or less as defined in "A
--   Predicative Analysis of Structural Recursion" by Andreas Abel and
--   Thorsten Altenkirch.
module Agda.Termination.CallGraph

-- | Call graph nodes.
--   
--   Machine integer <a>Int</a> is sufficient, since we cannot index more
--   than we have addresses on our machine.
type Node = Int

-- | Calls are edges in the call graph. It can be labelled with several
--   call matrices if there are several pathes from one function to
--   another.
type Call cinfo = Edge Node Node (CMSet cinfo)

-- | Make a call with a single matrix.
mkCall :: Node -> Node -> CallMatrix -> cinfo -> Call cinfo

-- | Make a call with empty <tt>cinfo</tt>.
mkCall' :: Monoid cinfo => Node -> Node -> CallMatrix -> Call cinfo

-- | Outgoing node.
source :: Edge s t e -> s

-- | Incoming node.
target :: Edge s t e -> t
callMatrixSet :: Call cinfo -> CMSet cinfo
(>*<) :: (CallComb a, ?cutoff :: CutOff) => a -> a -> a

-- | A call graph is a set of calls. Every call also has some associated
--   meta information, which should be <a>Monoid</a>al so that the meta
--   information for different calls can be combined when the calls are
--   combined.
newtype CallGraph cinfo
CallGraph :: Graph Node Node (CMSet cinfo) -> CallGraph cinfo
[theCallGraph] :: CallGraph cinfo -> Graph Node Node (CMSet cinfo)

-- | Returns all the nodes with incoming edges. Somewhat expensive.
--   <tt>O(e)</tt>.
targetNodes :: CallGraph cinfo -> Set Node

-- | Converts a list of calls with associated meta information to a call
--   graph.
fromList :: [Call cinfo] -> CallGraph cinfo

-- | Converts a call graph to a list of calls with associated meta
--   information.
toList :: CallGraph cinfo -> [Call cinfo]

-- | Takes the union of two call graphs.
union :: CallGraph cinfo -> CallGraph cinfo -> CallGraph cinfo

-- | Inserts a call into a call graph.
insert :: Node -> Node -> CallMatrix -> cinfo -> CallGraph cinfo -> CallGraph cinfo

-- | Call graph comparison. A graph <tt>cs'</tt> is `<tt>worse'</tt> than
--   <tt>cs</tt> if it has a new edge (call) or a call got worse, which
--   means that one of its elements that was better or equal to <tt>Le</tt>
--   moved a step towards <tt>Un</tt>.
--   
--   A call graph is complete if combining it with itself does not make it
--   any worse. This is sound because of monotonicity: By combining a graph
--   with itself, it can only get worse, but if it does not get worse after
--   one such step, it gets never any worse.
--   
--   <tt><a>complete</a> cs</tt> completes the call graph <tt>cs</tt>. A
--   call graph is complete if it contains all indirect calls; if <tt>f
--   -&gt; g</tt> and <tt>g -&gt; h</tt> are present in the graph, then
--   <tt>f -&gt; h</tt> should also be present.
complete :: (?cutoff :: CutOff) => Monoid cinfo => CallGraph cinfo -> CallGraph cinfo
completionStep :: (?cutoff :: CutOff) => Monoid cinfo => CallGraph cinfo -> CallGraph cinfo -> (CallGraph cinfo, CallGraph cinfo)
instance GHC.Show.Show cinfo => GHC.Show.Show (Agda.Termination.CallGraph.CallGraph cinfo)
instance Agda.Termination.CallGraph.CombineNewOld (Agda.Termination.CallMatrix.CMSet cinfo)
instance Agda.Utils.Null.Null (Agda.Termination.CallGraph.CallGraph cinfo)
instance Data.Semigroup.Semigroup (Agda.Termination.CallGraph.CallGraph cinfo)
instance GHC.Base.Monoid (Agda.Termination.CallGraph.CallGraph cinfo)
instance Agda.Utils.PartialOrd.PartialOrd a => Agda.Termination.CallGraph.CombineNewOld (Agda.Utils.Favorites.Favorites a)
instance (GHC.Base.Monoid a, Agda.Termination.CallGraph.CombineNewOld a, GHC.Classes.Ord s, GHC.Classes.Ord t) => Agda.Termination.CallGraph.CombineNewOld (Agda.Utils.Graph.AdjacencyMap.Unidirectional.Graph s t a)
instance Agda.Utils.Pretty.Pretty cinfo => Agda.Utils.Pretty.Pretty (Agda.Termination.CallGraph.CallGraph cinfo)


-- | Termination checker, based on "A Predicative Analysis of Structural
--   Recursion" by Andreas Abel and Thorsten Altenkirch (JFP'01), and "The
--   Size-Change Principle for Program Termination" by Chin Soon Lee, Neil
--   Jones, and Amir Ben-Amram (POPL'01).
module Agda.Termination.Termination

-- | TODO: This comment seems to be partly out of date.
--   
--   <tt><a>terminates</a> cs</tt> checks if the functions represented by
--   <tt>cs</tt> terminate. The call graph <tt>cs</tt> should have one
--   entry (<a>Call</a>) per recursive function application.
--   
--   <tt><a>Right</a> perms</tt> is returned if the functions are
--   size-change terminating.
--   
--   If termination can not be established, then <tt><a>Left</a>
--   problems</tt> is returned instead. Here <tt>problems</tt> contains an
--   indication of why termination cannot be established. See
--   <tt>lexOrder</tt> for further details.
--   
--   Note that this function assumes that all data types are strictly
--   positive.
--   
--   The termination criterion is taken from Jones et al. In the completed
--   call graph, each idempotent call-matrix from a function to itself must
--   have a decreasing argument. Idempotency is wrt. matrix multiplication.
--   
--   This criterion is strictly more liberal than searching for a
--   lexicographic order (and easier to implement, but harder to justify).
terminates :: (Monoid cinfo, ?cutoff :: CutOff) => CallGraph cinfo -> Either cinfo ()
terminatesFilter :: (Monoid cinfo, ?cutoff :: CutOff) => (Node -> Bool) -> CallGraph cinfo -> Either cinfo ()
endos :: [Call cinfo] -> [CallMatrixAug cinfo]

-- | A call <tt>c</tt> is idempotent if it is an endo (<tt><a>source</a> ==
--   <a>target</a></tt>) of order 1. (Endo-calls of higher orders are e.g.
--   argument permutations). We can test idempotency by self-composition.
--   Self-composition <tt>c &gt;*&lt; c</tt> should not make any
--   parameter-argument relation worse.
idempotent :: (?cutoff :: CutOff) => CallMatrixAug cinfo -> Bool


-- | Position information for syntax. Crucial for giving good error
--   messages.
module Agda.Syntax.Position
type Position = Position' SrcFile
type PositionWithoutFile = Position' ()

-- | Represents a point in the input.
--   
--   If two positions have the same <a>srcFile</a> and <a>posPos</a>
--   components, then the final two components should be the same as well,
--   but since this can be hard to enforce the program should not rely too
--   much on the last two components; they are mainly there to improve
--   error messages for the user.
--   
--   Note the invariant which positions have to satisfy:
--   <a>positionInvariant</a>.
data Position' a
Pn :: !a -> !Int32 -> !Int32 -> !Int32 -> Position' a

-- | File.
[srcFile] :: Position' a -> !a

-- | Position, counting from 1.
[posPos] :: Position' a -> !Int32

-- | Line number, counting from 1.
[posLine] :: Position' a -> !Int32

-- | Column number, counting from 1.
[posCol] :: Position' a -> !Int32
type SrcFile = Maybe AbsolutePath
positionInvariant :: Position' a -> Bool

-- | The first position in a file: position 1, line 1, column 1.
startPos :: Maybe AbsolutePath -> Position

-- | Advance the position by one character. A newline character
--   (<tt>'\n'</tt>) moves the position to the first character in the next
--   line. Any other character moves the position to the next column.
movePos :: Position' a -> Char -> Position' a

-- | Advance the position by a string.
--   
--   <pre>
--   movePosByString = foldl' movePos
--   </pre>
movePosByString :: Position' a -> String -> Position' a

-- | Backup the position by one character.
--   
--   Precondition: The character must not be <tt>'\n'</tt>.
backupPos :: Position' a -> Position' a

-- | The first position in a file: position 1, line 1, column 1.
startPos' :: a -> Position' a
type Interval = Interval' SrcFile
type IntervalWithoutFile = Interval' ()

-- | An interval. The <tt>iEnd</tt> position is not included in the
--   interval.
--   
--   Note the invariant which intervals have to satisfy:
--   <a>intervalInvariant</a>.
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

-- | Gets the <a>srcFile</a> component of the interval. Because of the
--   invariant, they are both the same.
getIntervalFile :: Interval' a -> a

-- | The length of an interval.
iLength :: Interval' a -> Int32

-- | Finds the least interval which covers the arguments.
--   
--   Precondition: The intervals must point to the same file.
fuseIntervals :: Ord a => Interval' a -> Interval' a -> Interval' a

-- | Sets the <a>srcFile</a> components of the interval.
setIntervalFile :: a -> Interval' b -> 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:
--   <a>rangeInvariant</a>.
data Range' a
NoRange :: Range' a
Range :: !a -> (Seq IntervalWithoutFile) -> 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: <a>consecutiveAndSeparated</a>.
intervalsToRange :: a -> [IntervalWithoutFile] -> Range' a

-- | Converts a file name and an interval to a range.
intervalToRange :: a -> IntervalWithoutFile -> Range' a

-- | The intervals that make up the range. The intervals are consecutive
--   and separated (<a>consecutiveAndSeparated</a>).
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

-- | Converts a range to an interval, if possible.
rangeToIntervalWithFile :: Range' a -> Maybe (Interval' a)

-- | 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 <tt><a>getRange</a> (<a>setRange</a> r x) ==
--   r</tt>.
class HasRange t => SetRange t
setRange :: SetRange t => Range -> t -> t

-- | Killing the range of an object sets all range information to
--   <a>noRange</a>.
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

-- | <tt>x `withRangeOf` y</tt> sets the range of <tt>x</tt> to the range
--   of <tt>y</tt>.
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

-- | <tt>fuseRanges r r'</tt> unions the ranges <tt>r</tt> and <tt>r'</tt>.
--   
--   Meaning it finds the least range <tt>r0</tt> that covers <tt>r</tt>
--   and <tt>r'</tt>.
--   
--   Precondition: The ranges must point to the same file (or be empty).
fuseRanges :: (Ord a) => Range' a -> Range' a -> Range' a

-- | <tt>beginningOf r</tt> is an empty range (a single, empty interval)
--   positioned at the beginning of <tt>r</tt>. If <tt>r</tt> does not have
--   a beginning, then <a>noRange</a> is returned.
beginningOf :: Range -> Range

-- | <tt>beginningOfFile r</tt> is an empty range (a single, empty
--   interval) at the beginning of <tt>r</tt>'s starting position's file.
--   If there is no such position, then an empty range is returned.
beginningOfFile :: Range -> Range

-- | Interleaves two streams of ranged elements
--   
--   It will report the conflicts as a list of conflicting pairs. In case
--   of conflict, the element with the earliest start position is placed
--   first. In case of a tie, the element with the earliest ending position
--   is placed first. If both tie, the element from the first list is
--   placed first.
interleaveRanges :: (HasRange a) => [a] -> [a] -> ([a], [(a, a)])
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)

module Agda.Utils.Permutation

-- | Partial permutations. Examples:
--   
--   <tt>permute [1,2,0] [x0,x1,x2] = [x1,x2,x0]</tt> (proper permutation).
--   
--   <tt>permute [1,0] [x0,x1,x2] = [x1,x0]</tt> (partial permuation).
--   
--   <tt>permute [1,0,1,2] [x0,x1,x2] = [x1,x0,x1,x2]</tt> (not a
--   permutation because not invertible).
--   
--   Agda typing would be: <tt>Perm : {m : Nat}(n : Nat) -&gt; Vec (Fin n)
--   m -&gt; Permutation</tt> <tt>m</tt> is the <a>size</a> of the
--   permutation.
data Permutation
Perm :: Int -> [Int] -> Permutation
[permRange] :: Permutation -> Int
[permPicks] :: Permutation -> [Int]

-- | <tt>permute [1,2,0] [x0,x1,x2] = [x1,x2,x0]</tt> More precisely,
--   <tt>permute indices list = sublist</tt>, generates <tt>sublist</tt>
--   from <tt>list</tt> by picking the elements of list as indicated by
--   <tt>indices</tt>. <tt>permute [1,3,0] [x0,x1,x2,x3] = [x1,x3,x0]</tt>
--   
--   Agda typing: <tt>permute (Perm {m} n is) : Vec A m -&gt; Vec A n</tt>
permute :: Permutation -> [a] -> [a]
safePermute :: Permutation -> [a] -> [Maybe a]

-- | Invert a Permutation on a partial finite int map. <tt>inversePermute
--   perm f = f'</tt> such that <tt>permute perm f' = f</tt>
--   
--   Example, with map represented as <tt>[Maybe a]</tt>: <tt> f =
--   [Nothing, Just a, Just b ] perm = Perm 4 [3,0,2] f' = [ Just a ,
--   Nothing , Just b , Nothing ] </tt> Zipping <tt>perm</tt> with
--   <tt>f</tt> gives <tt>[(0,a),(2,b)]</tt>, after compression with
--   <tt>catMaybes</tt>. This is an <tt>IntMap</tt> 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 <tt>n</tt> elements, discarding
--   picks <tt>&gt;=n</tt>.
takeP :: Int -> Permutation -> Permutation

-- | Pick the elements that are not picked by the permutation.
droppedP :: Permutation -> Permutation

-- | <tt>liftP k</tt> takes a <tt>Perm {m} n</tt> to a <tt>Perm {m+k}
--   (n+k)</tt>. Analogous to <a>liftS</a>, but Permutations operate on de
--   Bruijn LEVELS, not indices.
liftP :: Int -> Permutation -> Permutation

-- | <pre>
--   permute (compose p1 p2) == permute p1 . permute p2
--   </pre>
composeP :: Permutation -> Permutation -> Permutation

-- | <tt>invertP err p</tt> is the inverse of <tt>p</tt> where defined,
--   otherwise defaults to <tt>err</tt>. <tt>composeP p (invertP err p) ==
--   p</tt>
invertP :: Int -> Permutation -> Permutation

-- | Turn a possible non-surjective permutation into a surjective
--   permutation.
compactP :: Permutation -> Permutation

-- | <pre>
--   permute (reverseP p) xs ==
--       reverse $ permute p $ reverse xs
--   </pre>
--   
--   Example: <tt> 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] </tt>
--   
--   With <tt>reverseP</tt>, you can convert a permutation on de Bruijn
--   indices to one on de Bruijn levels, and vice versa.
reverseP :: Permutation -> Permutation

-- | <tt>permPicks (flipP p) = permute p (downFrom (permRange p))</tt> or
--   <tt>permute (flipP (Perm n xs)) [0..n-1] = permute (Perm n xs)
--   (downFrom n)</tt>
--   
--   Can be use to turn a permutation from (de Bruijn) levels to levels to
--   one from levels to indices.
--   
--   See <a>numberPatVars</a>.
flipP :: Permutation -> Permutation

-- | <tt>expandP i n π</tt> in the domain of <tt>π</tt> replace the
--   <i>i</i>th element by <i>n</i> 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" 241))
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

module Agda.Syntax.Parser.Monad

-- | The parse monad. Equivalent to <tt>StateT <a>ParseState</a> (Either
--   <a>ParseError</a>)</tt> except for the definition of <tt>fail</tt>,
--   which builds a suitable <a>ParseError</a> 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

-- | Errors that arise at a specific position in the file
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

-- | Parse errors that concern a range in a file.
OverlappingTokensError :: !(Range' SrcFile) -> ParseError

-- | The range of the bigger overlapping token
[errRange] :: ParseError -> !(Range' SrcFile)

-- | Parse errors that concern a whole file.
InvalidExtensionError :: !AbsolutePath -> [String] -> ParseError

-- | The file which the error concerns.
[errPath] :: ParseError -> !AbsolutePath
[errValidExts] :: ParseError -> [String]
ReadFileError :: !AbsolutePath -> IOError -> ParseError

-- | The file which the error concerns.
[errPath] :: ParseError -> !AbsolutePath
[errIOError] :: ParseError -> IOError

-- | Warnings for parsing
data ParseWarning

-- | Parse errors that concern a range in a file.
OverlappingTokensWarning :: !(Range' SrcFile) -> ParseWarning

-- | The range of the bigger overlapping token
[warnRange] :: ParseWarning -> !(Range' SrcFile)

-- | To do context sensitive lexing alex provides what is called <i>start
--   codes</i> in the Alex documentation. It is really an integer
--   representing the state of the lexer, so we call it <tt>LexState</tt>
--   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
--   <a>Agda.Syntax.Parser.Layout</a> 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
--   <a>Agda.Syntax.Parser</a> will define more specialised functions that
--   supply the <a>ParseFlags</a> and the <a>LexState</a>.
parse :: ParseFlags -> [LexState] -> Parser a -> String -> ParseResult a

-- | The most general way of parsing a file. The <a>Agda.Syntax.Parser</a>
--   will define more specialised functions that supply the
--   <a>ParseFlags</a> and the <a>LexState</a>.
--   
--   Note that Agda source files always use the UTF-8 character encoding.
parseFile :: ParseFlags -> [LexState] -> Parser a -> AbsolutePath -> IO (ParseResult a)

-- | The even more general way of parsing a string.
parsePosString :: Position -> ParseFlags -> [LexState] -> Parser a -> String -> ParseResult a

-- | Parses a string as if it were the contents of the given file Useful
--   for integrating preprocessors.
parseFromSrc :: ParseFlags -> [LexState] -> Parser a -> SrcFile -> String -> 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 ()

-- | <pre>
--   parseError = fail
--   </pre>
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 <a>parseErrorAt</a> or <a>parseError</a> 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 <a>parseErrorAt</a> 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.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
instance GHC.Show.Show Agda.Syntax.Parser.Monad.ParseWarning
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Parser.Monad.ParseWarning
instance Agda.Syntax.Position.HasRange Agda.Syntax.Parser.Monad.ParseWarning


-- | Preprocessors for literate code formats
module Agda.Syntax.Parser.Literate

-- | List of valid extensions for literate Agda files, and their
--   corresponding preprocessors.
--   
--   If you add new extensions, remember to update test/Utils.hs so that
--   test cases ending in the new extensions are found.
literateProcessors :: [(String, Processor)]

-- | Possible extensions for a literate Agda file
literateExts :: [String]

-- | Short list of extensions for literate Agda files For display purposes.
literateExtsShortList :: [String]
literateSrcFile :: [Layer] -> SrcFile

-- | Preprocessor for literate TeX
literateTeX :: Position -> String -> [Layer]

-- | Preprocessor for reStructuredText
literateRsT :: Position -> String -> [Layer]

-- | Blanks the non-code parts of a given file, preserving positions of
--   characters corresponding to code. This way, there is a direct
--   correspondence between source positions and positions in the processed
--   result.
illiterate :: [Layer] -> String

-- | Checks if a layer corresponds to Agda code
isCode :: Layer -> Bool

-- | Type of a literate preprocessor: Invariants:
--   
--   <pre>
--   f : Processor
--   </pre>
--   
--   <pre>
--   f pos s /= []
--   </pre>
--   
--   <pre>
--   f pos s &gt;&gt;= layerContent == s
--   </pre>
type Processor = Position -> String -> [Layer]
data Layer
Layer :: LayerType -> Interval -> String -> Layer
[layerType] :: Layer -> LayerType
[interval] :: Layer -> Interval
[layerContent] :: Layer -> String
data LayerType
Markup :: LayerType
Comment :: LayerType
Code :: LayerType
instance GHC.Show.Show Agda.Syntax.Parser.Literate.Layer
instance GHC.Classes.Eq Agda.Syntax.Parser.Literate.LayerType
instance GHC.Show.Show Agda.Syntax.Parser.Literate.LayerType
instance Agda.Syntax.Position.HasRange Agda.Syntax.Parser.Literate.Layer


-- | 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 <a>lexInput</a>.
lensLexInput :: Lens' String AlexInput

-- | Get the previously lexed character. Same as <a>lexPrevChar</a>. 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 <a>alexGetChar</a>.
--   
--   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 <a>LexPredicate</a>s.
(.&&.) :: LexPredicate -> LexPredicate -> LexPredicate

-- | Disjunction of <a>LexPredicate</a>s.
(.||.) :: LexPredicate -> LexPredicate -> LexPredicate

-- | Negation of <a>LexPredicate</a>s.
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 <a>LookAhead</a> 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 <a>Parser</a>
--   monad (see <a>sync</a> and <a>rollback</a>).
module Agda.Syntax.Parser.LookAhead

-- | The LookAhead monad is basically a state monad keeping with an extra
--   <a>AlexInput</a>, wrapped around the <a>Parser</a> monad.
data LookAhead a

-- | Run a <a>LookAhead</a> 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 <a>Parser</a> monad to the <a>LookAhead</a>
--   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 <a>nextChar</a> followed by
--   <a>sync</a>.
eatNextChar :: LookAhead Char

-- | Consume all the characters up to the current look-ahead position.
sync :: LookAhead ()

-- | Undo look-ahead. Restores the input from the <a>ParseState</a>.
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 <a>match</a> 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

-- | <a>Hiding</a> is an idempotent partial monoid, with unit
--   <a>NotHidden</a>. <a>Instance</a> and <a>NotHidden</a> are
--   incompatible.

-- | Decorating something with <a>Hiding</a> information.
data WithHiding a
WithHiding :: !Hiding -> a -> WithHiding a

-- | A lens to access the <a>Hiding</a> attribute in data structures.
--   Minimal implementation: <tt>getHiding</tt> and one of
--   <tt>setHiding</tt> or <tt>mapHiding</tt>.
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 <a>Hiding</a> information in some data.
mergeHiding :: LensHiding a => WithHiding a -> a

-- | Visible (<a>NotHidden</a>) arguments are <tt>notHidden</tt>.
--   (DEPRECATED, use <a>visible</a>.)
notHidden :: LensHiding a => a -> Bool

-- | <a>NotHidden</a> arguments are <tt>visible</tt>.
visible :: LensHiding a => a -> Bool

-- | <a>Instance</a> and <a>Hidden</a> arguments are <tt>notVisible</tt>.
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. <tt> List : Set -&gt; Set nil : (A :
--   Set) -&gt; List A </tt> <tt>A</tt> is big in constructor <tt>nil</tt>
--   as the sort <tt>Set1</tt> of its type <tt>Set</tt> is bigger than the
--   sort <tt>Set</tt> of the data type <tt>List</tt>.
data Big
Big :: Big
Small :: Big

-- | A function argument can be relevant or irrelevant. See
--   <a>Agda.TypeChecking.Irrelevance</a>.
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
--   <a>UnusedArg</a>
UnusedArg :: Relevance
allRelevances :: [Relevance]

-- | A lens to access the <a>Relevance</a> attribute in data structures.
--   Minimal implementation: <tt>getRelevance</tt> and one of
--   <tt>setRelevance</tt> or <tt>mapRelevance</tt>.
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. <tt>Relevant `moreRelevant` UnusedArg
--   `moreRelevant` Forced `moreRelevant` NonStrict `moreRelevant`
--   Irrelevant</tt>
moreRelevant :: Relevance -> Relevance -> Bool
irrelevantOrUnused :: Relevance -> Bool

-- | <tt>unusableRelevance rel == True</tt> iff we cannot use a variable of
--   <tt>rel</tt>.
unusableRelevance :: Relevance -> Bool

-- | <a>Relevance</a> composition. <a>Irrelevant</a> is dominant,
--   <a>Relevant</a> is neutral.
composeRelevance :: Relevance -> Relevance -> Relevance

-- | <tt>inverseComposeRelevance r x</tt> returns the most irrelevant
--   <tt>y</tt> such that forall <tt>x</tt>, <tt>y</tt> we have <tt>x
--   `moreRelevant` (r `composeRelevance` y)</tt> iff <tt>(r
--   `inverseComposeRelevance` x) `moreRelevant` y</tt> (Galois
--   connection).
inverseComposeRelevance :: Relevance -> Relevance -> Relevance

-- | For comparing <tt>Relevance</tt> ignoring <tt>Forced</tt> and
--   <tt>UnusedArg</tt>.
ignoreForced :: Relevance -> Relevance

-- | Irrelevant function arguments may appear non-strictly in the codomain
--   type.
irrToNonStrict :: Relevance -> Relevance

-- | Applied when working on types (unless --experimental-irrelevance).
nonStrictToRel :: Relevance -> Relevance
nonStrictToIrr :: Relevance -> Relevance
data Origin
UserWritten :: Origin
Inserted :: Origin
Reflected :: Origin
class LensOrigin a where setOrigin o = mapOrigin (const o) mapOrigin f a = setOrigin (f $ getOrigin a) a
getOrigin :: LensOrigin a => a -> Origin
setOrigin :: LensOrigin a => Origin -> a -> a
mapOrigin :: LensOrigin a => (Origin -> Origin) -> a -> a

-- | A function argument can be hidden and/or irrelevant.
data ArgInfo
ArgInfo :: Hiding -> Relevance -> Origin -> Bool -> ArgInfo
[argInfoHiding] :: ArgInfo -> Hiding
[argInfoRelevance] :: ArgInfo -> Relevance
[argInfoOrigin] :: ArgInfo -> Origin
[argInfoOverlappable] :: ArgInfo -> Bool
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

-- | <tt>xs `withArgsFrom` args</tt> translates <tt>xs</tt> into a list of
--   <a>Arg</a>s, using the elements in <tt>args</tt> to fill in the
--   non-<a>unArg</a> 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 <a>Arg</a>, but we need to distinguish an irrelevance
--   annotation in a function domain (the domain itself is not irrelevant!)
--   from an irrelevant argument.
--   
--   <tt>Dom</tt> is used in <tt>Pi</tt> of internal syntax, in
--   <tt>Context</tt> and <tt>Telescope</tt>. <a>Arg</a> is used for actual
--   arguments (<tt>Var</tt>, <tt>Con</tt>, <tt>Def</tt> etc.) and in
--   <tt>Abstract</tt> 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 <a>Hidden</a> arguments can have names.
type NamedArg a = Arg (Named_ a)

-- | Get the content of a <a>NamedArg</a>.
namedArg :: NamedArg a -> a
defaultNamedArg :: a -> NamedArg a

-- | The functor instance for <a>NamedArg</a> 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 <tt>RawName</tt> 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 <tt>ConP</tt> or <tt>Con</tt> come from?
data ConOrigin

-- | Inserted by system or expanded from an implicit pattern.
ConOSystem :: ConOrigin

-- | User wrote a constructor (pattern).
ConOCon :: ConOrigin

-- | User wrote a record (pattern).
ConORec :: ConOrigin

-- | Prefer user-written over system-inserted.
bestConInfo :: ConOrigin -> ConOrigin -> ConOrigin

-- | Where does a projection come from?
data ProjOrigin

-- | User wrote a prefix projection.
ProjPrefix :: ProjOrigin

-- | User wrote a postfix projection.
ProjPostfix :: ProjOrigin

-- | Projection was generated by the system.
ProjSystem :: ProjOrigin

-- | Functions can be defined in both infix and prefix style. See
--   <a>LHS</a>.
data IsInfix
InfixDef :: IsInfix
PrefixDef :: IsInfix

-- | Access modifier.
data Access

-- | Store the <a>Origin</a> of the private block that lead to this
--   qualifier. This is needed for more faithful printing of declarations.
PrivateAccess :: Origin -> 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 :: {-# UNPACK #-} !Word64 -> {-# UNPACK #-} !Word64 -> 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:
--   <tt>_foo</tt>.
Beginning :: PositionInName

-- | The following underscore is in the middle of the name:
--   <tt>foo_bar</tt>.
Middle :: PositionInName

-- | The following underscore is at the end of the name: <tt>foo_</tt>.
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: <tt>noPlaceholder = <a>NoPlaceholder</a>
--   <a>Nothing</a></tt>.
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 <tt>import</tt>, <tt>namespace</tt>, or <tt>open</tt>
--   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 <tt>open</tt>. 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 <tt>private</tt> (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 <a>renFrom</a>.
[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
--   <a>NoTerminationCheck</a>.
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.ProjOrigin
instance GHC.Enum.Enum Agda.Syntax.Common.ProjOrigin
instance GHC.Classes.Ord Agda.Syntax.Common.ProjOrigin
instance GHC.Classes.Eq Agda.Syntax.Common.ProjOrigin
instance GHC.Show.Show Agda.Syntax.Common.ProjOrigin
instance GHC.Enum.Bounded Agda.Syntax.Common.ConOrigin
instance GHC.Enum.Enum Agda.Syntax.Common.ConOrigin
instance GHC.Classes.Ord Agda.Syntax.Common.ConOrigin
instance GHC.Classes.Eq Agda.Syntax.Common.ConOrigin
instance GHC.Show.Show Agda.Syntax.Common.ConOrigin
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 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.Ord Agda.Syntax.Common.Origin
instance GHC.Classes.Eq Agda.Syntax.Common.Origin
instance GHC.Show.Show Agda.Syntax.Common.Origin
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 Control.DeepSeq.NFData Agda.Syntax.Common.Induction
instance Data.Semigroup.Semigroup Agda.Syntax.Common.Hiding
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 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.Origin
instance Control.DeepSeq.NFData Agda.Syntax.Common.Origin
instance Agda.Syntax.Common.LensOrigin Agda.Syntax.Common.Origin
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.Syntax.Common.LensOrigin 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.LensOrigin (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.Classes.Eq a => GHC.Classes.Eq (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.ConOrigin
instance Agda.Syntax.Position.KillRange Agda.Syntax.Common.ProjOrigin
instance Control.DeepSeq.NFData Agda.Syntax.Common.Access
instance Agda.Syntax.Position.HasRange Agda.Syntax.Common.Access
instance Agda.Syntax.Position.KillRange Agda.Syntax.Common.Access
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 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 Data.Semigroup.Semigroup (Agda.Syntax.Common.Using' a b)
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 <a>Id</a>s and <a>Hole</a>s.
--   A normal name is represented by a singleton list, and operators are
--   represented by a list with <a>Hole</a>s where the arguments should go.
--   For instance: <tt>[Hole,Id "+",Hole]</tt> is infix addition.
--   
--   Equality and ordering on <tt>Name</tt>s are defined to ignore range so
--   same names in different locations are equal.
data Name

-- | A (mixfix) identifier.
Name :: Range -> [NamePart] -> Name

-- | <tt>_</tt>.
NoName :: Range -> NameId -> Name

-- | Mixfix identifiers are composed of words and holes, e.g. <tt>_+_</tt>
--   or <tt>if_then_else_</tt> or <tt>[_/_]</tt>.
data NamePart

-- | <tt>_</tt> part.
Hole :: NamePart

-- | Identifier part.
Id :: RawName -> NamePart

-- | Define equality on <tt>Name</tt> 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

-- | <tt>QName</tt> is a list of namespaces and the name of the constant.
--   For the moment assumes namespaces are just <tt>Name</tt>s 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

-- | <tt>A.rest</tt>.
Qual :: Name -> QName -> QName

-- | <tt>x</tt>.
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: <tt>stringNameParts "_" == [Id "_"] == nameParts NoName{}</tt>
stringNameParts :: String -> [NamePart]

-- | Number of holes in a <a>Name</a> (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

-- | <pre>
--   qualify A.B x == A.B.x
--   </pre>
qualify :: QName -> Name -> QName

-- | <pre>
--   unqualify A.B.x == x
--   </pre>
--   
--   The range is preserved.
unqualify :: QName -> Name

-- | <pre>
--   qnameParts A.B.x = [A, B, x]
--   </pre>
qnameParts :: QName -> [Name]

-- | Turns a qualified name into a <a>TopLevelModuleName</a>. The qualified
--   name is assumed to represent a top-level module name.
toTopLevelModuleName :: QName -> TopLevelModuleName

-- | Turns a top level module into a qualified name with <a>noRange</a>.
fromTopLevelModuleName :: TopLevelModuleName -> QName

-- | 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
--   "<i>foo</i>A<i>B</i>C.agda", then the root is "<i>foo</i>".
--   
--   Precondition: The module name must be well-formed.
projectRoot :: AbsolutePath -> TopLevelModuleName -> AbsolutePath

-- | <pre>
--   noName_ = <a>noName</a> <a>noRange</a>
--   </pre>
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 Agda.Utils.Size.Sized Agda.Syntax.Concrete.Name.TopLevelModuleName
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 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


-- | The parser monad used by the operator parser
module Agda.Syntax.Concrete.Operators.Parser.Monad

-- | Memoisation keys.
data MemoKey
NodeK :: (Either Integer Integer) -> MemoKey
PostLeftsK :: (Either Integer Integer) -> MemoKey
PreRightsK :: (Either Integer Integer) -> MemoKey
TopK :: MemoKey
AppK :: MemoKey
NonfixK :: MemoKey

-- | The parser monad.
type Parser tok a = Parser MemoKey tok (MaybePlaceholder tok) a

-- | Runs the parser.
parse :: forall tok a. Parser tok a -> [MaybePlaceholder tok] -> [a]

-- | Parses a single token.
token :: Parser tok (MaybePlaceholder tok)

-- | Parses a token satisfying the given predicate.
sat :: (MaybePlaceholder tok -> Bool) -> Parser tok (MaybePlaceholder tok)

-- | Parses a given token.
tok :: (Eq tok, Show tok) => MaybePlaceholder tok -> Parser tok (MaybePlaceholder tok)

-- | Uses the given function to modify the printed representation (if any)
--   of the given parser.
annotate :: (Doc -> Doc) -> Parser tok a -> Parser tok a

-- | Memoises the given parser.
--   
--   Every memoised parser must be annotated with a <i>unique</i> key.
--   (Parametrised parsers must use distinct keys for distinct inputs.)
memoise :: MemoKey -> Parser tok tok -> Parser tok tok

-- | Memoises the given parser, but only if printing, not if parsing.
--   
--   Every memoised parser must be annotated with a <i>unique</i> key.
--   (Parametrised parsers must use distinct keys for distinct inputs.)
memoiseIfPrinting :: MemoKey -> Parser tok tok -> Parser tok tok

-- | Tries to print the parser, or returns <a>empty</a>, depending on the
--   implementation. This function might not terminate.
grammar :: Parser tok a -> Doc
instance GHC.Generics.Generic Agda.Syntax.Concrete.Operators.Parser.Monad.MemoKey
instance GHC.Show.Show Agda.Syntax.Concrete.Operators.Parser.Monad.MemoKey
instance GHC.Classes.Eq Agda.Syntax.Concrete.Operators.Parser.Monad.MemoKey
instance Data.Hashable.Class.Hashable Agda.Syntax.Concrete.Operators.Parser.Monad.MemoKey


-- | As a concrete name, a notation is a non-empty list of alternating
--   <a>IdPart</a>s and holes. In contrast to concrete names, holes can be
--   binders.
--   
--   Example: <tt> syntax fmap (λ x → e) xs = for x ∈ xs return e </tt>
--   
--   The declared notation for <tt>fmap</tt> is <tt>for_∈_return_</tt>
--   where the first hole is a binder.
module Agda.Syntax.Notation

-- | Data type constructed in the Happy parser; converted to <a>GenPart</a>
--   before it leaves the Happy code.
data HoleName

-- | <tt> x -&gt; y</tt>; 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 <tt>syntax</tt> 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: <tt>_bla_blub_</tt>.
InfixNotation :: NotationKind

-- | Ex: <tt>_bla_blub</tt>.
PrefixNotation :: NotationKind

-- | Ex: <tt>bla_blub_</tt>.
PostfixNotation :: NotationKind

-- | Ex: <tt>bla_blub</tt>.
NonfixNotation :: NotationKind
NoNotation :: NotationKind

-- | Classify a notation by presence of leading and/or trailing
--   <i>normal</i> holes.
notationKind :: Notation -> NotationKind

-- | From notation with names to notation with indices.
--   
--   Example: <tt> ids = ["for", "x", "∈", "xs", "return", "e"] holes = [
--   LambdaHole "x" "e", ExprHole "xs" ] </tt> creates the notation <tt> [
--   IdPart "for" , BindHole 0 , IdPart "∈" , NormalHole 1 , IdPart
--   "return" , NormalHole 0 ] </tt>
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 <tt> x + n <a>y becomes x
--   ---(-n)---</a> y x <a>n + y becomes x ---(+n)---</a> y </tt> 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 <tt>Int</tt>), - rigid variables (also identified by
--   <tt>Int</tt>s), 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

-- | <tt>isBelow r w r'</tt> checks, if <tt>r</tt> and <tt>r'</tt> are
--   connected by <tt>w</tt> (meaning <tt>w</tt> not infinite), whether
--   <tt>r + w &lt;= r'</tt>. 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 <tt>Arc v1 k v2</tt> at least one of <tt>v1</tt> or <tt>v2</tt> is
--   a <tt>MetaV</tt> (Flex), the other a <tt>MetaV</tt> or a <tt>Var</tt>
--   (Rigid). If <tt>k &lt;= 0</tt> this means <tt>suc^(-k) v1 &lt;=
--   v2</tt> otherwise <tt>v1 &lt;= suc^k v3</tt>.
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 <tt>n</tt>.
[nextNode] :: Graph -> NodeId

-- | The edges (restrict to <tt>[0..n[</tt>).
[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

-- | <tt>addEdge n1 k n2</tt> improves the weight of egde
--   <tt>n1-&gt;n2</tt> to be at most <tt>k</tt>. 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 <tt>b</tt> and column descriptions
--   in <tt>c</tt>.
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 <tt>v + n</tt> for a rigid variable
--   <tt>v</tt>.
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

-- | <tt>sizeRigid r n</tt> returns the size expression corresponding to
--   <tt>r + n</tt>
sizeRigid :: Rigid -> Int -> SizeExpr
solve :: Constraints -> Maybe Solution
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 <a>SetRange</a> 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 <a>SetRange</a> 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
--   <a>Range</a>).
newtype AmbiguousQName
AmbQ :: [QName] -> AmbiguousQName
[unAmbQ] :: AmbiguousQName -> [QName]

-- | Check whether we are a projection pattern.
class IsProjP a
isProjP :: IsProjP a => a -> Maybe (ProjOrigin, AmbiguousQName)

-- | 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 <a>noRange</a>.
--   
--   <tt>C.D.E `withRangesOf` [A, B]</tt> returns <tt>C.D.E</tt> but with
--   ranges set as follows:
--   
--   <ul>
--   <li><tt>C</tt>: <a>noRange</a>.</li>
--   <li><tt>D</tt>: the range of <tt>A</tt>.</li>
--   <li><tt>E</tt>: the range of <tt>B</tt>.</li>
--   </ul>
--   
--   Precondition: The number of module name name parts has to be at least
--   as large as the length of the list.
withRangesOf :: ModuleName -> [Name] -> ModuleName

-- | Like <a>withRangesOf</a>, but uses the name parts (qualifier + name)
--   of the qualified name as the list of concrete names.
withRangesOfQ :: ModuleName -> QName -> ModuleName
mnameFromList :: [Name] -> ModuleName
noModuleName :: ModuleName
commonParentModule :: ModuleName -> ModuleName -> ModuleName

-- | Make a <a>Name</a> from some kind of string.
class MkName a where mkName_ = mkName noRange

-- | The <a>Range</a> sets the <i>definition site</i> of the name, not the
--   use site.
mkName :: MkName a => Range -> NameId -> a -> Name
mkName_ :: MkName a => NameId -> a -> Name
qnameToList :: QName -> [Name]
qnameFromList :: [Name] -> QName
qnameToMName :: QName -> ModuleName
mnameToQName :: ModuleName -> QName
showQNameId :: QName -> String

-- | Turn a qualified name into a concrete name. This should only be used
--   as a fallback when looking up the right concrete name in the scope
--   fails.
qnameToConcrete :: QName -> QName
mnameToConcrete :: ModuleName -> QName

-- | Computes the <tt>TopLevelModuleName</tt> corresponding to the given
--   module name, which is assumed to represent a top-level module name.
--   
--   Precondition: The module name must be well-formed.
toTopLevelModuleName :: ModuleName -> TopLevelModuleName
qualifyM :: ModuleName -> ModuleName -> ModuleName
qualifyQ :: ModuleName -> QName -> QName
qualify :: ModuleName -> Name -> QName

-- | Convert a <a>Name</a> to a <a>QName</a> (add no module name).
qualify_ :: Name -> QName

-- | Is the name an operator?
isOperator :: QName -> Bool
isSubModuleOf :: ModuleName -> ModuleName -> Bool
isInModule :: QName -> ModuleName -> Bool

-- | Get the next version of the concrete name. For instance, <tt>nextName
--   "x" = "x₁"</tt>. The name must not be a <tt>NoName</tt>.
nextName :: Name -> Name

-- | An abstract name is empty if its concrete name is empty.

-- | We can have an instance for ambiguous names as all share a common
--   concrete name.

-- | Only use this <tt>show</tt> function in debugging! To convert an
--   abstract <a>Name</a> into a string use <tt>prettyShow</tt>.

-- | Only use this <tt>show</tt> function in debugging! To convert an
--   abstract <a>ModuleName</a> into a string use <tt>prettyShow</tt>.

-- | Only use this <tt>show</tt> function in debugging! To convert an
--   abstract <a>QName</a> into a string use <tt>prettyShow</tt>.

-- | The range of an <tt>AmbiguousQName</tt> is the range of any of its
--   disambiguations (they are the same concrete name).

-- | The range is not forced.

-- | Check whether a name is the empty name "_".
class IsNoName a
isNoName :: IsNoName a => a -> Bool
instance GHC.Classes.Ord Agda.Syntax.Abstract.Name.AmbiguousQName
instance GHC.Classes.Eq Agda.Syntax.Abstract.Name.AmbiguousQName
instance Data.Traversable.Traversable Agda.Syntax.Abstract.Name.QNamed
instance Data.Foldable.Foldable Agda.Syntax.Abstract.Name.QNamed
instance GHC.Base.Functor Agda.Syntax.Abstract.Name.QNamed
instance GHC.Classes.Ord Agda.Syntax.Abstract.Name.ModuleName
instance GHC.Classes.Eq Agda.Syntax.Abstract.Name.ModuleName
instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Abstract.Name.QNamed a)
instance GHC.Show.Show Agda.Syntax.Abstract.Name.AmbiguousQName
instance Agda.Syntax.Abstract.Name.IsProjP a => Agda.Syntax.Abstract.Name.IsProjP (Agda.Syntax.Common.Arg a)
instance Agda.Syntax.Abstract.Name.IsProjP a => Agda.Syntax.Abstract.Name.IsProjP (Agda.Syntax.Common.Named n a)
instance Agda.Syntax.Abstract.Name.MkName GHC.Base.String
instance GHC.Classes.Eq Agda.Syntax.Abstract.Name.Name
instance GHC.Classes.Ord Agda.Syntax.Abstract.Name.Name
instance Data.Hashable.Class.Hashable Agda.Syntax.Abstract.Name.Name
instance GHC.Classes.Eq Agda.Syntax.Abstract.Name.QName
instance GHC.Classes.Ord Agda.Syntax.Abstract.Name.QName
instance Data.Hashable.Class.Hashable Agda.Syntax.Abstract.Name.QName
instance Agda.Syntax.Concrete.Name.IsNoName Agda.Syntax.Abstract.Name.Name
instance Agda.Syntax.Concrete.Name.NumHoles Agda.Syntax.Abstract.Name.Name
instance Agda.Syntax.Concrete.Name.NumHoles Agda.Syntax.Abstract.Name.QName
instance Agda.Syntax.Concrete.Name.NumHoles Agda.Syntax.Abstract.Name.AmbiguousQName
instance GHC.Show.Show Agda.Syntax.Abstract.Name.Name
instance GHC.Show.Show Agda.Syntax.Abstract.Name.ModuleName
instance GHC.Show.Show Agda.Syntax.Abstract.Name.QName
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Abstract.Name.Name
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Abstract.Name.ModuleName
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Abstract.Name.QName
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Abstract.Name.AmbiguousQName
instance Agda.Utils.Pretty.Pretty a => Agda.Utils.Pretty.Pretty (Agda.Syntax.Abstract.Name.QNamed a)
instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.Name.Name
instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.Name.ModuleName
instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.Name.QName
instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.Name.AmbiguousQName
instance Agda.Syntax.Position.SetRange Agda.Syntax.Abstract.Name.Name
instance Agda.Syntax.Position.SetRange Agda.Syntax.Abstract.Name.QName
instance Agda.Syntax.Position.SetRange Agda.Syntax.Abstract.Name.ModuleName
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.Name.Name
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.Name.ModuleName
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.Name.QName
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.Name.AmbiguousQName
instance Agda.Utils.Size.Sized Agda.Syntax.Abstract.Name.QName
instance Agda.Utils.Size.Sized Agda.Syntax.Abstract.Name.ModuleName
instance Control.DeepSeq.NFData Agda.Syntax.Abstract.Name.Name
instance Control.DeepSeq.NFData Agda.Syntax.Abstract.Name.QName
instance Control.DeepSeq.NFData Agda.Syntax.Abstract.Name.ModuleName


-- | Definitions for fixity, precedence levels, and declared syntax.
module Agda.Syntax.Fixity

-- | The notation is handled as the fixity in the renamer. Hence, they are
--   grouped together in this type.
data Fixity'
Fixity' :: !Fixity -> Notation -> Range -> Fixity'
[theFixity] :: Fixity' -> !Fixity
[theNotation] :: Fixity' -> Notation

-- | Range of the name in the fixity declaration (used for correct
--   highlighting, see issue #2140).
[theNameRange] :: Fixity' -> Range

-- | Decorating something with <tt>Fixity'</tt>.
data ThingWithFixity x
ThingWithFixity :: x -> Fixity' -> ThingWithFixity x

-- | All the notation information related to a name.
data NewNotation
NewNotation :: QName -> Set Name -> Fixity -> Notation -> Bool -> NewNotation
[notaName] :: NewNotation -> QName

-- | The names the syntax and/or fixity belong to.
--   
--   Invariant: The set is non-empty. Every name in the list matches
--   <a>notaName</a>.
[notaNames] :: NewNotation -> Set Name

-- | Associativity and precedence (fixity) of the names.
[notaFixity] :: NewNotation -> Fixity

-- | Syntax associated with the names.
[notation] :: NewNotation -> Notation

-- | True if the notation comes from an operator (rather than a syntax
--   declaration).
[notaIsOperator] :: NewNotation -> Bool

-- | If an operator has no specific notation, then it is computed from its
--   name.
namesToNotation :: QName -> Name -> NewNotation

-- | Replace <a>noFixity</a> by <a>defaultFixity</a>.
useDefaultFixity :: NewNotation -> NewNotation

-- | Return the <a>IdPart</a>s of a notation, the first part qualified, the
--   other parts unqualified. This allows for qualified use of operators,
--   e.g., <tt>M.for x ∈ xs return e</tt>, or <tt>x ℕ.+ y</tt>.
notationNames :: NewNotation -> [QName]

-- | Create a <a>Notation</a> (without binders) from a concrete
--   <a>Name</a>. Does the obvious thing: <a>Hole</a>s become
--   <a>NormalHole</a>s, <a>Id</a>s become <tt>IdParts</tt>. If <a>Name</a>
--   has no <a>Hole</a>s, it returns <a>noNotation</a>.
syntaxOf :: Name -> Notation
noFixity' :: Fixity'

-- | Merges <a>NewNotation</a>s that have the same precedence level and
--   notation, with two exceptions:
--   
--   <ul>
--   <li>Operators and notations coming from syntax declarations are kept
--   separate.</li>
--   <li>If <i>all</i> instances of a given <a>NewNotation</a> have the
--   same precedence level or are "unrelated", then they are merged. They
--   get the given precedence level, if any, and otherwise they become
--   unrelated (but related to each other).</li>
--   </ul>
--   
--   If <a>NewNotation</a>s that are merged have distinct associativities,
--   then they get <a>NonAssoc</a> as their associativity.
--   
--   Precondition: No <a>Name</a> may occur in more than one list element.
--   Every <a>NewNotation</a> must have the same <a>notaName</a>.
--   
--   Postcondition: No <a>Name</a> occurs in more than one list element.
mergeNotations :: [NewNotation] -> [NewNotation]

-- | Sections, as well as non-sectioned operators.
data NotationSection
NotationSection :: NewNotation -> NotationKind -> Maybe PrecedenceLevel -> Bool -> NotationSection
[sectNotation] :: NotationSection -> NewNotation

-- | For non-sectioned operators this should match the notation's
--   <a>notationKind</a>.
[sectKind] :: NotationSection -> NotationKind

-- | Effective precedence level. <a>Nothing</a> for closed notations.
[sectLevel] :: NotationSection -> Maybe PrecedenceLevel

-- | <a>False</a> for non-sectioned operators.
[sectIsSection] :: NotationSection -> Bool

-- | Converts a notation to a (non-)section.
noSection :: NewNotation -> NotationSection

-- | Precedence levels for operators.
data PrecedenceLevel

-- | No fixity declared.
Unrelated :: PrecedenceLevel

-- | Fixity level declared as the <tt>Integer</tt>.
Related :: !Integer -> PrecedenceLevel

-- | Associativity.
data Associativity
NonAssoc :: Associativity
LeftAssoc :: Associativity
RightAssoc :: Associativity

-- | Fixity of operators.
data Fixity
Fixity :: Range -> !PrecedenceLevel -> !Associativity -> Fixity

-- | Range of the whole fixity declaration.
[fixityRange] :: Fixity -> Range
[fixityLevel] :: Fixity -> !PrecedenceLevel
[fixityAssoc] :: Fixity -> !Associativity
noFixity :: Fixity
defaultFixity :: Fixity

-- | Precedence is associated with a context.
data Precedence
TopCtx :: Precedence
FunctionSpaceDomainCtx :: Precedence
LeftOperandCtx :: Fixity -> Precedence
RightOperandCtx :: Fixity -> Precedence
FunctionCtx :: Precedence
ArgumentCtx :: Precedence
InsideOperandCtx :: Precedence
WithFunCtx :: Precedence
WithArgCtx :: Precedence
DotPatternCtx :: Precedence

-- | The precedence corresponding to a possibly hidden argument.
hiddenArgumentCtx :: Hiding -> Precedence

-- | Do we need to bracket an operator application of the given fixity in a
--   context with the given precedence.
opBrackets :: Fixity -> Precedence -> Bool

-- | Does a lambda-like thing (lambda, let or pi) need brackets in the
--   given context? A peculiar thing with lambdas is that they don't need
--   brackets in certain right operand contexts. However, we insert
--   brackets anyway, for the following reasons:
--   
--   <ul>
--   <li>Clarity.</li>
--   <li>Sometimes brackets are needed. Example: <tt>m₁ &gt;&gt;= (λ x → x)
--   &gt;&gt;= m₂</tt> (here <tt>_&gt;&gt;=_</tt> is left
--   associative).</li>
--   </ul>
lamBrackets :: Precedence -> Bool

-- | Does a function application need brackets?
appBrackets :: Precedence -> Bool

-- | Does a with application need brackets?
withAppBrackets :: Precedence -> Bool

-- | Does a function space need brackets?
piBrackets :: Precedence -> Bool
roundFixBrackets :: Precedence -> Bool
_notaFixity :: Lens' Fixity NewNotation
_fixityAssoc :: Lens' Associativity Fixity
_fixityLevel :: Lens' PrecedenceLevel Fixity

-- | Ranges are not forced.
instance GHC.Classes.Eq Agda.Syntax.Fixity.Precedence
instance GHC.Show.Show Agda.Syntax.Fixity.Precedence
instance GHC.Show.Show x => GHC.Show.Show (Agda.Syntax.Fixity.ThingWithFixity x)
instance Data.Traversable.Traversable Agda.Syntax.Fixity.ThingWithFixity
instance Data.Foldable.Foldable Agda.Syntax.Fixity.ThingWithFixity
instance GHC.Base.Functor Agda.Syntax.Fixity.ThingWithFixity
instance GHC.Show.Show Agda.Syntax.Fixity.NotationSection
instance GHC.Show.Show Agda.Syntax.Fixity.NewNotation
instance GHC.Show.Show Agda.Syntax.Fixity.Fixity'
instance GHC.Show.Show Agda.Syntax.Fixity.Fixity
instance GHC.Show.Show Agda.Syntax.Fixity.Associativity
instance GHC.Classes.Ord Agda.Syntax.Fixity.Associativity
instance GHC.Classes.Eq Agda.Syntax.Fixity.Associativity
instance GHC.Show.Show Agda.Syntax.Fixity.PrecedenceLevel
instance GHC.Classes.Ord Agda.Syntax.Fixity.PrecedenceLevel
instance GHC.Classes.Eq Agda.Syntax.Fixity.PrecedenceLevel
instance GHC.Classes.Eq Agda.Syntax.Fixity.Fixity'
instance GHC.Classes.Eq Agda.Syntax.Fixity.Fixity
instance GHC.Classes.Ord Agda.Syntax.Fixity.Fixity
instance Agda.Syntax.Position.HasRange Agda.Syntax.Fixity.Fixity
instance Agda.Syntax.Position.KillRange Agda.Syntax.Fixity.Fixity
instance Agda.Syntax.Position.KillRange Agda.Syntax.Fixity.Fixity'
instance Agda.Syntax.Position.KillRange x => Agda.Syntax.Position.KillRange (Agda.Syntax.Fixity.ThingWithFixity x)
instance Control.DeepSeq.NFData Agda.Syntax.Fixity.Fixity'
instance Control.DeepSeq.NFData Agda.Syntax.Fixity.Fixity

module Agda.Syntax.Literal
data Literal
LitNat :: Range -> !Integer -> Literal
LitFloat :: Range -> !Double -> Literal
LitString :: Range -> String -> Literal
LitChar :: Range -> !Char -> Literal
LitQName :: Range -> QName -> Literal
LitMeta :: Range -> AbsolutePath -> MetaId -> Literal
showString' :: String -> ShowS
showChar' :: Char -> ShowS
compareFloat :: Double -> Double -> Ordering

-- | Ranges are not forced.
instance GHC.Show.Show Agda.Syntax.Literal.Literal
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Literal.Literal
instance GHC.Classes.Eq Agda.Syntax.Literal.Literal
instance GHC.Classes.Ord Agda.Syntax.Literal.Literal
instance Agda.Syntax.Position.HasRange Agda.Syntax.Literal.Literal
instance Agda.Syntax.Position.SetRange Agda.Syntax.Literal.Literal
instance Agda.Syntax.Position.KillRange Agda.Syntax.Literal.Literal
instance Control.DeepSeq.NFData Agda.Syntax.Literal.Literal

module Agda.Syntax.Parser.Tokens
data Token
TokKeyword :: Keyword -> Interval -> Token
TokId :: (Interval, String) -> Token
TokQId :: [(Interval, String)] -> Token
TokLiteral :: Literal -> Token
TokSymbol :: Symbol -> Interval -> Token
TokString :: (Interval, String) -> Token
TokSetN :: (Interval, Integer) -> Token
TokTeX :: (Interval, String) -> Token
TokComment :: (Interval, String) -> Token
TokDummy :: Token
TokEOF :: Token
data Keyword
KwLet :: Keyword
KwIn :: Keyword
KwWhere :: Keyword
KwData :: Keyword
KwCoData :: Keyword
KwPostulate :: Keyword
KwMutual :: Keyword
KwAbstract :: Keyword
KwPrivate :: Keyword
KwInstance :: Keyword
KwOverlap :: Keyword
KwOpen :: Keyword
KwImport :: Keyword
KwModule :: Keyword
KwPrimitive :: Keyword
KwMacro :: Keyword
KwInfix :: Keyword
KwInfixL :: Keyword
KwInfixR :: Keyword
KwWith :: Keyword
KwRewrite :: Keyword
KwSet :: Keyword
KwProp :: Keyword
KwForall :: Keyword
KwRecord :: Keyword
KwConstructor :: Keyword
KwField :: Keyword
KwInductive :: Keyword
KwCoInductive :: Keyword
KwEta :: Keyword
KwNoEta :: Keyword
KwHiding :: Keyword
KwUsing :: Keyword
KwRenaming :: Keyword
KwTo :: Keyword
KwPublic :: Keyword
KwOPTIONS :: Keyword
KwBUILTIN :: Keyword
KwLINE :: Keyword
KwCOMPILED_DATA :: Keyword
KwCOMPILED_DECLARE_DATA :: Keyword
KwCOMPILED_TYPE :: Keyword
KwCOMPILED :: Keyword
KwCOMPILED_EXPORT :: Keyword
KwHASKELL :: Keyword
KwCOMPILED_EPIC :: Keyword
KwCOMPILED_JS :: Keyword
KwCOMPILED_UHC :: Keyword
KwCOMPILED_DATA_UHC :: Keyword
KwIMPORT :: Keyword
KwIMPORT_UHC :: Keyword
KwIMPOSSIBLE :: Keyword
KwSTATIC :: Keyword
KwINLINE :: Keyword
KwNO_TERMINATION_CHECK :: Keyword
KwTERMINATING :: Keyword
KwNON_TERMINATING :: Keyword
KwMEASURE :: Keyword
KwDISPLAY :: Keyword
KwREWRITE :: Keyword
KwQuoteGoal :: Keyword
KwQuoteContext :: Keyword
KwQuote :: Keyword
KwQuoteTerm :: Keyword
KwUnquote :: Keyword
KwUnquoteDecl :: Keyword
KwUnquoteDef :: Keyword
KwSyntax :: Keyword
KwPatternSyn :: Keyword
KwTactic :: Keyword
KwCATCHALL :: Keyword
KwNO_POSITIVITY_CHECK :: Keyword
KwPOLARITY :: Keyword
layoutKeywords :: [Keyword]
data Symbol
SymDot :: Symbol
SymSemi :: Symbol
SymVirtualSemi :: Symbol
SymBar :: Symbol
SymColon :: Symbol
SymArrow :: Symbol
SymEqual :: Symbol
SymLambda :: Symbol
SymUnderscore :: Symbol
SymQuestionMark :: Symbol
SymAs :: Symbol
SymOpenParen :: Symbol
SymCloseParen :: Symbol
SymOpenIdiomBracket :: Symbol
SymCloseIdiomBracket :: Symbol
SymDoubleOpenBrace :: Symbol
SymDoubleCloseBrace :: Symbol
SymOpenBrace :: Symbol
SymCloseBrace :: Symbol
SymOpenVirtualBrace :: Symbol
SymCloseVirtualBrace :: Symbol
SymOpenPragma :: Symbol
SymClosePragma :: Symbol
SymEllipsis :: Symbol
SymDotDot :: Symbol

-- | A misplaced end-comment "-}".
SymEndComment :: Symbol
instance GHC.Show.Show Agda.Syntax.Parser.Tokens.Token
instance GHC.Classes.Eq Agda.Syntax.Parser.Tokens.Token
instance GHC.Show.Show Agda.Syntax.Parser.Tokens.Symbol
instance GHC.Classes.Eq Agda.Syntax.Parser.Tokens.Symbol
instance GHC.Show.Show Agda.Syntax.Parser.Tokens.Keyword
instance GHC.Classes.Eq Agda.Syntax.Parser.Tokens.Keyword
instance Agda.Syntax.Position.HasRange Agda.Syntax.Parser.Tokens.Token


-- | This module defines the lex action to lex nested comments. As is
--   well-known this cannot be done by regular expressions (which,
--   incidently, is probably the reason why C-comments don't nest).
--   
--   When scanning nested comments we simply keep track of the nesting
--   level, counting up for <i>open comments</i> and down for <i>close
--   comments</i>.
module Agda.Syntax.Parser.Comments

-- | Should comment tokens be output?
keepComments :: LexPredicate

-- | Should comment tokens be output?
keepCommentsM :: Parser Bool

-- | Manually lexing a block comment. Assumes an <i>open comment</i> has
--   been lexed. In the end the comment is discarded and <a>lexToken</a> is
--   called to lex a real token.
nestedComment :: LexAction Token

-- | Lex a hole (<tt>{! ... !}</tt>). Holes can be nested. Returns
--   <tt><a>TokSymbol</a> <a>SymQuestionMark</a></tt>.
hole :: LexAction Token

-- | Skip a block of text enclosed by the given open and close strings.
--   Assumes the first open string has been consumed. Open-close pairs may
--   be nested.
skipBlock :: String -> String -> LookAhead ()


-- | The code to lex string and character literals. Basically the same code
--   as in GHC.
module Agda.Syntax.Parser.StringLiterals

-- | Lex a string literal. Assumes that a double quote has been lexed.
litString :: LexAction Token

-- | Lex a character literal. Assumes that a single quote has been lexed. A
--   character literal is lexed in exactly the same way as a string
--   literal. Only before returning the token do we check that the lexed
--   string is of length 1. This is maybe not the most efficient way of
--   doing things, but on the other hand it will only be inefficient if
--   there is a lexical error.
litChar :: LexAction Token


-- | The lexer is generated by Alex (<a>http://www.haskell.org/alex</a>)
--   and is an adaptation of GHC's lexer. The main lexing function
--   <a>lexer</a> is called by the <a>Agda.Syntax.Parser.Parser</a> to get
--   the next token from the input.
module Agda.Syntax.Parser.Lexer

-- | Return the next token. This is the function used by Happy in the
--   parser.
--   
--   <pre>
--   lexer k = <a>lexToken</a> &gt;&gt;= k
--   </pre>
lexer :: (Token -> Parser a) -> Parser a

-- | This is the initial state for parsing a regular, non-literate file.
normal :: LexState
code :: Int

-- | The layout state. Entered when we see a layout keyword
--   (<a>withLayout</a>) and exited either when seeing an open brace
--   (<tt>openBrace</tt>) or at the next token (<a>newLayoutContext</a>).
--   
--   Update: we don't use braces for layout anymore.
layout :: LexState

-- | We enter this state from <a>newLayoutContext</a> when the token
--   following a layout keyword is to the left of (or at the same column
--   as) the current layout context. Example:
--   
--   <pre>
--   data Empty : Set where
--   foo : Empty -&gt; Nat
--   </pre>
--   
--   Here the second line is not part of the <tt>where</tt> clause since it
--   is has the same indentation as the <tt>data</tt> definition. What we
--   have to do is insert an empty layout block <tt>{}</tt> after the
--   <tt>where</tt>. The only thing that can happen in this state is that
--   <a>emptyLayout</a> is executed, generating the closing brace. The open
--   brace is generated when entering by <a>newLayoutContext</a>.
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 <a>offsideRule</a>.
bol :: LexState

-- | This state can only be entered by the parser. In this state you can
--   only lex the keywords <tt>using</tt>, <tt>hiding</tt>,
--   <tt>renaming</tt> and <tt>to</tt>. 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)


-- | 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 <a>alexScanUser</a>. This
--   is the main lexing function where all the work happens. The function
--   <a>lexer</a>, 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 <a>Interval</a> and the lexed string.
withInterval :: ((Interval, String) -> tok) -> LexAction tok

-- | Like <a>withInterval</a>, 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 <a>layout</a> 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 <a>parseErrorAt</a> the current
--   position.
lexError :: String -> Parser a

-- | Parse a <a>Keyword</a> token, triggers layout for
--   <a>layoutKeywords</a>.
keyword :: Keyword -> LexAction Token

-- | Parse a <a>Symbol</a> token.
symbol :: Symbol -> LexAction Token

-- | Parse an identifier. Identifiers can be qualified (see <tt>Name</tt>).
--   Example: <tt>Foo.Bar.f</tt>
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 <a>Parser</a> monad keeps track of a stack of
--   <a>LayoutContext</a>s specifying the indentation of the layout blocks
--   in scope. For instance, consider the following incomplete (Haskell)
--   program:
--   
--   <pre>
--   f x = x'
--     where
--       x' = case x of { True -&gt; False; False -&gt; ...
--   </pre>
--   
--   At the <tt>...</tt> the layout context would be
--   
--   <pre>
--   [NoLayout, Layout 4, Layout 0]
--   </pre>
--   
--   The closest layout block is the one containing the <tt>case</tt>
--   branches. This block starts with an open brace (<tt>'{'</tt>) and so
--   doesn't use layout. The second closest block is the <tt>where</tt>
--   clause. Here, there is no open brace so the block is started by the
--   <tt>x'</tt> 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 (<tt>'{'</tt>). Enters the
--   <a>NoLayout</a> context.
openBrace :: LexAction Token

-- | Executed upon lexing a close brace (<tt>'}'</tt>). 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 <a>layout</a> state and
--   performs the given action.
withLayout :: LexAction r -> LexAction r

-- | Executed for the first token in each line (see <a>bol</a>). Checks the
--   position of the token relative to the current layout context. If the
--   token is
--   
--   <ul>
--   <li><i>to the left</i> : Exit the current context and a return virtual
--   close brace (stay in the <a>bol</a> state).</li>
--   <li><i>same column</i> : Exit the <a>bol</a> state and return a
--   virtual semi colon.</li>
--   <li><i>to the right</i> : Exit the <a>bol</a> state and continue
--   lexing.</li>
--   </ul>
--   
--   If the current block doesn't use layout (i.e. it was started by
--   <a>openBrace</a>) all positions are considered to be <i>to the
--   right</i>.
offsideRule :: LexAction Token

-- | Start a new layout context. This is one of two ways to get out of the
--   <a>layout</a> state (the other is <a>openBrace</a>). There are two
--   possibilities:
--   
--   <ul>
--   <li>The current token is to the right of the current layout context
--   (or we're in a no layout context).</li>
--   <li>The current token is to the left of or in the same column as the
--   current context.</li>
--   </ul>
--   
--   In the first case everything is fine and we enter a new layout context
--   at the column of the current token. In the second case we have an
--   empty layout block so we enter the <a>empty_layout</a> state. In both
--   cases we return a virtual open brace without consuming any input.
--   
--   Entering a new state when we know we want to generate a virtual
--   <tt>{}</tt> may seem a bit roundabout. The thing is that we can only
--   generate one token at a time, so the way to generate two tokens is to
--   generate the first one and then enter a state in which the only thing
--   you can do is generate the second one.
newLayoutContext :: LexAction Token

-- | This action is only executed from the <a>empty_layout</a> state. It
--   will exit this state, enter the <a>bol</a> state, and return a virtual
--   close brace (closing the empty layout block started by
--   <a>newLayoutContext</a>).
emptyLayout :: LexAction Token

module Agda.Syntax.Reflected
type Args = [Arg Term]
data Elim' a
Apply :: (Arg a) -> Elim' a
type Elim = Elim' Term
type Elims = [Elim]
argsToElims :: Args -> Elims
data Abs a
Abs :: String -> a -> Abs a
data Term
Var :: Int -> Elims -> Term
Con :: QName -> Elims -> Term
Def :: QName -> Elims -> Term
Meta :: MetaId -> Elims -> Term
Lam :: Hiding -> (Abs Term) -> Term
ExtLam :: [Clause] -> Elims -> Term
Pi :: (Dom Type) -> (Abs Type) -> Term
Sort :: Sort -> Term
Lit :: Literal -> Term
Unknown :: Term
type Type = Term
data Sort
SetS :: Term -> Sort
LitS :: Integer -> Sort
UnknownS :: Sort
data Pattern
ConP :: QName -> [Arg Pattern] -> Pattern
DotP :: Pattern
VarP :: String -> Pattern
LitP :: Literal -> Pattern
AbsurdP :: Pattern
ProjP :: QName -> Pattern
data Clause
Clause :: [Arg Pattern] -> Term -> Clause
AbsurdClause :: [Arg Pattern] -> Clause
data Definition
FunDef :: Type -> [Clause] -> Definition
DataDef :: Definition
RecordDef :: Definition
DataConstructor :: Definition
Axiom :: Definition
Primitive :: Definition
instance GHC.Show.Show Agda.Syntax.Reflected.Definition
instance GHC.Show.Show Agda.Syntax.Reflected.Sort
instance GHC.Show.Show Agda.Syntax.Reflected.Term
instance GHC.Show.Show Agda.Syntax.Reflected.Clause
instance GHC.Show.Show Agda.Syntax.Reflected.Pattern
instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Reflected.Abs a)
instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Reflected.Elim' a)


-- | The treeless syntax is intended to be used as input for the compiler
--   backends. It is more low-level than Internal syntax and is not used
--   for type checking.
--   
--   Some of the features of treeless syntax are: - case expressions
--   instead of case trees - no instantiated datatypes / constructors
module Agda.Syntax.Treeless
data Compiled
Compiled :: TTerm -> [Bool] -> Compiled
[cTreeless] :: Compiled -> TTerm
[cArgUsage] :: Compiled -> [Bool]
type Args = [TTerm]
data TTerm
TVar :: Int -> TTerm
TPrim :: TPrim -> TTerm
TDef :: QName -> TTerm
TApp :: TTerm -> Args -> TTerm
TLam :: TTerm -> TTerm
TLit :: Literal -> TTerm
TCon :: QName -> TTerm

-- | introduces a new local binding. The bound term MUST only be evaluated
--   if it is used inside the body. Sharing may happen, but is optional. It
--   is also perfectly valid to just inline the bound term in the body.
TLet :: TTerm -> TTerm -> TTerm

-- | Case scrutinee (always variable), case type, default value,
--   alternatives First, all TACon alternatives are tried; then all TAGuard
--   alternatives in top to bottom order. TACon alternatives must not
--   overlap.
TCase :: Int -> CaseType -> TTerm -> [TAlt] -> TTerm
TUnit :: TTerm
TSort :: TTerm
TErased :: TTerm

-- | A runtime error, something bad has happened.
TError :: TError -> TTerm

-- | Compiler-related primitives. This are NOT the same thing as primitives
--   in Agda's surface or internal syntax! Some of the primitives have a
--   suffix indicating which type of arguments they take, using the
--   following naming convention: Char | Type C | Character F | Float I |
--   Integer Q | QName S | String
data TPrim
PAdd :: TPrim
PSub :: TPrim
PMul :: TPrim
PQuot :: TPrim
PRem :: TPrim
PGeq :: TPrim
PLt :: TPrim
PEqI :: TPrim
PEqF :: TPrim
PEqS :: TPrim
PEqC :: TPrim
PEqQ :: TPrim
PIf :: TPrim
PSeq :: TPrim
isPrimEq :: TPrim -> Bool
mkTApp :: TTerm -> Args -> TTerm
tAppView :: TTerm -> [TTerm]
tLetView :: TTerm -> ([TTerm], TTerm)
tLamView :: TTerm -> (Int, TTerm)
mkTLam :: Int -> TTerm -> TTerm

-- | Introduces a new binding
mkLet :: TTerm -> TTerm -> TTerm
tInt :: Integer -> TTerm
intView :: TTerm -> Maybe Integer
tPlusK :: Integer -> TTerm -> TTerm
tNegPlusK :: Integer -> TTerm -> TTerm
plusKView :: TTerm -> Maybe (Integer, TTerm)
negPlusKView :: TTerm -> Maybe (Integer, TTerm)
tOp :: TPrim -> TTerm -> TTerm -> TTerm
tUnreachable :: TTerm
tIfThenElse :: TTerm -> TTerm -> TTerm -> TTerm
data CaseType
CTData :: QName -> CaseType
CTNat :: CaseType
CTInt :: CaseType
CTChar :: CaseType
CTString :: CaseType
CTFloat :: CaseType
CTQName :: CaseType
data TAlt

-- | Matches on the given constructor. If the match succeeds, the pattern
--   variables are prepended to the current environment (pushes all
--   existing variables aArity steps further away)
TACon :: QName -> Int -> TTerm -> TAlt
[aCon] :: TAlt -> QName
[aArity] :: TAlt -> Int
[aBody] :: TAlt -> TTerm

-- | Binds no variables
TAGuard :: TTerm -> TTerm -> TAlt
[aGuard] :: TAlt -> TTerm
[aBody] :: TAlt -> TTerm
TALit :: Literal -> TTerm -> TAlt
[aLit] :: TAlt -> Literal
[aBody] :: TAlt -> TTerm
data TError

-- | Code which is unreachable. E.g. absurd branches or missing case
--   defaults. Runtime behaviour of unreachable code is undefined, but
--   preferably the program will exit with an error message. The compiler
--   is free to assume that this code is unreachable and to remove it.
TUnreachable :: TError
class Unreachable a

-- | Checks if the given expression is unreachable or not.
isUnreachable :: Unreachable a => a -> Bool
instance GHC.Classes.Ord Agda.Syntax.Treeless.Compiled
instance GHC.Classes.Eq Agda.Syntax.Treeless.Compiled
instance GHC.Show.Show Agda.Syntax.Treeless.Compiled
instance GHC.Classes.Ord Agda.Syntax.Treeless.TAlt
instance GHC.Classes.Eq Agda.Syntax.Treeless.TAlt
instance GHC.Show.Show Agda.Syntax.Treeless.TAlt
instance GHC.Classes.Ord Agda.Syntax.Treeless.TTerm
instance GHC.Classes.Eq Agda.Syntax.Treeless.TTerm
instance GHC.Show.Show Agda.Syntax.Treeless.TTerm
instance GHC.Classes.Ord Agda.Syntax.Treeless.TError
instance GHC.Classes.Eq Agda.Syntax.Treeless.TError
instance GHC.Show.Show Agda.Syntax.Treeless.TError
instance GHC.Classes.Ord Agda.Syntax.Treeless.CaseType
instance GHC.Classes.Eq Agda.Syntax.Treeless.CaseType
instance GHC.Show.Show Agda.Syntax.Treeless.CaseType
instance GHC.Classes.Ord Agda.Syntax.Treeless.TPrim
instance GHC.Classes.Eq Agda.Syntax.Treeless.TPrim
instance GHC.Show.Show Agda.Syntax.Treeless.TPrim
instance Agda.Syntax.Treeless.Unreachable Agda.Syntax.Treeless.TAlt
instance Agda.Syntax.Treeless.Unreachable Agda.Syntax.Treeless.TTerm
instance Agda.Syntax.Position.KillRange Agda.Syntax.Treeless.Compiled


-- | Occurrences.
module Agda.TypeChecking.Positivity.Occurrence

-- | Subterm occurrences for positivity checking. The constructors are
--   listed in increasing information they provide: <tt>Mixed &lt;= JustPos
--   &lt;= StrictPos &lt;= GuardPos &lt;= Unused</tt> <tt>Mixed &lt;=
--   JustNeg &lt;= Unused</tt>.
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

-- | Description of an occurrence.
data OccursWhere

-- | an unknown position (treated as negative)
Unknown :: OccursWhere

-- | The elements of the sequence, from left to right, explain how to get
--   to the occurrence.
Known :: Range -> (Seq Where) -> OccursWhere

-- | One part of the description of an occurrence.
data Where
LeftOfArrow :: Where

-- | in the nth argument of a define constant
DefArg :: QName -> Nat -> Where

-- | in the principal argument of built-in ∞
UnderInf :: Where

-- | as an argument to a bound variable
VarArg :: Where

-- | as an argument of a metavariable
MetaArg :: Where

-- | in the type of a constructor
ConArgType :: QName -> Where

-- | in a datatype index of a constructor
IndArgType :: QName -> Where

-- | in the nth clause of a defined function
InClause :: Nat -> Where

-- | matched against in a clause of a defined function
Matched :: Where

-- | in the definition of a constant
InDefOf :: QName -> Where

-- | The map contains bindings of the form <tt>bound |-&gt; es</tt>,
--   satisfying the following property: for every non-empty list
--   <tt>w</tt>, <tt><a>foldr1</a> <a>otimes</a> w <a>&lt;=</a> bound</tt>
--   iff <tt><a>or</a> [ <a>all</a> every w <a>&amp;&amp;</a> <a>any</a>
--   some w | (every, some) &lt;- ess ]</tt>.
boundToEverySome :: Map Occurrence [(Occurrence -> Bool, Occurrence -> Bool)]

-- | <tt>productOfEdgesInBoundedWalk occ g u v bound</tt> returns
--   <tt><a>Just</a> e</tt> iff there is a walk <tt>c</tt> (a list of
--   edges) in <tt>g</tt>, from <tt>u</tt> to <tt>v</tt>, for which the
--   product <tt><a>foldr1</a> <a>otimes</a> (<a>map</a> occ c)
--   <a>&lt;=</a> bound</tt>. In this case the returned value <tt>e</tt> is
--   the product <tt><a>foldr1</a> <a>otimes</a> c</tt> for one such walk.
--   
--   Preconditions: <tt>u</tt> and <tt>v</tt> must belong to <tt>g</tt>,
--   and <tt>bound</tt> must belong to the domain of
--   <tt>boundToEverySome</tt>.
productOfEdgesInBoundedWalk :: (SemiRing e, Ord n) => (e -> Occurrence) -> Graph n n e -> n -> n -> Occurrence -> Maybe e
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 GHC.Classes.Ord Agda.TypeChecking.Positivity.Occurrence.OccursWhere
instance GHC.Classes.Eq Agda.TypeChecking.Positivity.Occurrence.OccursWhere
instance GHC.Show.Show Agda.TypeChecking.Positivity.Occurrence.OccursWhere
instance GHC.Classes.Ord Agda.TypeChecking.Positivity.Occurrence.Where
instance GHC.Classes.Eq Agda.TypeChecking.Positivity.Occurrence.Where
instance GHC.Show.Show Agda.TypeChecking.Positivity.Occurrence.Where
instance Control.DeepSeq.NFData Agda.TypeChecking.Positivity.Occurrence.Occurrence
instance Agda.Syntax.Position.KillRange 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


-- | The concrete syntax is a raw representation of the program text
--   without any desugaring at all. This is what the parser produces. The
--   idea is that if we figure out how to keep the concrete syntax around,
--   it can be printed exactly as the user wrote it.
module Agda.Syntax.Concrete

-- | Concrete expressions. Should represent exactly what the user wrote.
data Expr

-- | ex: <tt>x</tt>
Ident :: QName -> Expr

-- | ex: <tt>1</tt> or <tt>"foo"</tt>
Lit :: Literal -> Expr

-- | ex: <tt>?</tt> or <tt>{! ... !}</tt>
QuestionMark :: Range -> (Maybe Nat) -> Expr

-- | ex: <tt>_</tt> or <tt>_A_5</tt>
Underscore :: Range -> (Maybe String) -> Expr

-- | before parsing operators
RawApp :: Range -> [Expr] -> Expr

-- | ex: <tt>e e</tt>, <tt>e {e}</tt>, or <tt>e {x = e}</tt>
App :: Range -> Expr -> (NamedArg Expr) -> Expr

-- | ex: <tt>e + e</tt> The <a>QName</a> is possibly ambiguous, but it must
--   correspond to one of the names in the set.
OpApp :: Range -> QName -> (Set Name) -> [NamedArg (MaybePlaceholder (OpApp Expr))] -> Expr

-- | ex: <tt>e | e1 | .. | en</tt>
WithApp :: Range -> Expr -> [Expr] -> Expr

-- | ex: <tt>{e}</tt> or <tt>{x=e}</tt>
HiddenArg :: Range -> (Named_ Expr) -> Expr

-- | ex: <tt>{{e}}</tt> or <tt>{{x=e}}</tt>
InstanceArg :: Range -> (Named_ Expr) -> Expr

-- | ex: <tt>\x {y} -&gt; e</tt> or <tt>\(x:A){y:B} -&gt; e</tt>
Lam :: Range -> [LamBinding] -> Expr -> Expr

-- | ex: <tt>\ ()</tt>
AbsurdLam :: Range -> Hiding -> Expr

-- | ex: <tt>\ { p11 .. p1a -&gt; e1 ; .. ; pn1 .. pnz -&gt; en }</tt>
ExtendedLam :: Range -> [(LHS, RHS, WhereClause, Bool)] -> Expr

-- | ex: <tt>e -&gt; e</tt> or <tt>.e -&gt; e</tt> (NYI: <tt>{e} -&gt;
--   e</tt>)
Fun :: Range -> Expr -> Expr -> Expr

-- | ex: <tt>(xs:e) -&gt; e</tt> or <tt>{xs:e} -&gt; e</tt>
Pi :: Telescope -> Expr -> Expr

-- | ex: <tt>Set</tt>
Set :: Range -> Expr

-- | ex: <tt>Prop</tt>
Prop :: Range -> Expr

-- | ex: <tt>Set0, Set1, ..</tt>
SetN :: Range -> Integer -> Expr

-- | ex: <tt>record {x = a; y = b}</tt>, or <tt>record { x = a; M1; M2
--   }</tt>
Rec :: Range -> RecordAssignments -> Expr

-- | ex: <tt>record e {x = a; y = b}</tt>
RecUpdate :: Range -> Expr -> [FieldAssignment] -> Expr

-- | ex: <tt>let Ds in e</tt>
Let :: Range -> [Declaration] -> Expr -> Expr

-- | ex: <tt>(e)</tt>
Paren :: Range -> Expr -> Expr

-- | ex: <tt>(| e |)</tt>
IdiomBrackets :: Range -> Expr -> Expr

-- | ex: <tt>()</tt> or <tt>{}</tt>, only in patterns
Absurd :: Range -> Expr

-- | ex: <tt>x@p</tt>, only in patterns
As :: Range -> Name -> Expr -> Expr

-- | ex: <tt>.p</tt>, only in patterns
Dot :: Range -> Expr -> Expr

-- | only used for printing telescopes
ETel :: Telescope -> Expr

-- | ex: <tt>quoteGoal x in e</tt>
QuoteGoal :: Range -> Name -> Expr -> Expr

-- | ex: <tt>quoteContext</tt>
QuoteContext :: Range -> Expr

-- | ex: <tt>quote</tt>, should be applied to a name
Quote :: Range -> Expr

-- | ex: <tt>quoteTerm</tt>, should be applied to a term
QuoteTerm :: Range -> Expr

-- | <pre>
--   tactic solve | subgoal1 | .. | subgoalN
--   </pre>
Tactic :: Range -> Expr -> [Expr] -> Expr

-- | ex: <tt>unquote</tt>, should be applied to a term of type
--   <tt>Term</tt>
Unquote :: Range -> Expr

-- | to print irrelevant things
DontCare :: Expr -> Expr

-- | ex: <tt>a = b</tt>, 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 <a>Expr</a> 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

-- | . <tt>x</tt> or <tt>{x}</tt> or <tt>.x</tt> or <tt>.{x}</tt> or
--   <tt>{.x}</tt>
DomainFree :: ArgInfo -> BoundName -> LamBinding' a

-- | . <tt>(xs : e)</tt> or <tt>{xs : e}</tt>
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
--   <a>Hiding</a> in <tt>TypedBindings</tt> must be the unit
--   <a>NotHidden</a>.
type TypedBindings = TypedBindings' TypedBinding
data TypedBindings' a

-- | . <tt>(xs : e)</tt> or <tt>{xs : e}</tt> or something like <tt>(x {y}
--   _ : e)</tt>.
TypedBindings :: Range -> (Arg a) -> TypedBindings' a

-- | A typed binding.
type TypedBinding = TypedBinding' Expr
data TypedBinding' e

-- | Binding <tt>(x1 ... xn : A)</tt>.
TBind :: Range -> [WithHiding BoundName] -> e -> TypedBinding' e

-- | Let binding <tt>(let Ds)</tt> or <tt>(open M args)</tt>.
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

-- | In <a>Agda.Syntax.Concrete.Definitions</a> we generate private blocks
--   temporarily, which should be treated different that user-declared
--   private blocks. Thus the <a>Origin</a>.
Private :: Range -> Origin -> [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

-- | <pre>
--   tel. M args
--   </pre>
SectionApp :: Range -> [TypedBindings] -> Expr -> ModuleApplication

-- | <pre>
--   M {{...}}
--   </pre>
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 <tt>import</tt>, <tt>namespace</tt>, or <tt>open</tt>
--   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:
--   
--   <pre>
--   n + suc m = suc (n + m)
--   (f ∘ g) x = f (g x)
--   </pre>
--   
--   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

-- | <pre>
--   f ps
--   </pre>
[lhsOriginalPattern] :: LHS -> Pattern

-- | <tt>| p</tt> (many)
[lhsWithPattern] :: LHS -> [Pattern]

-- | <tt>rewrite e</tt> (many)
[lhsRewriteEqn] :: LHS -> [RewriteEqn]

-- | <tt>with e</tt> (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

-- | <tt>c</tt> or <tt>x</tt>
IdentP :: QName -> Pattern

-- | <pre>
--   quote
--   </pre>
QuoteP :: Range -> Pattern

-- | <tt>p p'</tt> or <tt>p {x = p'}</tt>
AppP :: Pattern -> (NamedArg Pattern) -> Pattern

-- | <tt>p1..pn</tt> before parsing operators
RawAppP :: Range -> [Pattern] -> Pattern

-- | eg: <tt>p =&gt; p'</tt> for operator <tt>_=&gt;_</tt> The <a>QName</a>
--   is possibly ambiguous, but it must correspond to one of the names in
--   the set.
OpAppP :: Range -> QName -> (Set Name) -> [NamedArg Pattern] -> Pattern

-- | <tt>{p}</tt> or <tt>{x = p}</tt>
HiddenP :: Range -> (Named_ Pattern) -> Pattern

-- | <tt>{{p}}</tt> or <tt>{{x = p}}</tt>
InstanceP :: Range -> (Named_ Pattern) -> Pattern

-- | <pre>
--   (p)
--   </pre>
ParenP :: Range -> Pattern -> Pattern

-- | <pre>
--   _
--   </pre>
WildP :: Range -> Pattern

-- | <pre>
--   ()
--   </pre>
AbsurdP :: Range -> Pattern

-- | <tt>x@p</tt> unused
AsP :: Range -> Name -> Pattern -> Pattern

-- | <pre>
--   .e
--   </pre>
DotP :: Range -> Origin -> Expr -> Pattern

-- | <tt>0</tt>, <tt>1</tt>, etc.
LitP :: Literal -> Pattern

-- | <pre>
--   record {x = p; y = q}
--   </pre>
RecP :: Range -> [FieldAssignment' Pattern] -> Pattern

-- | Processed (scope-checked) intermediate form of the core <tt>f ps</tt>
--   of <a>LHS</a>. Corresponds to <a>lhsOriginalPattern</a>.
data LHSCore
LHSHead :: QName -> [NamedArg Pattern] -> LHSCore

-- | <pre>
--   f
--   </pre>
[lhsDefName] :: LHSCore -> QName

-- | <pre>
--   ps
--   </pre>
[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 <tt>where</tt> clauses.
NoWhere :: WhereClause' decls

-- | Ordinary <tt>where</tt>.
AnyWhere :: decls -> WhereClause' decls

-- | Named where: <tt>module M where</tt>. The <a>Access</a> flag applies
--   to the <a>Name</a> (not the module contents!) and is propagated from
--   the parent function.
SomeWhere :: Name -> Access -> 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
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
PolarityPragma :: Range -> Name -> [Occurrence] -> Pragma

-- | Modules: Top-level pragmas plus other top-level declarations.
type Module = ([Pragma], [Declaration])

-- | Decorating something with <tt>Fixity'</tt>.
data ThingWithFixity x
ThingWithFixity :: x -> Fixity' -> ThingWithFixity x

-- | Computes the top-level module name.
--   
--   Precondition: The <a>Module</a> has to be well-formed. This means that
--   there are only allowed declarations before the first module
--   declaration, typically import declarations. See
--   <a>spanAllowedBeforeModule</a>.
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
--   <a>Agda.Syntax.Internal.Generic</a>.
--   
--   However, here we use the terminology of <a>Traversable</a>.
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" 43)) foldExpr = (throwImpossible (Impossible "src/full/Agda/Syntax/Concrete/Generic.hs" 44))

-- | This corresponds to <a>map</a>.
mapExpr :: ExprLike a => (Expr -> Expr) -> a -> a

-- | This corresponds to <a>mapM</a>.
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
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 <a>QName</a> 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
--   <a>PositionInName</a> 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 (<tt>_</tt>), or an unqualified name (possibly
--   containing multiple name parts).
wildOrUnqualifiedName :: IsExpr e => Parser e (Maybe Name)

-- | Used to define the return type of <a>opP</a>.

-- | A singleton type for <a>NotationKind</a> (except for the constructor
--   <a>NoNotation</a>).
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 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

-- | <tt>prettyHiding info visible doc</tt> puts the correct braces around
--   <tt>doc</tt> according to info <tt>info</tt> and returns <tt>visible
--   doc</tt> 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.TypeChecking.Positivity.Occurrence.Occurrence
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 a => Agda.Utils.Pretty.Pretty (Agda.Syntax.Common.Arg a)
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 <a>Declaration</a>s, producing <a>NiceDeclaration</a>s.
--   
--   <ul>
--   <li>Attach fixity and syntax declarations to the definition they refer
--   to.</li>
--   <li>Distribute the following attributes to the individual definitions:
--   <tt>abstract</tt>, <tt>instance</tt>, <tt>postulate</tt>,
--   <tt>primitive</tt>, <tt>private</tt>, termination pragmas.</li>
--   <li>Gather the function clauses belonging to one function
--   definition.</li>
--   <li>Expand ellipsis <tt>...</tt> in function clauses following
--   <tt>with</tt>.</li>
--   <li>Infer mutual blocks. A block starts when a lone signature is
--   encountered, and ends when all lone signatures have seen their
--   definition.</li>
--   <li>Report basic well-formedness error, when one of the above
--   transformation fails.</li>
--   </ul>
module Agda.Syntax.Concrete.Definitions

-- | The nice declarations. No fixity declarations and function definitions
--   are contained in a single constructor instead of spread out between
--   type signatures and clauses. The <tt>private</tt>, <tt>postulate</tt>,
--   <tt>abstract</tt> and <tt>instance</tt> modifiers have been
--   distributed to the individual declarations.
--   
--   Observe the order of components:
--   
--   Range Fixity' Access IsAbstract IsInstance TerminationCheck
--   PositivityCheck
--   
--   further attributes
--   
--   (Q)Name
--   
--   content (Expr, Declaration ...)
data NiceDeclaration

-- | <a>IsAbstract</a> argument: We record whether a declaration was made
--   in an <tt>abstract</tt> block.
--   
--   <a>ArgInfo</a> argument: Axioms and functions can be declared
--   irrelevant. (<a>Hiding</a> should be <a>NotHidden</a>.)
--   
--   <tt>Maybe [Occurrence]</tt> argument: Polarities can be assigned to
--   identifiers.
Axiom :: Range -> Fixity' -> Access -> IsAbstract -> IsInstance -> ArgInfo -> (Maybe [Occurrence]) -> Name -> Expr -> NiceDeclaration
NiceField :: Range -> Fixity' -> Access -> IsAbstract -> IsInstance -> Name -> (Arg Expr) -> NiceDeclaration
PrimitiveFunction :: Range -> Fixity' -> Access -> IsAbstract -> Name -> Expr -> NiceDeclaration
NiceMutual :: Range -> TerminationCheck -> PositivityCheck -> [NiceDeclaration] -> NiceDeclaration
NiceModule :: Range -> Access -> IsAbstract -> QName -> Telescope -> [Declaration] -> NiceDeclaration
NiceModuleMacro :: Range -> Access -> Name -> ModuleApplication -> OpenShortHand -> ImportDirective -> NiceDeclaration
NiceOpen :: Range -> QName -> ImportDirective -> NiceDeclaration
NiceImport :: Range -> QName -> (Maybe AsName) -> OpenShortHand -> ImportDirective -> NiceDeclaration
NicePragma :: Range -> Pragma -> NiceDeclaration
NiceRecSig :: Range -> Fixity' -> Access -> IsAbstract -> PositivityCheck -> Name -> [LamBinding] -> Expr -> NiceDeclaration
NiceDataSig :: Range -> Fixity' -> Access -> IsAbstract -> PositivityCheck -> Name -> [LamBinding] -> Expr -> NiceDeclaration

-- | An uncategorized function clause, could be a function clause without
--   type signature or a pattern lhs (e.g. for irrefutable let). The
--   <a>Declaration</a> is the actual <a>FunClause</a>.
NiceFunClause :: Range -> Access -> IsAbstract -> TerminationCheck -> Catchall -> Declaration -> NiceDeclaration
FunSig :: Range -> Fixity' -> Access -> IsAbstract -> IsInstance -> IsMacro -> ArgInfo -> TerminationCheck -> Name -> Expr -> NiceDeclaration

-- | Block of function clauses (we have seen the type signature before).
--   The <a>Declaration</a>s are the original declarations that were
--   processed into this <a>FunDef</a> and are only used in
--   <tt>notSoNiceDeclaration</tt>.
FunDef :: Range -> [Declaration] -> Fixity' -> IsAbstract -> TerminationCheck -> Name -> [Clause] -> NiceDeclaration
DataDef :: Range -> Fixity' -> IsAbstract -> PositivityCheck -> Name -> [LamBinding] -> [NiceConstructor] -> NiceDeclaration
RecDef :: Range -> Fixity' -> IsAbstract -> PositivityCheck -> Name -> (Maybe (Ranged Induction)) -> (Maybe Bool) -> (Maybe (ThingWithFixity Name, IsInstance)) -> [LamBinding] -> [NiceDeclaration] -> NiceDeclaration
NicePatternSyn :: Range -> Fixity' -> Name -> [Arg Name] -> Pattern -> NiceDeclaration
NiceUnquoteDecl :: Range -> [Fixity'] -> Access -> IsAbstract -> IsInstance -> TerminationCheck -> [Name] -> Expr -> NiceDeclaration
NiceUnquoteDef :: Range -> [Fixity'] -> Access -> IsAbstract -> TerminationCheck -> [Name] -> Expr -> NiceDeclaration

-- | Only <a>Axiom</a>s.
type NiceConstructor = NiceTypeSignature

-- | Only <a>Axiom</a>s.
type NiceTypeSignature = NiceDeclaration

-- | One clause in a function definition. There is no guarantee that the
--   <a>LHS</a> actually declares the <a>Name</a>. We will have to check
--   that later.
data Clause
Clause :: Name -> Catchall -> LHS -> RHS -> WhereClause -> [Clause] -> Clause

-- | The exception type.
data DeclarationException
MultipleFixityDecls :: [(Name, [Fixity'])] -> DeclarationException
MultiplePolarityPragmas :: [Name] -> DeclarationException
InvalidName :: Name -> DeclarationException
DuplicateDefinition :: Name -> DeclarationException
MissingDefinition :: Name -> DeclarationException
MissingWithClauses :: Name -> DeclarationException
MissingTypeSignature :: LHS -> DeclarationException
MissingDataSignature :: Name -> DeclarationException
WrongDefinition :: Name -> DataRecOrFun -> DataRecOrFun -> DeclarationException
WrongParameters :: Name -> DeclarationException
NotAllowedInMutual :: NiceDeclaration -> DeclarationException
UnknownNamesInFixityDecl :: [Name] -> DeclarationException
UnknownNamesInPolarityPragmas :: [Name] -> DeclarationException
PolarityPragmasButNotPostulates :: [Name] -> DeclarationException
Codata :: Range -> DeclarationException
DeclarationPanic :: String -> DeclarationException
UselessPrivate :: Range -> DeclarationException
UselessAbstract :: Range -> DeclarationException
UselessInstance :: Range -> DeclarationException
WrongContentBlock :: KindOfBlock -> Range -> DeclarationException

-- | in a mutual block, a clause could belong to any of the <tt>[Name]</tt>
--   type signatures
AmbiguousFunClauses :: LHS -> [Name] -> DeclarationException
InvalidTerminationCheckPragma :: Range -> DeclarationException

-- | In a mutual block, all or none need a MEASURE pragma. Range is of
--   mutual block.
InvalidMeasureMutual :: Range -> DeclarationException

-- | Pragma <tt>{--}</tt> has been replaced by {--} and {--}.
PragmaNoTerminationCheck :: Range -> DeclarationException
InvalidCatchallPragma :: Range -> DeclarationException
UnquoteDefRequiresSignature :: [Name] -> DeclarationException
BadMacroDef :: NiceDeclaration -> DeclarationException
InvalidNoPositivityCheckPragma :: Range -> DeclarationException

-- | Nicifier monad.
type Nice = StateT NiceEnv (Either DeclarationException)
runNice :: Nice a -> Either DeclarationException a

-- | Main.
niceDeclarations :: [Declaration] -> Nice [NiceDeclaration]

-- | (Approximately) convert a <a>NiceDeclaration</a> back to a list of
--   <a>Declaration</a>s.
notSoNiceDeclarations :: NiceDeclaration -> [Declaration]

-- | Has the <a>NiceDeclaration</a> a field of type <a>IsAbstract</a>?
niceHasAbstract :: NiceDeclaration -> Maybe IsAbstract

-- | Termination measure is, for now, a variable name.
type Measure = Name
instance GHC.Show.Show Agda.Syntax.Concrete.Definitions.DeclKind
instance GHC.Classes.Eq Agda.Syntax.Concrete.Definitions.DeclKind
instance GHC.Show.Show Agda.Syntax.Concrete.Definitions.InMutual
instance GHC.Classes.Eq Agda.Syntax.Concrete.Definitions.InMutual
instance GHC.Show.Show Agda.Syntax.Concrete.Definitions.KindOfBlock
instance GHC.Classes.Ord Agda.Syntax.Concrete.Definitions.KindOfBlock
instance GHC.Classes.Eq Agda.Syntax.Concrete.Definitions.KindOfBlock
instance GHC.Show.Show Agda.Syntax.Concrete.Definitions.NiceDeclaration
instance GHC.Show.Show Agda.Syntax.Concrete.Definitions.Clause
instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.Definitions.DeclarationException
instance Agda.Syntax.Position.HasRange Agda.Syntax.Concrete.Definitions.NiceDeclaration
instance Agda.Utils.Except.Error Agda.Syntax.Concrete.Definitions.DeclarationException
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Concrete.Definitions.DeclarationException
instance GHC.Classes.Eq Agda.Syntax.Concrete.Definitions.DataRecOrFun
instance GHC.Show.Show Agda.Syntax.Concrete.Definitions.DataRecOrFun
instance Agda.Syntax.Concrete.Definitions.MakeAbstract a => Agda.Syntax.Concrete.Definitions.MakeAbstract [a]
instance Agda.Syntax.Concrete.Definitions.MakeAbstract Agda.Syntax.Common.IsAbstract
instance Agda.Syntax.Concrete.Definitions.MakeAbstract Agda.Syntax.Concrete.Definitions.NiceDeclaration
instance Agda.Syntax.Concrete.Definitions.MakeAbstract Agda.Syntax.Concrete.Definitions.Clause
instance Agda.Syntax.Concrete.Definitions.MakeAbstract Agda.Syntax.Concrete.WhereClause
instance Agda.Syntax.Concrete.Definitions.MakePrivate a => Agda.Syntax.Concrete.Definitions.MakePrivate [a]
instance Agda.Syntax.Concrete.Definitions.MakePrivate Agda.Syntax.Common.Access
instance Agda.Syntax.Concrete.Definitions.MakePrivate Agda.Syntax.Concrete.Definitions.NiceDeclaration
instance Agda.Syntax.Concrete.Definitions.MakePrivate Agda.Syntax.Concrete.Definitions.Clause
instance Agda.Syntax.Concrete.Definitions.MakePrivate Agda.Syntax.Concrete.WhereClause
instance Data.Semigroup.Semigroup (Agda.Syntax.Concrete.Definitions.Nice (Agda.Syntax.Concrete.Definitions.Fixities, Agda.Syntax.Concrete.Definitions.Polarities))
instance GHC.Base.Monoid (Agda.Syntax.Concrete.Definitions.Nice (Agda.Syntax.Concrete.Definitions.Fixities, Agda.Syntax.Concrete.Definitions.Polarities))


-- | The parser is generated by Happy
--   (<a>http://www.haskell.org/happy</a>). - - Ideally, ranges should be
--   as precise as possible, to get messages that - emphasize precisely the
--   faulting term(s) upon error. - - However, interactive highlighting is
--   only applied at the end of each - mutual block, keywords are only
--   highlighted once (see - <a>Decl</a>). So if the ranges of two
--   declarations - interleave, one must ensure that keyword ranges are not
--   included in - the intersection. (Otherwise they are uncolored by the
--   interactive - highlighting.) -
module Agda.Syntax.Parser.Parser

-- | Parse a module.
moduleParser :: Parser Module
moduleNameParser :: Parser QName

-- | Parse an expression. Could be used in interactions.
exprParser :: Parser Expr

-- | Parse an expression followed by a where clause. Could be used in
--   interactions.
exprWhereParser :: Parser ExprWhere

-- | Parse the token stream. Used by the TeX compiler.
tokensParser :: Parser [Token]

-- | Breaks up a string into substrings. Returns every maximal subsequence
--   of zero or more characters distinct from <tt><a>.</a></tt>.
--   
--   <pre>
--   splitOnDots ""         == [""]
--   splitOnDots "foo.bar"  == ["foo", "bar"]
--   splitOnDots ".foo.bar" == ["", "foo", "bar"]
--   splitOnDots "foo.bar." == ["foo", "bar", ""]
--   splitOnDots "foo..bar" == ["foo", "", "bar"]
--   </pre>
splitOnDots :: String -> [String]
instance GHC.Show.Show Agda.Syntax.Parser.Parser.RHSOrTypeSigs
instance GHC.Show.Show Agda.Syntax.Parser.Parser.RecordDirective
instance GHC.Classes.Eq Agda.Syntax.Parser.Parser.RecordDirective

module Agda.Syntax.Parser

-- | Wrapped Parser type.
data Parser a
parse :: Parser a -> String -> PM a
parsePosString :: Parser a -> Position -> String -> PM a
parseFile' :: (Show a) => Parser a -> AbsolutePath -> PM a

-- | Parses a module.
moduleParser :: Parser Module

-- | Parses a module name.
moduleNameParser :: Parser QName

-- | Parses an expression.
exprParser :: Parser Expr

-- | Parses an expression followed by a where clause.
exprWhereParser :: Parser ExprWhere

-- | Gives the parsed token stream (including comments).
tokensParser :: Parser [Token]

-- | What you get if parsing fails.
data ParseError

-- | Errors that arise at a specific position in the file
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

-- | Parse errors that concern a range in a file.
OverlappingTokensError :: !(Range' SrcFile) -> ParseError

-- | The range of the bigger overlapping token
[errRange] :: ParseError -> !(Range' SrcFile)

-- | Parse errors that concern a whole file.
InvalidExtensionError :: !AbsolutePath -> [String] -> ParseError

-- | The file which the error concerns.
[errPath] :: ParseError -> !AbsolutePath
[errValidExts] :: ParseError -> [String]
ReadFileError :: !AbsolutePath -> IOError -> ParseError

-- | The file which the error concerns.
[errPath] :: ParseError -> !AbsolutePath
[errIOError] :: ParseError -> IOError

-- | Warnings for parsing
data ParseWarning

-- | Parse errors that concern a range in a file.
OverlappingTokensWarning :: !(Range' SrcFile) -> ParseWarning

-- | The range of the bigger overlapping token
[warnRange] :: ParseWarning -> !(Range' SrcFile)

-- | A monad for handling parse results
newtype PM a
PM :: ExceptT ParseError (StateT [ParseWarning] IO) a -> PM a
[unPM] :: PM a -> ExceptT ParseError (StateT [ParseWarning] IO) a
runPMIO :: (MonadIO m) => PM a -> m (Either ParseError a, [ParseWarning])
instance Control.Monad.IO.Class.MonadIO Agda.Syntax.Parser.PM
instance Control.Monad.Error.Class.MonadError Agda.Syntax.Parser.Monad.ParseError Agda.Syntax.Parser.PM
instance GHC.Base.Monad Agda.Syntax.Parser.PM
instance GHC.Base.Applicative Agda.Syntax.Parser.PM
instance GHC.Base.Functor Agda.Syntax.Parser.PM

module Agda.Interaction.Library.Base
type LibName = String
data AgdaLibFile
AgdaLib :: LibName -> FilePath -> [FilePath] -> [LibName] -> AgdaLibFile
[libName] :: AgdaLibFile -> LibName
[libFile] :: AgdaLibFile -> FilePath
[libIncludes] :: AgdaLibFile -> [FilePath]
[libDepends] :: AgdaLibFile -> [LibName]
instance GHC.Show.Show Agda.Interaction.Library.Base.AgdaLibFile

module Agda.Interaction.Library.Parse

-- | .agda-lib parser
parseLibFile :: FilePath -> IO (P AgdaLibFile)

-- | ...and trailing, but not leading, whitespace.
stripComments :: String -> String
splitCommas :: String -> [String]
instance GHC.Show.Show Agda.Interaction.Library.Parse.GenericLine

module Agda.Interaction.Library
getDefaultLibraries :: FilePath -> Bool -> LibM ([LibName], [FilePath])
getInstalledLibraries :: Maybe FilePath -> LibM [AgdaLibFile]
libraryIncludePaths :: Maybe FilePath -> [AgdaLibFile] -> [LibName] -> LibM [FilePath]
type LibName = String
type LibM = ExceptT Doc IO
instance GHC.Show.Show Agda.Interaction.Library.LibError

module Agda.Interaction.Options
data CommandLineOptions
Options :: String -> Maybe FilePath -> [FilePath] -> [AbsolutePath] -> [LibName] -> Maybe FilePath -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> [String] -> Bool -> Bool -> Bool -> Maybe FilePath -> Bool -> Bool -> Int -> [String] -> Bool -> Maybe FilePath -> Bool -> Bool -> Bool -> Maybe FilePath -> FilePath -> FilePath -> Maybe FilePath -> Bool -> Bool -> PragmaOptions -> [String] -> Bool -> Bool -> Bool -> CommandLineOptions
[optProgramName] :: CommandLineOptions -> String
[optInputFile] :: CommandLineOptions -> Maybe FilePath
[optIncludePaths] :: CommandLineOptions -> [FilePath]
[optAbsoluteIncludePaths] :: CommandLineOptions -> [AbsolutePath]
[optLibraries] :: CommandLineOptions -> [LibName]

-- | Use this (if Just) instead of .agda/libraries
[optOverrideLibrariesFile] :: CommandLineOptions -> Maybe FilePath

-- | Use ~<i>.agda</i>defaults
[optDefaultLibs] :: CommandLineOptions -> Bool

-- | look for .agda-lib files
[optUseLibs] :: CommandLineOptions -> Bool
[optShowVersion] :: CommandLineOptions -> Bool
[optShowHelp] :: CommandLineOptions -> Bool
[optInteractive] :: CommandLineOptions -> Bool
[optGHCiInteraction] :: CommandLineOptions -> Bool
[optCompileNoMain] :: CommandLineOptions -> Bool
[optGhcCompile] :: CommandLineOptions -> Bool
[optGhcCallGhc] :: CommandLineOptions -> Bool
[optGhcFlags] :: CommandLineOptions -> [String]
[optEpicCompile] :: CommandLineOptions -> Bool
[optJSCompile] :: CommandLineOptions -> Bool
[optUHCCompile] :: CommandLineOptions -> Bool
[optUHCBin] :: CommandLineOptions -> Maybe FilePath
[optUHCTextualCore] :: CommandLineOptions -> Bool
[optUHCCallUHC] :: CommandLineOptions -> Bool
[optUHCTraceLevel] :: CommandLineOptions -> Int
[optUHCFlags] :: CommandLineOptions -> [String]
[optOptimSmashing] :: CommandLineOptions -> Bool

-- | In the absence of a path the project root is used.
[optCompileDir] :: CommandLineOptions -> Maybe FilePath
[optGenerateVimFile] :: CommandLineOptions -> Bool
[optGenerateLaTeX] :: CommandLineOptions -> Bool
[optGenerateHTML] :: CommandLineOptions -> Bool
[optDependencyGraph] :: CommandLineOptions -> Maybe FilePath
[optLaTeXDir] :: CommandLineOptions -> FilePath
[optHTMLDir] :: CommandLineOptions -> FilePath
[optCSSFile] :: CommandLineOptions -> Maybe FilePath
[optIgnoreInterfaces] :: CommandLineOptions -> Bool
[optForcing] :: CommandLineOptions -> Bool
[optPragmaOptions] :: CommandLineOptions -> PragmaOptions
[optEpicFlags] :: CommandLineOptions -> [String]
[optSafe] :: CommandLineOptions -> Bool
[optSharing] :: CommandLineOptions -> Bool
[optCaching] :: CommandLineOptions -> Bool
data IgnoreFlags
IgnoreFlags :: IgnoreFlags
RespectFlags :: IgnoreFlags

-- | Options which can be set in a pragma.
data PragmaOptions
PragmaOptions :: Bool -> Bool -> Verbosity -> Bool -> Bool -> Bool -> Bool -> CutOff -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Int -> PragmaOptions
[optShowImplicit] :: PragmaOptions -> Bool
[optShowIrrelevant] :: PragmaOptions -> Bool
[optVerbose] :: PragmaOptions -> Verbosity
[optProofIrrelevance] :: PragmaOptions -> Bool
[optAllowUnsolved] :: PragmaOptions -> Bool
[optDisablePositivity] :: PragmaOptions -> Bool
[optTerminationCheck] :: PragmaOptions -> Bool

-- | Cut off structural order comparison at some depth in termination
--   checker?
[optTerminationDepth] :: PragmaOptions -> CutOff
[optCompletenessCheck] :: PragmaOptions -> Bool
[optUniverseCheck] :: PragmaOptions -> Bool
[optSizedTypes] :: PragmaOptions -> Bool
[optInjectiveTypeConstructors] :: PragmaOptions -> Bool
[optGuardingTypeConstructors] :: PragmaOptions -> Bool
[optUniversePolymorphism] :: PragmaOptions -> Bool
[optIrrelevantProjections] :: PragmaOptions -> Bool

-- | irrelevant levels, irrelevant data matching
[optExperimentalIrrelevance] :: PragmaOptions -> Bool
[optWithoutK] :: PragmaOptions -> Bool

-- | Allow definitions by copattern matching?
[optCopatterns] :: PragmaOptions -> Bool

-- | Is pattern matching allowed in the current file?
[optPatternMatching] :: PragmaOptions -> Bool
[optExactSplit] :: PragmaOptions -> Bool
[optEta] :: PragmaOptions -> Bool

-- | Can rewrite rules be added and used?
[optRewriting] :: PragmaOptions -> Bool

-- | Should system generated projections <tt>ProjSystem</tt> be printed
--   postfix (True) or prefix (False).
[optPostfixProjections] :: PragmaOptions -> Bool
[optInstanceSearchDepth] :: PragmaOptions -> Int

-- | The options from an <tt>OPTIONS</tt> pragma.
--   
--   In the future it might be nice to switch to a more structured
--   representation. Note that, currently, there is not a one-to-one
--   correspondence between list elements and options.
type OptionsPragma = [String]

-- | <tt>f :: Flag opts</tt> is an action on the option record that results
--   from parsing an option. <tt>f opts</tt> produces either an error
--   message or an updated options record
type Flag opts = opts -> OptM opts
type OptM = ExceptT String IO
runOptM :: OptM a -> IO (Either String a)
type Verbosity = Trie String Int

-- | Checks that the given options are consistent.
checkOpts :: Flag CommandLineOptions

-- | Parse the standard options.
parseStandardOptions :: [String] -> OptM CommandLineOptions
parseStandardOptions' :: [String] -> Flag CommandLineOptions

-- | Parse options from an options pragma.
parsePragmaOptions :: [String] -> CommandLineOptions -> OptM PragmaOptions

-- | Parse options for a plugin.
parsePluginOptions :: [String] -> [OptDescr (Flag opts)] -> Flag opts
defaultOptions :: CommandLineOptions
defaultInteractionOptions :: PragmaOptions
defaultVerbosity :: Verbosity

-- | The default termination depth.
defaultCutOff :: CutOff
defaultPragmaOptions :: PragmaOptions

-- | Used for printing usage info.
standardOptions_ :: [OptDescr ()]

-- | Check for unsafe pramas. Gives a list of used unsafe flags.
unsafePragmaOptions :: PragmaOptions -> [String]

-- | This should probably go somewhere else.
isLiterate :: FilePath -> Bool

-- | Map a function over the long options. Also removes the short options.
--   Will be used to add the plugin name to the plugin options.
mapFlag :: (String -> String) -> OptDescr a -> OptDescr a

-- | The usage info message. The argument is the program name (probably
--   agda).
usage :: [OptDescr ()] -> String -> String

-- | Returns the absolute default lib dir. This directory is used to store
--   the Primitive.agda file.
defaultLibDir :: IO FilePath
inputFlag :: FilePath -> Flag CommandLineOptions
standardOptions :: [OptDescr (Flag CommandLineOptions)]

-- | Simple interface for System.Console.GetOpt Could be moved to
--   Agda.Utils.Options (does not exist yet)
getOptSimple :: [String] -> [OptDescr (Flag opts)] -> (String -> Flag opts) -> Flag opts
instance GHC.Show.Show Agda.Interaction.Options.CommandLineOptions
instance GHC.Classes.Eq Agda.Interaction.Options.PragmaOptions
instance GHC.Show.Show Agda.Interaction.Options.PragmaOptions
instance GHC.Classes.Eq Agda.Interaction.Options.IgnoreFlags


-- | Ranges.
module Agda.Interaction.Highlighting.Range

-- | Character ranges. The first character in the file has position 1. Note
--   that the <a>to</a> position is considered to be outside of the range.
--   
--   Invariant: <tt><a>from</a> <a>&lt;=</a> <a>to</a></tt>.
data Range
Range :: Int -> Range
[from, to] :: Range -> Int

-- | The <a>Range</a> invariant.
rangeInvariant :: Range -> Bool

-- | Zero or more consecutive and separated ranges.
newtype Ranges
Ranges :: [Range] -> Ranges

-- | The <a>Ranges</a> invariant.
rangesInvariant :: Ranges -> Bool

-- | <a>True</a> iff the ranges overlap.
--   
--   The ranges are assumed to be well-formed.
overlapping :: Range -> Range -> Bool

-- | <a>True</a> iff the range is empty.
empty :: Range -> Bool

-- | Converts a range to a list of positions.
rangeToPositions :: Range -> [Int]

-- | Converts several ranges to a list of positions.
rangesToPositions :: Ranges -> [Int]

-- | Converts a <a>Range</a> to a <a>Ranges</a>.
rToR :: Range -> Ranges
rangeToEndPoints :: Range -> Maybe (Int, Int)

-- | <tt>minus xs ys</tt> computes the difference between <tt>xs</tt> and
--   <tt>ys</tt>: the result contains those positions which are present in
--   <tt>xs</tt> but not in <tt>ys</tt>.
--   
--   Linear in the lengths of the input ranges.
minus :: Ranges -> Ranges -> Ranges
instance GHC.Show.Show Agda.Interaction.Highlighting.Range.Ranges
instance GHC.Classes.Eq Agda.Interaction.Highlighting.Range.Ranges
instance GHC.Show.Show Agda.Interaction.Highlighting.Range.Range
instance GHC.Classes.Ord Agda.Interaction.Highlighting.Range.Range
instance GHC.Classes.Eq Agda.Interaction.Highlighting.Range.Range


-- | Types used for precise syntax highlighting.
module Agda.Interaction.Highlighting.Precise

-- | Syntactic aspects of the code. (These cannot overlap.) They can be
--   obtained from the lexed tokens already, except for the
--   <a>NameKind</a>.
data Aspect
Comment :: Aspect
Keyword :: Aspect
String :: Aspect
Number :: Aspect

-- | Symbols like forall, =, -&gt;, etc.
Symbol :: Aspect

-- | Things like Set and Prop.
PrimitiveType :: Aspect

-- | Is the name an operator part?
Name :: (Maybe NameKind) -> Bool -> Aspect

-- | <tt>NameKind</tt>s are figured our during scope checking.
data NameKind

-- | Bound variable.
Bound :: NameKind

-- | Inductive or coinductive constructor.
Constructor :: Induction -> NameKind
Datatype :: NameKind

-- | Record field.
Field :: NameKind
Function :: NameKind

-- | Module name.
Module :: NameKind
Postulate :: NameKind

-- | Primitive.
Primitive :: NameKind

-- | Record type.
Record :: NameKind

-- | Named argument, like x in {x = v}
Argument :: NameKind

-- | Macro.
Macro :: NameKind

-- | Other aspects, generated by type checking. (These can overlap with
--   each other and with <a>Aspect</a>s.)
data OtherAspect
Error :: OtherAspect
DottedPattern :: OtherAspect
UnsolvedMeta :: OtherAspect

-- | Unsolved constraint not connected to meta-variable. This could for
--   instance be an emptyness constraint.
UnsolvedConstraint :: OtherAspect
TerminationProblem :: OtherAspect
PositivityProblem :: OtherAspect

-- | When this constructor is used it is probably a good idea to include a
--   <a>note</a> explaining why the pattern is incomplete.
IncompletePattern :: OtherAspect

-- | Code which is being type-checked.
TypeChecks :: OtherAspect

-- | Meta information which can be associated with a character/character
--   range.
data Aspects
Aspects :: Maybe Aspect -> [OtherAspect] -> Maybe String -> Maybe (TopLevelModuleName, Int) -> Aspects
[aspect] :: Aspects -> Maybe Aspect
[otherAspects] :: Aspects -> [OtherAspect]

-- | This note, if present, can be displayed as a tool-tip or something
--   like that. It should contain useful information about the range (like
--   the module containing a certain identifier, or the fixity of an
--   operator).
[note] :: Aspects -> Maybe String

-- | The definition site of the annotated thing, if applicable and known.
--   File positions are counted from 1.
[definitionSite] :: Aspects -> Maybe (TopLevelModuleName, Int)

-- | A <a>File</a> is a mapping from file positions to meta information.
--   
--   The first position in the file has number 1.
newtype File
File :: IntMap Aspects -> File
[mapping] :: File -> IntMap Aspects

-- | Syntax highlighting information.
type HighlightingInfo = CompressedFile

-- | <tt><a>singleton</a> rs m</tt> is a file whose positions are those in
--   <tt>rs</tt>, and in which every position is associated with
--   <tt>m</tt>.
singleton :: Ranges -> Aspects -> File

-- | Like <a>singleton</a>, but with several <a>Ranges</a> instead of only
--   one.
several :: [Ranges] -> Aspects -> File

-- | Merges files.
merge :: File -> File -> File

-- | Returns the smallest position, if any, in the <a>File</a>.
smallestPos :: File -> Maybe Int

-- | Convert the <a>File</a> to a map from file positions (counting from 1)
--   to meta information.
toMap :: File -> IntMap Aspects

-- | A compressed <a>File</a>, in which consecutive positions with the same
--   <a>Aspects</a> are stored together.
newtype CompressedFile
CompressedFile :: [(Range, Aspects)] -> CompressedFile
[ranges] :: CompressedFile -> [(Range, Aspects)]

-- | Invariant for compressed files.
--   
--   Note that these files are not required to be <i>maximally</i>
--   compressed, because ranges are allowed to be empty, and the
--   <a>Aspects</a>s in adjacent ranges are allowed to be equal.
compressedFileInvariant :: CompressedFile -> Bool

-- | Compresses a file by merging consecutive positions with equal meta
--   information into longer ranges.
compress :: File -> CompressedFile

-- | Decompresses a compressed file.
decompress :: CompressedFile -> File

-- | Clear any highlighting info for the given ranges. Used to make sure
--   unsolved meta highlighting overrides error highlighting.
noHighlightingInRange :: Ranges -> CompressedFile -> CompressedFile

-- | <tt><a>singletonC</a> rs m</tt> is a file whose positions are those in
--   <tt>rs</tt>, and in which every position is associated with
--   <tt>m</tt>.
singletonC :: Ranges -> Aspects -> CompressedFile

-- | Like <tt>singletonR</tt>, but with a list of <a>Ranges</a> instead of
--   a single one.
severalC :: [Ranges] -> Aspects -> CompressedFile

-- | <tt>splitAtC p f</tt> splits the compressed file <tt>f</tt> into
--   <tt>(f1, f2)</tt>, where all the positions in <tt>f1</tt> are <tt>&lt;
--   p</tt>, and all the positions in <tt>f2</tt> are <tt>&gt;= p</tt>.
splitAtC :: Int -> CompressedFile -> (CompressedFile, CompressedFile)
selectC :: Range -> CompressedFile -> CompressedFile

-- | Returns the smallest position, if any, in the <a>CompressedFile</a>.
smallestPosC :: CompressedFile -> Maybe Int

-- | Merges compressed files.
mergeC :: CompressedFile -> CompressedFile -> CompressedFile
instance GHC.Show.Show Agda.Interaction.Highlighting.Precise.CompressedFile
instance GHC.Classes.Eq Agda.Interaction.Highlighting.Precise.CompressedFile
instance GHC.Show.Show Agda.Interaction.Highlighting.Precise.File
instance GHC.Classes.Eq Agda.Interaction.Highlighting.Precise.File
instance GHC.Show.Show Agda.Interaction.Highlighting.Precise.Aspects
instance GHC.Enum.Bounded Agda.Interaction.Highlighting.Precise.OtherAspect
instance GHC.Enum.Enum Agda.Interaction.Highlighting.Precise.OtherAspect
instance GHC.Show.Show Agda.Interaction.Highlighting.Precise.OtherAspect
instance GHC.Classes.Eq Agda.Interaction.Highlighting.Precise.OtherAspect
instance GHC.Show.Show Agda.Interaction.Highlighting.Precise.Aspect
instance GHC.Classes.Eq Agda.Interaction.Highlighting.Precise.Aspect
instance GHC.Show.Show Agda.Interaction.Highlighting.Precise.NameKind
instance GHC.Classes.Eq Agda.Interaction.Highlighting.Precise.NameKind
instance GHC.Classes.Eq Agda.Interaction.Highlighting.Precise.Aspects
instance Data.Semigroup.Semigroup Agda.Interaction.Highlighting.Precise.Aspects
instance GHC.Base.Monoid Agda.Interaction.Highlighting.Precise.Aspects
instance Data.Semigroup.Semigroup Agda.Interaction.Highlighting.Precise.File
instance GHC.Base.Monoid Agda.Interaction.Highlighting.Precise.File
instance Data.Semigroup.Semigroup Agda.Interaction.Highlighting.Precise.CompressedFile
instance GHC.Base.Monoid Agda.Interaction.Highlighting.Precise.CompressedFile


-- | Data type for all interactive responses
module Agda.Interaction.Response

-- | Responses for any interactive interface
--   
--   Note that the response is given in pieces and incrementally, so the
--   user can have timely response even during long computations.
data Response
Resp_HighlightingInfo :: HighlightingInfo -> ModuleToSource -> Response
Resp_Status :: Status -> Response
Resp_JumpToError :: FilePath -> Int32 -> Response
Resp_InteractionPoints :: [InteractionId] -> Response
Resp_GiveAction :: InteractionId -> GiveResult -> Response
Resp_MakeCase :: MakeCaseVariant -> [String] -> Response

-- | Solution for one or more meta-variables.
Resp_SolveAll :: [(InteractionId, Expr)] -> Response
Resp_DisplayInfo :: DisplayInfo -> Response

-- | The integer is the message's debug level.
Resp_RunningInfo :: Int -> String -> Response
Resp_ClearRunningInfo :: Response
Resp_ClearHighlighting :: Response

-- | There are two kinds of "make case" commands.
data MakeCaseVariant
Function :: MakeCaseVariant
ExtendedLambda :: MakeCaseVariant

-- | Info to display at the end of an interactive command
data DisplayInfo
Info_CompilationOk :: DisplayInfo
Info_Constraints :: String -> DisplayInfo

-- | Strings are the goals, the warnings and the (non-fatal) errors
Info_AllGoalsWarnings :: String -> String -> String -> DisplayInfo
Info_Time :: Doc -> DisplayInfo

-- | When an error message is displayed this constructor should be used, if
--   appropriate. | Info_Warning String --FNF: currently unused
Info_Error :: String -> DisplayInfo

-- | <a>Info_Intro</a> denotes two different types of errors TODO: split
--   these into separate constructors
Info_Intro :: Doc -> DisplayInfo

-- | <a>Info_Auto</a> denotes either an error or a success (when
--   <a>Resp_GiveAction</a> is present) TODO: split these into separate
--   constructors
Info_Auto :: String -> DisplayInfo
Info_ModuleContents :: Doc -> DisplayInfo
Info_SearchAbout :: Doc -> DisplayInfo
Info_WhyInScope :: Doc -> DisplayInfo
Info_NormalForm :: Doc -> DisplayInfo
Info_GoalType :: Doc -> DisplayInfo
Info_CurrentGoal :: Doc -> DisplayInfo
Info_InferredType :: Doc -> DisplayInfo
Info_Context :: Doc -> DisplayInfo
Info_HelperFunction :: Doc -> DisplayInfo
Info_Version :: DisplayInfo

-- | Status information.
data Status
Status :: Bool -> Bool -> Status

-- | Are implicit arguments displayed?
[sShowImplicitArguments] :: Status -> Bool

-- | Has the module been successfully type checked?
[sChecked] :: Status -> Bool

-- | Give action result
--   
--   Comment derived from agda2-mode.el
--   
--   If <a>GiveResult</a> is 'Give_String s', then the goal is replaced by
--   <tt>s</tt>, and otherwise the text inside the goal is retained
--   (parenthesised if <a>GiveResult</a> is <a>Give_Paren</a>).
data GiveResult
Give_String :: String -> GiveResult
Give_Paren :: GiveResult
Give_NoParen :: GiveResult

-- | Callback fuction to call when there is a response to give to the
--   interactive frontend.
--   
--   Note that the response is given in pieces and incrementally, so the
--   user can have timely response even during long computations.
--   
--   Typical <a>InteractionOutputCallback</a> functions:
--   
--   <ul>
--   <li>Convert the response into a <a>String</a> representation and print
--   it on standard output (suitable for inter-process communication).</li>
--   <li>Put the response into a mutable variable stored in the closure of
--   the <a>InteractionOutputCallback</a> function. (suitable for
--   intra-process communication).</li>
--   </ul>
type InteractionOutputCallback = Response -> TCM ()

-- | The default <a>InteractionOutputCallback</a> function prints certain
--   things to stdout (other things generate internal errors).
defaultInteractionOutputCallback :: InteractionOutputCallback
instance GHC.Show.Show Agda.Interaction.Response.DisplayInfo


-- | Code for instructing Emacs to do things
module Agda.Interaction.EmacsCommand

-- | Simple Emacs Lisp expressions.
data Lisp a

-- | Atom.
A :: a -> Lisp a
Cons :: (Lisp a) -> (Lisp a) -> Lisp a

-- | List.
L :: [Lisp a] -> Lisp a
Q :: (Lisp a) -> Lisp a

-- | Formats a response command.
--   
--   Replaces <tt>'\n'</tt> with spaces to ensure that each command is a
--   single line.
response :: Lisp String -> String

-- | Writes a response command to standard output.
putResponse :: Lisp String -> IO ()
display_info' :: Bool -> String -> String -> Lisp String
display_warning :: String -> String -> Lisp String

-- | Clear the running info buffer.
clearRunningInfo :: Lisp String

-- | Clear the warning buffer
clearWarning :: Lisp String

-- | Display running information about what the type-checker is up to.
displayRunningInfo :: String -> Lisp String
instance Agda.Utils.Pretty.Pretty a => Agda.Utils.Pretty.Pretty (Agda.Interaction.EmacsCommand.Lisp a)
instance GHC.Show.Show (Agda.Interaction.EmacsCommand.Lisp GHC.Base.String)

module Agda.ImpossibleTest
impossibleTest :: a


-- | Exports the UHC API, and provides dummy definitions if the backend is
--   disabled.
module Agda.Compiler.UHC.Bridge
uhcBackendEnabled :: Bool
type PP_Doc = String
putPPFile :: String -> PP_Doc -> Int -> IO ()
disp :: PP_Doc -> Int -> ShowS
pp :: PP a => a -> PP_Doc
class Serialize a
putSerializeFile :: FilePath -> a -> IO ()
serialize :: x -> Put
unserialize :: Get x
data EHCOpts
defaultEHCOpts :: EHCOpts
data HsName
data CTag
mkHsName :: [String] -> String -> HsName
mkHsName1 :: String -> HsName
mkUniqueHsName :: String -> [String] -> String -> HsName
data CModule
data CImport
data CExport
data CDeclMeta
data CDataCon
data CExpr
data CBind
data CAlt
data CPat
data CPatFld
mkUnit :: EHCOpts -> CExpr
mkInt :: EHCOpts -> Int -> CExpr
mkInteger :: EHCOpts -> Integer -> CExpr
mkChar :: Char -> CExpr
mkString :: EHCOpts -> String -> CExpr
mkError :: EHCOpts -> String -> CExpr
mkUndefined :: EHCOpts -> CExpr
mkVar :: HsName -> CExpr
mkLet1Plain :: HsName -> CExpr -> CExpr -> CExpr
mkLet1Strict :: HsName -> CExpr -> CExpr -> CExpr
mkLetRec :: [CBind] -> CExpr -> CExpr
mkLam :: [HsName] -> CExpr -> CExpr
mkApp :: CExpr -> [CExpr] -> CExpr
mkBind1 :: HsName -> CExpr -> CBind
mkBind1Nm1 :: HsName -> CBind
mkCTag :: HsName -> HsName -> Int -> Int -> CTag
destructCTag :: a -> (HsName -> HsName -> Int -> Int -> a) -> CTag -> a
ctagUnit :: CTag
ctagTrue :: EHCOpts -> CTag
ctagFalse :: EHCOpts -> CTag
ctagCons :: EHCOpts -> CTag
ctagNil :: EHCOpts -> CTag
mkCase :: CExpr -> [CAlt] -> CExpr
mkAlt :: CPat -> CExpr -> CAlt
mkPatCon :: CTag -> CPatRest -> [CPatFld] -> CPat
mkPatRestEmpty :: CPatRest
mkPatFldBind :: (HsName, CExpr) -> CBind -> CPatFld
mkTagTup :: CTag -> [CExpr] -> CExpr
mkModule :: HsName -> [CExport] -> [CImport] -> [CDeclMeta] -> CExpr -> CModule
mkImport :: HsName -> CImport
mkExport :: HsName -> CExport
mkMetaData :: HsName -> [CDataCon] -> CDeclMeta
mkMetaDataCon :: HsName -> Int -> Int -> CDataCon
mkMetaDataConFromCTag :: CTag -> Maybe CDataCon
mkMain :: HsName -> CExpr
parseExpr :: EHCOpts -> String -> Either [String] CExpr
printModule :: EHCOpts -> CModule -> PP_Doc
instance GHC.Show.Show Agda.Compiler.UHC.Bridge.CExpr
instance GHC.Classes.Ord Agda.Compiler.UHC.Bridge.CExpr
instance GHC.Classes.Eq Agda.Compiler.UHC.Bridge.CExpr
instance GHC.Classes.Eq Agda.Compiler.UHC.Bridge.HsName
instance GHC.Classes.Ord Agda.Compiler.UHC.Bridge.HsName
instance GHC.Show.Show Agda.Compiler.UHC.Bridge.HsName
instance GHC.Classes.Eq Agda.Compiler.UHC.Bridge.CTag
instance GHC.Classes.Ord Agda.Compiler.UHC.Bridge.CTag
instance GHC.Show.Show Agda.Compiler.UHC.Bridge.CTag
instance Agda.Compiler.UHC.Bridge.PP Agda.Compiler.UHC.Bridge.CExpr
instance Agda.Compiler.UHC.Bridge.Serialize Agda.Compiler.UHC.Bridge.HsName
instance Agda.Compiler.UHC.Bridge.Serialize Agda.Compiler.UHC.Bridge.CTag
instance Agda.Compiler.UHC.Bridge.Serialize Agda.Compiler.UHC.Bridge.CModule
instance Agda.Compiler.UHC.Bridge.Serialize Agda.Compiler.UHC.Bridge.CExpr


-- | Defines some magic builtin datatypes.
module Agda.Compiler.UHC.MagicTypes
builtinUnitCtor :: HsName

-- | name of a magic, differently translated datatype/constructor
type MagicName = String
getMagicTypes :: MagicTypeInfo
type MagicConstrInfo = Map MagicName CTag
type MagicTypeInfo = Map MagicName (HsDataType, MagicConstrInfo)
data HsDataType
HsDataType :: HsName -> HsDataType
HsUnit :: HsDataType


-- | Defines UHC Core functions used in other parts of Agda. E.g. parsing
--   Core pragmas uses the <tt>parseCoreCode</tt> function.
module Agda.Compiler.UHC.Pragmas.Base
type CoreExpr = String
data CoreType

-- | Magic name
CTMagic :: MagicName -> CoreType
CTNormal :: String -> CoreType
data CoreConstr
CCMagic :: MagicName -> MagicName -> CoreConstr
CCNormal :: HsName -> HsName -> Int -> CoreConstr
coreConstrToCTag :: CoreConstr -> Int -> CTag
setTag :: CoreConstr -> Int -> CoreConstr
data HsName
instance GHC.Show.Show Agda.Compiler.UHC.Pragmas.Base.CoreConstr
instance GHC.Classes.Eq Agda.Compiler.UHC.Pragmas.Base.CoreConstr
instance GHC.Show.Show Agda.Compiler.UHC.Pragmas.Base.CoreType
instance GHC.Classes.Eq Agda.Compiler.UHC.Pragmas.Base.CoreType

module Agda.Compiler.Treeless.Pretty
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Treeless.TTerm

module Agda.Compiler.JS.Syntax
data Exp
Self :: Exp
Local :: LocalId -> Exp
Global :: GlobalId -> Exp
Undefined :: Exp
String :: String -> Exp
Char :: Char -> Exp
Integer :: Integer -> Exp
Double :: Double -> Exp
Lambda :: Nat -> Exp -> Exp
Object :: (Map MemberId Exp) -> Exp
Apply :: Exp -> [Exp] -> Exp
Lookup :: Exp -> MemberId -> Exp
If :: Exp -> Exp -> Exp -> Exp
BinOp :: Exp -> String -> Exp -> Exp
PreOp :: String -> Exp -> Exp
Const :: String -> Exp

-- | Arbitrary JS code.
PlainJS :: String -> Exp
newtype LocalId
LocalId :: Nat -> LocalId
newtype GlobalId
GlobalId :: [String] -> GlobalId
newtype MemberId
MemberId :: String -> MemberId
data Export
Export :: [MemberId] -> Bool -> Exp -> Export
[expName] :: Export -> [MemberId]
[isCoind] :: Export -> Bool
[defn] :: Export -> Exp
data Module
Module :: GlobalId -> [Export] -> Maybe Exp -> Module
[modName] :: Module -> GlobalId
[exports] :: Module -> [Export]
[postscript] :: Module -> Maybe Exp
class Uses a
uses :: Uses a => a -> Set [MemberId]
class Globals a
globals :: Globals a => a -> Set GlobalId
instance GHC.Show.Show Agda.Compiler.JS.Syntax.Module
instance GHC.Show.Show Agda.Compiler.JS.Syntax.Export
instance GHC.Show.Show Agda.Compiler.JS.Syntax.Exp
instance GHC.Show.Show Agda.Compiler.JS.Syntax.MemberId
instance GHC.Classes.Ord Agda.Compiler.JS.Syntax.MemberId
instance GHC.Classes.Eq Agda.Compiler.JS.Syntax.MemberId
instance GHC.Show.Show Agda.Compiler.JS.Syntax.GlobalId
instance GHC.Classes.Ord Agda.Compiler.JS.Syntax.GlobalId
instance GHC.Classes.Eq Agda.Compiler.JS.Syntax.GlobalId
instance GHC.Show.Show Agda.Compiler.JS.Syntax.LocalId
instance GHC.Classes.Ord Agda.Compiler.JS.Syntax.LocalId
instance GHC.Classes.Eq Agda.Compiler.JS.Syntax.LocalId
instance Agda.Compiler.JS.Syntax.Uses a => Agda.Compiler.JS.Syntax.Uses [a]
instance Agda.Compiler.JS.Syntax.Uses a => Agda.Compiler.JS.Syntax.Uses (Data.Map.Base.Map k a)
instance Agda.Compiler.JS.Syntax.Uses Agda.Compiler.JS.Syntax.Exp
instance Agda.Compiler.JS.Syntax.Uses Agda.Compiler.JS.Syntax.Export
instance Agda.Compiler.JS.Syntax.Globals a => Agda.Compiler.JS.Syntax.Globals [a]
instance Agda.Compiler.JS.Syntax.Globals a => Agda.Compiler.JS.Syntax.Globals (Data.Map.Base.Map k a)
instance Agda.Compiler.JS.Syntax.Globals Agda.Compiler.JS.Syntax.Exp
instance Agda.Compiler.JS.Syntax.Globals Agda.Compiler.JS.Syntax.Export
instance Agda.Compiler.JS.Syntax.Globals Agda.Compiler.JS.Syntax.Module

module Agda.Compiler.JS.Substitution
map :: Nat -> (Nat -> LocalId -> Exp) -> Exp -> Exp
shift :: Nat -> Exp -> Exp
shiftFrom :: Nat -> Nat -> Exp -> Exp
shifter :: Nat -> Nat -> LocalId -> Exp
subst :: Nat -> [Exp] -> Exp -> Exp
substituter :: Nat -> [Exp] -> Nat -> LocalId -> Exp
map' :: Nat -> (Nat -> LocalId -> Exp) -> Exp -> Exp
subst' :: Nat -> [Exp] -> Exp -> Exp
apply :: Exp -> [Exp] -> Exp
lookup :: Exp -> MemberId -> Exp
self :: Exp -> Exp -> Exp
fix :: Exp -> Exp
curriedApply :: Exp -> [Exp] -> Exp
curriedLambda :: Nat -> Exp -> Exp
emp :: Exp
union :: Exp -> Exp -> Exp
vine :: [MemberId] -> Exp -> Exp
object :: [([MemberId], Exp)] -> Exp

module Agda.Compiler.JS.Pretty
br :: Int -> String
unescape :: Char -> String
unescapes :: String -> String
class Pretty a
pretty :: Pretty a => Nat -> Int -> a -> String
class Pretties a
pretties :: Pretties a => Nat -> Int -> a -> [String]
block :: Nat -> Int -> Exp -> String
block' :: Nat -> Int -> Exp -> String
modname :: GlobalId -> String
exports :: Nat -> Int -> Set [MemberId] -> [Export] -> String
instance (Agda.Compiler.JS.Pretty.Pretty a, Agda.Compiler.JS.Pretty.Pretty b) => Agda.Compiler.JS.Pretty.Pretty (a, b)
instance Agda.Compiler.JS.Pretty.Pretty a => Agda.Compiler.JS.Pretty.Pretties [a]
instance (Agda.Compiler.JS.Pretty.Pretty a, Agda.Compiler.JS.Pretty.Pretty b) => Agda.Compiler.JS.Pretty.Pretties (Data.Map.Base.Map a b)
instance Agda.Compiler.JS.Pretty.Pretty Agda.Compiler.JS.Syntax.LocalId
instance Agda.Compiler.JS.Pretty.Pretty Agda.Compiler.JS.Syntax.GlobalId
instance Agda.Compiler.JS.Pretty.Pretty Agda.Compiler.JS.Syntax.MemberId
instance Agda.Compiler.JS.Pretty.Pretty Agda.Compiler.JS.Syntax.Exp
instance Agda.Compiler.JS.Pretty.Pretty Agda.Compiler.JS.Syntax.Module


-- | Agda-specific benchmarking structure.
module Agda.Benchmarking

-- | Phases to allocate CPU time to.
data Phase

-- | Happy parsing and operator parsing.
Parsing :: Phase

-- | Import chasing.
Import :: Phase

-- | Reading interface files.
Deserialization :: Phase

-- | Scope checking and translation to abstract syntax.
Scoping :: Phase

-- | Type checking and translation to internal syntax.
Typing :: Phase

-- | Termination checking.
Termination :: Phase

-- | Positivity checking and polarity computation.
Positivity :: Phase

-- | Injectivity checking.
Injectivity :: Phase

-- | Checking for projection likeness.
ProjectionLikeness :: Phase

-- | Coverage checking and compilation to case trees.
Coverage :: Phase

-- | Generating highlighting info.
Highlighting :: Phase

-- | Writing interface files.
Serialization :: Phase

-- | Deac code elimination.
DeadCode :: Phase

-- | Subphase for <a>Termination</a>.
Graph :: Phase

-- | Subphase for <a>Termination</a>.
RecCheck :: Phase

-- | Subphase for <a>Termination</a>.
Reduce :: Phase

-- | Subphase for <a>Termination</a>.
Level :: Phase

-- | Subphase for <a>Termination</a>.
Compare :: Phase

-- | Subphase for <a>Termination</a>.
With :: Phase

-- | Subphase for <a>Import</a>.
ModuleName :: Phase

-- | Subphase for <a>Serialization</a>.
BuildInterface :: Phase

-- | Subphase for <a>Serialization</a>.
Sort :: Phase

-- | Subphase for <a>Serialization</a>.
BinaryEncode :: Phase

-- | Subphase for <a>Serialization</a>.
Compress :: Phase

-- | Subphase for <a>Parsing</a>.
Operators :: Phase

-- | Subphase for <a>Typing</a>: free variable computation.
Free :: Phase

-- | Subphase for <a>Typing</a>: occurs check for solving metas.
OccursCheck :: Phase

-- | Subphase for <a>Typing</a>: checking the LHS
CheckLHS :: Phase

-- | Subphase for <a>Typing</a>: checking the RHS
CheckRHS :: Phase

-- | Subphase for <a>Typing</a>: checking a type signature
TypeSig :: Phase

-- | Subphase for <a>CheckLHS</a>: unification of the indices
UnifyIndices :: Phase

-- | Pretty printing names.
InverseScopeLookup :: Phase
type Benchmark = Benchmark Phase
type Account = Account Phase

-- | Global variable to store benchmark statistics.
benchmarks :: IORef Benchmark

-- | Benchmark an IO computation and bill it to the given account.
billToIO :: Account -> IO a -> IO a

-- | Benchmark a pure computation and bill it to the given account.
billToPure :: Account -> a -> a
instance GHC.Enum.Bounded Agda.Benchmarking.Phase
instance GHC.Enum.Enum Agda.Benchmarking.Phase
instance GHC.Show.Show Agda.Benchmarking.Phase
instance GHC.Classes.Ord Agda.Benchmarking.Phase
instance GHC.Classes.Eq Agda.Benchmarking.Phase
instance Agda.Utils.Pretty.Pretty Agda.Benchmarking.Phase
instance Agda.Utils.Benchmark.MonadBench Agda.Benchmarking.Phase GHC.Types.IO


-- | This module defines the notion of a scope and operations on scopes.
module Agda.Syntax.Scope.Base

-- | A scope is a named collection of names partitioned into public and
--   private names.
data Scope
Scope :: ModuleName -> [ModuleName] -> ScopeNameSpaces -> Map QName ModuleName -> Bool -> Scope
[scopeName] :: Scope -> ModuleName
[scopeParents] :: Scope -> [ModuleName]
[scopeNameSpaces] :: Scope -> ScopeNameSpaces
[scopeImports] :: Scope -> Map QName ModuleName
[scopeDatatypeModule] :: Scope -> Bool

-- | See <a>Access</a>.
data NameSpaceId

-- | Things not exported by this module.
PrivateNS :: NameSpaceId

-- | Things defined and exported by this module.
PublicNS :: NameSpaceId

-- | Things from open public, exported by this module.
ImportedNS :: NameSpaceId

-- | Visible (as qualified) from outside, but not exported when opening the
--   module. Used for qualified constructors.
OnlyQualifiedNS :: NameSpaceId
type ScopeNameSpaces = [(NameSpaceId, NameSpace)]
localNameSpace :: Access -> NameSpaceId
nameSpaceAccess :: NameSpaceId -> Access

-- | Get a <a>NameSpace</a> from <a>Scope</a>.
scopeNameSpace :: NameSpaceId -> Scope -> NameSpace

-- | A lens for <a>scopeNameSpaces</a>
updateScopeNameSpaces :: (ScopeNameSpaces -> ScopeNameSpaces) -> Scope -> Scope

-- | `<tt>Monadic'</tt> lens (Functor sufficient).
updateScopeNameSpacesM :: (Functor m) => (ScopeNameSpaces -> m ScopeNameSpaces) -> Scope -> m Scope

-- | The complete information about the scope at a particular program point
--   includes the scope stack, the local variables, and the context
--   precedence.
data ScopeInfo
ScopeInfo :: ModuleName -> Map ModuleName Scope -> LocalVars -> Precedence -> Map QName [QName] -> Map ModuleName [QName] -> InScopeSet -> ScopeInfo
[scopeCurrent] :: ScopeInfo -> ModuleName
[scopeModules] :: ScopeInfo -> Map ModuleName Scope
[scopeLocals] :: ScopeInfo -> LocalVars
[scopePrecedence] :: ScopeInfo -> Precedence
[scopeInverseName] :: ScopeInfo -> Map QName [QName]
[scopeInverseModule] :: ScopeInfo -> Map ModuleName [QName]
[scopeInScope] :: ScopeInfo -> InScopeSet

-- | Local variables.
type LocalVars = AssocList Name LocalVar

-- | A local variable can be shadowed by an import. In case of reference to
--   a shadowed variable, we want to report a scope error.
data LocalVar

-- | Unique ID of local variable.
LocalVar :: Name -> LocalVar
[localVar] :: LocalVar -> Name

-- | This local variable is shadowed by one or more imports. (List not
--   empty).
ShadowedVar :: Name -> [AbstractName] -> LocalVar
[localVar] :: LocalVar -> Name
[localShadowedBy] :: LocalVar -> [AbstractName]

-- | We show shadowed variables as prefixed by a ".", as not in scope.

-- | Shadow a local name by a non-empty list of imports.
shadowLocal :: [AbstractName] -> LocalVar -> LocalVar

-- | Project name of unshadowed local variable.
notShadowedLocal :: LocalVar -> Maybe Name

-- | Get all locals that are not shadowed <b>by imports</b>.
notShadowedLocals :: LocalVars -> AssocList Name Name

-- | Lens for <a>scopeLocals</a>.
updateScopeLocals :: (LocalVars -> LocalVars) -> ScopeInfo -> ScopeInfo
setScopeLocals :: LocalVars -> ScopeInfo -> ScopeInfo
mapScopeInfo :: (Scope -> Scope) -> ScopeInfo -> ScopeInfo

-- | A <tt>NameSpace</tt> contains the mappings from concrete names that
--   the user can write to the abstract fully qualified names that the type
--   checker wants to read.
data NameSpace
NameSpace :: NamesInScope -> ModulesInScope -> InScopeSet -> NameSpace

-- | Maps concrete names to a list of abstract names.
[nsNames] :: NameSpace -> NamesInScope

-- | Maps concrete module names to a list of abstract module names.
[nsModules] :: NameSpace -> ModulesInScope
[nsInScope] :: NameSpace -> InScopeSet
type ThingsInScope a = Map Name [a]
type NamesInScope = ThingsInScope AbstractName
type ModulesInScope = ThingsInScope AbstractModule
type InScopeSet = Set QName

-- | Set of types consisting of exactly <a>AbstractName</a> and
--   <a>AbstractModule</a>.
--   
--   A GADT just for some dependent-types trickery.
data InScopeTag a
[NameTag] :: InScopeTag AbstractName
[ModuleTag] :: InScopeTag AbstractModule

-- | Type class for some dependent-types trickery.
class Eq a => InScope a
inScopeTag :: InScope a => InScopeTag a

-- | <tt>inNameSpace</tt> selects either the name map or the module name
--   map from a <a>NameSpace</a>. What is selected is determined by result
--   type (using the dependent-type trickery).
inNameSpace :: forall a. InScope a => NameSpace -> ThingsInScope a

-- | For the sake of parsing left-hand sides, we distinguish constructor
--   and record field names from defined names.
data KindOfName

-- | Constructor name.
ConName :: KindOfName

-- | Record field name.
FldName :: KindOfName

-- | Ordinary defined name.
DefName :: KindOfName

-- | Name of a pattern synonym.
PatternSynName :: KindOfName

-- | Name of a macro
MacroName :: KindOfName

-- | A name that can only be quoted.
QuotableName :: KindOfName

-- | A list containing all name kinds.
allKindsOfNames :: [KindOfName]

-- | Where does a name come from?
--   
--   This information is solely for reporting to the user, see
--   <a>whyInScope</a>.
data WhyInScope

-- | Defined in this module.
Defined :: WhyInScope

-- | Imported from another module.
Opened :: QName -> WhyInScope -> WhyInScope

-- | Imported by a module application.
Applied :: QName -> WhyInScope -> WhyInScope

-- | A decoration of <a>QName</a>.
data AbstractName
AbsName :: QName -> KindOfName -> WhyInScope -> AbstractName

-- | The resolved qualified name.
[anameName] :: AbstractName -> QName

-- | The kind (definition, constructor, record field etc.).
[anameKind] :: AbstractName -> KindOfName

-- | Explanation where this name came from.
[anameLineage] :: AbstractName -> WhyInScope

-- | A decoration of abstract syntax module names.
data AbstractModule
AbsModule :: ModuleName -> WhyInScope -> AbstractModule

-- | The resolved module name.
[amodName] :: AbstractModule -> ModuleName

-- | Explanation where this name came from.
[amodLineage] :: AbstractModule -> WhyInScope

-- | Van Laarhoven lens on <a>anameName</a>.
lensAnameName :: Functor m => (QName -> m QName) -> AbstractName -> m AbstractName

-- | Van Laarhoven lens on <a>amodName</a>.
lensAmodName :: Functor m => (ModuleName -> m ModuleName) -> AbstractModule -> m AbstractModule
mergeNames :: Eq a => ThingsInScope a -> ThingsInScope a -> ThingsInScope a

-- | The empty name space.
emptyNameSpace :: NameSpace

-- | Map functions over the names and modules in a name space.
mapNameSpace :: (NamesInScope -> NamesInScope) -> (ModulesInScope -> ModulesInScope) -> (InScopeSet -> InScopeSet) -> NameSpace -> NameSpace

-- | Zip together two name spaces.
zipNameSpace :: (NamesInScope -> NamesInScope -> NamesInScope) -> (ModulesInScope -> ModulesInScope -> ModulesInScope) -> (InScopeSet -> InScopeSet -> InScopeSet) -> NameSpace -> NameSpace -> NameSpace

-- | Map monadic function over a namespace.
mapNameSpaceM :: Applicative m => (NamesInScope -> m NamesInScope) -> (ModulesInScope -> m ModulesInScope) -> (InScopeSet -> m InScopeSet) -> NameSpace -> m NameSpace

-- | The empty scope.
emptyScope :: Scope

-- | The empty scope info.
emptyScopeInfo :: ScopeInfo

-- | Map functions over the names and modules in a scope.
mapScope :: (NameSpaceId -> NamesInScope -> NamesInScope) -> (NameSpaceId -> ModulesInScope -> ModulesInScope) -> (NameSpaceId -> InScopeSet -> InScopeSet) -> Scope -> Scope

-- | Same as <a>mapScope</a> but applies the same function to all name
--   spaces.
mapScope_ :: (NamesInScope -> NamesInScope) -> (ModulesInScope -> ModulesInScope) -> (InScopeSet -> InScopeSet) -> Scope -> Scope

-- | Same as <a>mapScope</a> but applies the function only on the given
--   name space.
mapScope' :: NameSpaceId -> (NamesInScope -> NamesInScope) -> (ModulesInScope -> ModulesInScope) -> (InScopeSet -> InScopeSet) -> Scope -> Scope

-- | Map monadic functions over the names and modules in a scope.
mapScopeM :: Applicative m => (NameSpaceId -> NamesInScope -> m NamesInScope) -> (NameSpaceId -> ModulesInScope -> m ModulesInScope) -> (NameSpaceId -> InScopeSet -> m InScopeSet) -> Scope -> m Scope

-- | Same as <a>mapScopeM</a> but applies the same function to both the
--   public and private name spaces.
mapScopeM_ :: Applicative m => (NamesInScope -> m NamesInScope) -> (ModulesInScope -> m ModulesInScope) -> (InScopeSet -> m InScopeSet) -> Scope -> m Scope

-- | Zip together two scopes. The resulting scope has the same name as the
--   first scope.
zipScope :: (NameSpaceId -> NamesInScope -> NamesInScope -> NamesInScope) -> (NameSpaceId -> ModulesInScope -> ModulesInScope -> ModulesInScope) -> (NameSpaceId -> InScopeSet -> InScopeSet -> InScopeSet) -> Scope -> Scope -> Scope

-- | Same as <a>zipScope</a> but applies the same function to both the
--   public and private name spaces.
zipScope_ :: (NamesInScope -> NamesInScope -> NamesInScope) -> (ModulesInScope -> ModulesInScope -> ModulesInScope) -> (InScopeSet -> InScopeSet -> InScopeSet) -> Scope -> Scope -> Scope

-- | Recompute the inScope sets of a scope.
recomputeInScopeSets :: Scope -> Scope

-- | Filter a scope keeping only concrete names matching the predicates.
--   The first predicate is applied to the names and the second to the
--   modules.
filterScope :: (Name -> Bool) -> (Name -> Bool) -> Scope -> Scope

-- | Return all names in a scope.
allNamesInScope :: InScope a => Scope -> ThingsInScope a
allNamesInScope' :: InScope a => Scope -> ThingsInScope (a, Access)

-- | Returns the scope's non-private names.
exportedNamesInScope :: InScope a => Scope -> ThingsInScope a
namesInScope :: InScope a => [NameSpaceId] -> Scope -> ThingsInScope a
allThingsInScope :: Scope -> NameSpace
thingsInScope :: [NameSpaceId] -> Scope -> NameSpace

-- | Merge two scopes. The result has the name of the first scope.
mergeScope :: Scope -> Scope -> Scope

-- | Merge a non-empty list of scopes. The result has the name of the first
--   scope in the list.
mergeScopes :: [Scope] -> Scope

-- | Move all names in a scope to the given name space (except never move
--   from Imported to Public).
setScopeAccess :: NameSpaceId -> Scope -> Scope

-- | Update a particular name space.
setNameSpace :: NameSpaceId -> NameSpace -> Scope -> Scope

-- | Modify a particular name space.
modifyNameSpace :: NameSpaceId -> (NameSpace -> NameSpace) -> Scope -> Scope

-- | Add names to a scope.
addNamesToScope :: NameSpaceId -> Name -> [AbstractName] -> Scope -> Scope

-- | Add a name to a scope.
addNameToScope :: NameSpaceId -> Name -> AbstractName -> Scope -> Scope

-- | Remove a name from a scope. Caution: does not update the nsInScope
--   set. This is only used by rebindName and in that case we add the name
--   right back (but with a different kind).
removeNameFromScope :: NameSpaceId -> Name -> Scope -> Scope

-- | Add a module to a scope.
addModuleToScope :: NameSpaceId -> Name -> AbstractModule -> Scope -> Scope
type UsingOrHiding = Either Using [ImportedName]
usingOrHiding :: ImportDirective -> UsingOrHiding

-- | Apply an <a>ImportDirective</a> to a scope.
applyImportDirective :: ImportDirective -> Scope -> Scope

-- | Rename the abstract names in a scope.
renameCanonicalNames :: Map QName QName -> Map ModuleName ModuleName -> Scope -> Scope

-- | Remove private name space of a scope.
--   
--   Should be a right identity for <a>exportedNamesInScope</a>.
--   <tt>exportedNamesInScope . restrictPrivate ==
--   exportedNamesInScope</tt>.
restrictPrivate :: Scope -> Scope

-- | Remove private things from the given module from a scope.
restrictLocalPrivate :: ModuleName -> Scope -> Scope

-- | Remove names that can only be used qualified (when opening a scope)
removeOnlyQualified :: Scope -> Scope

-- | Add an explanation to why things are in scope.
inScopeBecause :: (WhyInScope -> WhyInScope) -> Scope -> Scope

-- | Get the public parts of the public modules of a scope
publicModules :: ScopeInfo -> Map ModuleName Scope
publicNames :: ScopeInfo -> Set AbstractName
everythingInScope :: ScopeInfo -> NameSpace

-- | Compute a flattened scope. Only include unqualified names or names
--   qualified by modules in the first argument.
flattenScope :: [[Name]] -> ScopeInfo -> Map QName [AbstractName]

-- | Get all concrete names in scope. Includes bound variables.
concreteNamesInScope :: ScopeInfo -> Set QName

-- | Look up a name in the scope
scopeLookup :: InScope a => QName -> ScopeInfo -> [a]
scopeLookup' :: forall a. InScope a => QName -> ScopeInfo -> [(a, Access)]
data AllowAmbiguousNames

-- | Used for instance arguments to check whether a name is in scope, but
--   we do not care whether is is ambiguous
AmbiguousAnything :: AllowAmbiguousNames

-- | Ambiguous constructors or projections.
AmbiguousConProjs :: AllowAmbiguousNames
AmbiguousNothing :: AllowAmbiguousNames
isNameInScope :: QName -> ScopeInfo -> Bool

-- | Find the concrete names that map (uniquely) to a given abstract name.
--   Sort by length, shortest first.
inverseScopeLookup :: Either ModuleName QName -> ScopeInfo -> [QName]
inverseScopeLookup' :: AllowAmbiguousNames -> Either ModuleName QName -> ScopeInfo -> [QName]
recomputeInverseScopeMaps :: ScopeInfo -> ScopeInfo

-- | Find the concrete names that map (uniquely) to a given abstract
--   qualified name. Sort by length, shortest first.
inverseScopeLookupName :: QName -> ScopeInfo -> [QName]
inverseScopeLookupName' :: AllowAmbiguousNames -> QName -> ScopeInfo -> [QName]

-- | Find the concrete names that map (uniquely) to a given abstract module
--   name. Sort by length, shortest first.
inverseScopeLookupModule :: ModuleName -> ScopeInfo -> [QName]

-- | Add first string only if list is non-empty.
blockOfLines :: String -> [String] -> [String]
instance GHC.Classes.Eq Agda.Syntax.Scope.Base.AllowAmbiguousNames
instance GHC.Classes.Eq Agda.Syntax.Scope.Base.Scope
instance GHC.Classes.Eq Agda.Syntax.Scope.Base.NameSpace
instance GHC.Enum.Bounded Agda.Syntax.Scope.Base.KindOfName
instance GHC.Enum.Enum Agda.Syntax.Scope.Base.KindOfName
instance GHC.Show.Show Agda.Syntax.Scope.Base.KindOfName
instance GHC.Classes.Eq Agda.Syntax.Scope.Base.KindOfName
instance GHC.Enum.Enum Agda.Syntax.Scope.Base.NameSpaceId
instance GHC.Enum.Bounded Agda.Syntax.Scope.Base.NameSpaceId
instance GHC.Classes.Eq Agda.Syntax.Scope.Base.NameSpaceId
instance GHC.Classes.Eq Agda.Syntax.Scope.Base.ScopeInfo
instance GHC.Classes.Eq Agda.Syntax.Scope.Base.LocalVar
instance GHC.Classes.Ord Agda.Syntax.Scope.Base.LocalVar
instance GHC.Show.Show Agda.Syntax.Scope.Base.LocalVar
instance Agda.Syntax.Scope.Base.InScope Agda.Syntax.Scope.Base.AbstractName
instance Agda.Syntax.Scope.Base.InScope Agda.Syntax.Scope.Base.AbstractModule
instance GHC.Classes.Eq Agda.Syntax.Scope.Base.AbstractName
instance GHC.Classes.Ord Agda.Syntax.Scope.Base.AbstractName
instance GHC.Classes.Eq Agda.Syntax.Scope.Base.AbstractModule
instance GHC.Classes.Ord Agda.Syntax.Scope.Base.AbstractModule
instance GHC.Show.Show Agda.Syntax.Scope.Base.AbstractName
instance GHC.Show.Show Agda.Syntax.Scope.Base.AbstractModule
instance GHC.Show.Show Agda.Syntax.Scope.Base.NameSpaceId
instance GHC.Show.Show Agda.Syntax.Scope.Base.NameSpace
instance GHC.Show.Show Agda.Syntax.Scope.Base.Scope
instance GHC.Show.Show Agda.Syntax.Scope.Base.ScopeInfo
instance Agda.Syntax.Position.KillRange Agda.Syntax.Scope.Base.ScopeInfo
instance Agda.Syntax.Position.HasRange Agda.Syntax.Scope.Base.AbstractName
instance Agda.Syntax.Position.SetRange Agda.Syntax.Scope.Base.AbstractName


-- | An info object contains additional information about a piece of
--   abstract syntax that isn't part of the actual syntax. For instance, it
--   might contain the source code position of an expression or the
--   concrete syntax that an internal expression originates from.
module Agda.Syntax.Info
data MetaInfo
MetaInfo :: Range -> ScopeInfo -> Maybe MetaId -> String -> MetaInfo
[metaRange] :: MetaInfo -> Range
[metaScope] :: MetaInfo -> ScopeInfo
[metaNumber] :: MetaInfo -> Maybe MetaId
[metaNameSuggestion] :: MetaInfo -> String
emptyMetaInfo :: MetaInfo
newtype ExprInfo
ExprRange :: Range -> ExprInfo
exprNoRange :: ExprInfo
data ModuleInfo
ModuleInfo :: Range -> Range -> Maybe Name -> Maybe OpenShortHand -> Maybe ImportDirective -> ModuleInfo
[minfoRange] :: ModuleInfo -> Range

-- | The range of the "as" and "to" keywords, if any. Retained for
--   highlighting purposes.
[minfoAsTo] :: ModuleInfo -> Range

-- | The "as" module name, if any. Retained for highlighting purposes.
[minfoAsName] :: ModuleInfo -> Maybe Name
[minfoOpenShort] :: ModuleInfo -> Maybe OpenShortHand

-- | Retained for <tt>abstractToConcrete</tt> of <a>ModuleMacro</a>.
[minfoDirective] :: ModuleInfo -> Maybe ImportDirective
newtype LetInfo
LetRange :: Range -> LetInfo
data DefInfo
DefInfo :: Fixity' -> Access -> IsAbstract -> IsInstance -> IsMacro -> DeclInfo -> DefInfo
[defFixity] :: DefInfo -> Fixity'
[defAccess] :: DefInfo -> Access
[defAbstract] :: DefInfo -> IsAbstract
[defInstance] :: DefInfo -> IsInstance
[defMacro] :: DefInfo -> IsMacro
[defInfo] :: DefInfo -> DeclInfo
mkDefInfo :: Name -> Fixity' -> Access -> IsAbstract -> Range -> DefInfo

-- | Same as <tt>mkDefInfo</tt> but where we can also give the
--   <tt>IsInstance</tt>
mkDefInfoInstance :: Name -> Fixity' -> Access -> IsAbstract -> IsInstance -> IsMacro -> Range -> DefInfo
data DeclInfo
DeclInfo :: Name -> Range -> DeclInfo
[declName] :: DeclInfo -> Name
[declRange] :: DeclInfo -> Range
data MutualInfo
MutualInfo :: TerminationCheck Name -> PositivityCheck -> Range -> MutualInfo
[mutualTermCheck] :: MutualInfo -> TerminationCheck Name
[mutualPositivityCheck] :: MutualInfo -> PositivityCheck
[mutualRange] :: MutualInfo -> Range

-- | Default value for <a>MutualInfo</a>.
newtype LHSInfo
LHSRange :: Range -> LHSInfo

-- | For a general pattern we remember the source code position.
newtype PatInfo
PatRange :: Range -> PatInfo

-- | Empty range for patterns.
patNoRange :: PatInfo

-- | Constructor pattern info.
data ConPatInfo
ConPatInfo :: ConOrigin -> PatInfo -> ConPatInfo

-- | Does this pattern come form the eta-expansion of an implicit pattern?
[patOrigin] :: ConPatInfo -> ConOrigin
[patInfo] :: ConPatInfo -> PatInfo
instance GHC.Classes.Eq Agda.Syntax.Info.ConPatInfo
instance Agda.Syntax.Position.KillRange Agda.Syntax.Info.PatInfo
instance Agda.Syntax.Position.HasRange Agda.Syntax.Info.PatInfo
instance GHC.Show.Show Agda.Syntax.Info.PatInfo
instance Agda.Utils.Null.Null Agda.Syntax.Info.PatInfo
instance GHC.Classes.Eq Agda.Syntax.Info.PatInfo
instance Agda.Utils.Null.Null Agda.Syntax.Info.LHSInfo
instance GHC.Classes.Eq Agda.Syntax.Info.LHSInfo
instance GHC.Show.Show Agda.Syntax.Info.LHSInfo
instance GHC.Classes.Eq Agda.Syntax.Info.MutualInfo
instance GHC.Show.Show Agda.Syntax.Info.MutualInfo
instance GHC.Classes.Eq Agda.Syntax.Info.DefInfo
instance GHC.Show.Show Agda.Syntax.Info.DefInfo
instance GHC.Classes.Eq Agda.Syntax.Info.DeclInfo
instance GHC.Show.Show Agda.Syntax.Info.DeclInfo
instance Agda.Utils.Null.Null Agda.Syntax.Info.LetInfo
instance GHC.Classes.Eq Agda.Syntax.Info.LetInfo
instance GHC.Show.Show Agda.Syntax.Info.LetInfo
instance GHC.Classes.Eq Agda.Syntax.Info.ModuleInfo
instance Agda.Utils.Null.Null Agda.Syntax.Info.ExprInfo
instance GHC.Classes.Eq Agda.Syntax.Info.ExprInfo
instance GHC.Show.Show Agda.Syntax.Info.ExprInfo
instance GHC.Classes.Eq Agda.Syntax.Info.MetaInfo
instance GHC.Show.Show Agda.Syntax.Info.MetaInfo
instance (GHC.Show.Show Agda.Syntax.Concrete.OpenShortHand, GHC.Show.Show Agda.Syntax.Concrete.ImportDirective) => GHC.Show.Show Agda.Syntax.Info.ModuleInfo
instance Agda.Syntax.Position.HasRange Agda.Syntax.Info.MetaInfo
instance Agda.Syntax.Position.KillRange Agda.Syntax.Info.MetaInfo
instance Agda.Syntax.Position.HasRange Agda.Syntax.Info.ExprInfo
instance Agda.Syntax.Position.KillRange Agda.Syntax.Info.ExprInfo
instance Agda.Syntax.Position.HasRange Agda.Syntax.Info.ModuleInfo
instance Agda.Syntax.Position.SetRange Agda.Syntax.Info.ModuleInfo
instance Agda.Syntax.Position.KillRange Agda.Syntax.Info.ModuleInfo
instance Agda.Syntax.Position.HasRange Agda.Syntax.Info.LetInfo
instance Agda.Syntax.Position.KillRange Agda.Syntax.Info.LetInfo
instance Agda.Syntax.Position.HasRange Agda.Syntax.Info.DefInfo
instance Agda.Syntax.Position.SetRange Agda.Syntax.Info.DefInfo
instance Agda.Syntax.Position.KillRange Agda.Syntax.Info.DefInfo
instance Agda.Syntax.Position.HasRange Agda.Syntax.Info.DeclInfo
instance Agda.Syntax.Position.SetRange Agda.Syntax.Info.DeclInfo
instance Agda.Syntax.Position.KillRange Agda.Syntax.Info.DeclInfo
instance Agda.Utils.Null.Null Agda.Syntax.Info.MutualInfo
instance Agda.Syntax.Position.HasRange Agda.Syntax.Info.MutualInfo
instance Agda.Syntax.Position.KillRange Agda.Syntax.Info.MutualInfo
instance Agda.Syntax.Position.HasRange Agda.Syntax.Info.LHSInfo
instance Agda.Syntax.Position.KillRange Agda.Syntax.Info.LHSInfo
instance GHC.Show.Show Agda.Syntax.Info.ConPatInfo
instance Agda.Syntax.Position.HasRange Agda.Syntax.Info.ConPatInfo
instance Agda.Syntax.Position.KillRange Agda.Syntax.Info.ConPatInfo
instance Agda.Syntax.Position.SetRange Agda.Syntax.Info.ConPatInfo


-- | Utilities related to Geniplate.
module Agda.Utils.Geniplate

-- | A localised instance of <a>instanceUniverseBiT</a>. The generated
--   <a>universeBi</a> functions neither descend into the types in
--   <a>dontDescendInto</a>, nor into the types in the list argument.
instanceUniverseBiT' :: [TypeQ] -> TypeQ -> Q [Dec]

-- | A localised instance of <a>instanceTransformBiMT</a>. The generated
--   <a>transformBiM</a> functions neither descend into the types in
--   <a>dontDescendInto</a>, nor into the types in the list argument.
instanceTransformBiMT' :: [TypeQ] -> TypeQ -> TypeQ -> Q [Dec]

-- | Types which Geniplate should not descend into.
dontDescendInto :: [TypeQ]

module Agda.Syntax.Internal

-- | Type of argument lists.
type Args = [Arg Term]
type NamedArgs = [NamedArg Term]

-- | Store the names of the record fields in the constructor. This allows
--   reduction of projection redexes outside of TCM. For instance, during
--   substitution and application.
data ConHead
ConHead :: QName -> Induction -> [QName] -> ConHead

-- | The name of the constructor.
[conName] :: ConHead -> QName

-- | Record constructors can be coinductive.
[conInductive] :: ConHead -> Induction

-- | The name of the record fields. Empty list for data constructors.
--   <a>Arg</a> is not needed here since it is stored in the constructor
--   args.
[conFields] :: ConHead -> [QName]
class LensConName a where setConName = mapConName . const mapConName f a = setConName (f (getConName a)) a
getConName :: LensConName a => a -> QName
setConName :: LensConName a => QName -> a -> a
mapConName :: LensConName a => (QName -> QName) -> a -> a

-- | Raw values.
--   
--   <tt>Def</tt> is used for both defined and undefined constants. Assume
--   there is a type declaration and a definition for every constant, even
--   if the definition is an empty list of clauses.
data Term

-- | <tt>x es</tt> neutral
Var :: {-# UNPACK #-} !Int -> Elims -> Term

-- | Terms are beta normal. Relevance is ignored
Lam :: ArgInfo -> (Abs Term) -> Term
Lit :: Literal -> Term

-- | <tt>f es</tt>, possibly a delta/iota-redex
Def :: QName -> Elims -> Term

-- | <tt>c vs</tt> or <tt>record { fs = vs }</tt>
Con :: ConHead -> ConInfo -> 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
--   <tt>.irrAx : .A -&gt; A</tt>.
DontCare :: Term -> Term

-- | Explicit sharing
Shared :: !(Ptr Term) -> Term
type ConInfo = ConOrigin

-- | Eliminations, subsuming applications and projections.
data Elim' a

-- | Application.
Apply :: (Arg a) -> Elim' a

-- | Projection. <a>QName</a> is name of a record projection.
Proj :: ProjOrigin -> 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. <a>Abs</a>: The bound variable might appear in the body.
--   <a>NoAbs</a> is pseudo-binder, it does not introduce a fresh variable,
--   similar to the <tt>const</tt> of Haskell.
data Abs a

-- | The body has (at least) one free variable. Danger: <a>unAbs</a>
--   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

-- | <a>Abs</a> is never <a>NoAbs</a>.
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

-- | <tt>Set ℓ</tt>.
Type :: Level -> Sort

-- | Dummy sort.
Prop :: Sort

-- | <tt>Setω</tt>.
Inf :: Sort

-- | <tt>SizeUniv</tt>, a sort inhabited by type <tt>Size</tt>.
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 <a>PlusLevel</a> 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

-- | <tt>n</tt>, to represent <tt>Setₙ</tt>.
ClosedLevel :: Integer -> PlusLevel

-- | <tt>n + ℓ</tt>.
Plus :: Integer -> LevelAtom -> PlusLevel

-- | An atomic term of type <tt>Level</tt>.
data LevelAtom

-- | A meta variable targeting <tt>Level</tt> under some eliminations.
MetaLevel :: MetaId -> Elims -> LevelAtom

-- | A term of type <tt>Level</tt> whose reduction is blocked by a meta.
BlockedLevel :: MetaId -> Term -> LevelAtom

-- | A neutral term of type <tt>Level</tt>.
NeutralLevel :: NotBlocked -> Term -> LevelAtom

-- | Introduced by <tt>instantiate</tt>, removed by <tt>reduce</tt>.
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 <a>Elim</a> 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 <a>Def</a>.
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
--   <a>Agda.TypeChecking.Patterns.Match</a>.
MissingClauses :: NotBlocked

-- | Reduction was not blocked, we reached a whnf which can be anything but
--   a stuck <tt><a>Def</a></tt>.
ReallyNotBlocked :: NotBlocked

-- | <a>ReallyNotBlocked</a> is the unit. <a>MissingClauses</a> is
--   dominant. <tt><a>StuckOn</a>{}</tt> 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.

-- | <tt><a>Blocked</a> t</tt> without the <tt>t</tt>.
type Blocked_ = Blocked ()

-- | When trying to reduce <tt>f es</tt>, on match failed on one
--   elimination <tt>e ∈ es</tt> that came with info <tt>r ::
--   NotBlocked</tt>. <tt>stuckOn e r</tt> produces the new
--   <tt>NotBlocked</tt> info.
--   
--   <a>MissingClauses</a> must be propagated, as this is blockage that can
--   be lifted in the future (as more clauses are added).
--   
--   <tt><a>StuckOn</a> e0</tt> is also propagated, since it provides more
--   precise information as <tt>StuckOn e</tt> (as <tt>e0</tt> is the
--   original reason why reduction got stuck and usually a subterm of
--   <tt>e</tt>). An information like <tt>StuckOn (Apply (Arg info (Var i
--   [])))</tt> (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 <tt>r</tt>, we are terminally stuck due to
--   <tt>StuckOn e</tt>. Propagating <tt><a>AbsurdMatch</a></tt> does not
--   seem useful.
--   
--   <a>Underapplied</a> must not be propagated, as this would mean that
--   <tt>f es</tt> is underapplied, which is not the case (it is stuck).
--   Note that <a>Underapplied</a> can only arise when projection patterns
--   were missing to complete the original match (in <tt>e</tt>). (Missing
--   ordinary pattern would mean the <tt>e</tt> 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.
--   
--   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 telescope.
--   
--   <pre>
--   clauseTel ~ permute clausePerm (patternVars namedClausePats)
--   </pre>
--   
--   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] -> Maybe Term -> Maybe (Arg Type) -> Bool -> Clause
[clauseRange] :: Clause -> Range

-- | <tt>Δ</tt>: The types of the pattern variables in dependency order.
[clauseTel] :: Clause -> Telescope

-- | <tt>Δ ⊢ ps</tt>. The de Bruijn indices refer to <tt>Δ</tt>.
[namedClausePats] :: Clause -> [NamedArg DeBruijnPattern]

-- | <tt>Just v</tt> with <tt>Δ ⊢ v</tt> for a regular clause, or
--   <tt>Nothing</tt> for an absurd one.
[clauseBody] :: Clause -> Maybe Term

-- | <tt>Δ ⊢ t</tt>. The type of the rhs under <tt>clauseTel</tt>. Used,
--   e.g., by <tt>TermCheck</tt>. Can be <a>Irrelevant</a> if we
--   encountered an irrelevant projection pattern on the lhs.
[clauseType] :: Clause -> Maybe (Arg Type)

-- | Clause has been labelled as CATCHALL.
[clauseCatchall] :: Clause -> Bool
clausePats :: Clause -> [Arg DeBruijnPattern]

-- | Pattern variables.
type PatVarName = ArgName
patVarNameToString :: PatVarName -> String
nameToPatVarName :: Name -> PatVarName

-- | Patterns are variables, constructors, or wildcards. <tt>QName</tt> is
--   used in <tt>ConP</tt> rather than <tt>Name</tt> 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
--   <tt>QName</tt>.
data Pattern' x

-- | <pre>
--   x
--   </pre>
VarP :: x -> Pattern' x

-- | <pre>
--   .t
--   </pre>
DotP :: Term -> Pattern' x

-- | <tt>c ps</tt> The subpatterns do not contain any projection
--   copatterns.
ConP :: ConHead -> ConPatternInfo -> [NamedArg (Pattern' x)] -> Pattern' x

-- | E.g. <tt>5</tt>, <tt>"hello"</tt>.
LitP :: Literal -> Pattern' x

-- | Projection copattern. Can only appear by itself.
ProjP :: ProjOrigin -> QName -> Pattern' x
type Pattern = Pattern' PatVarName  The @PatVarName@ is a name suggestion.
varP :: ArgName -> Pattern

-- | Type used when numbering pattern variables.
data DBPatVar
DBPatVar :: PatVarName -> Int -> DBPatVar
[dbPatVarName] :: DBPatVar -> PatVarName
[dbPatVarIndex] :: DBPatVar -> Int
type DeBruijnPattern = Pattern' DBPatVar
namedVarP :: PatVarName -> Named_ Pattern
namedDBVarP :: Int -> PatVarName -> Named_ DeBruijnPattern

-- | The <tt>ConPatternInfo</tt> states whether the constructor belongs to
--   a record type (<tt>Just</tt>) or data type (<tt>Nothing</tt>). In the
--   former case, the <tt>Bool</tt> says whether the record pattern
--   orginates from the expansion of an implicit pattern. The <tt>Type</tt>
--   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
--   (<a>clauseTel</a>).
data ConPatternInfo
ConPatternInfo :: Maybe ConOrigin -> Maybe (Arg Type) -> ConPatternInfo

-- | <tt>Nothing</tt> if data constructor. <tt>Just</tt> if record
--   constructor.
[conPRecord] :: ConPatternInfo -> Maybe ConOrigin

-- | The type of the whole constructor pattern. Should be present
--   (<tt>Just</tt>) if constructor pattern is is generated ordinarily by
--   type-checking. Could be absent (<tt>Nothing</tt>) if pattern comes
--   from some plugin (like Agsy). Needed e.g. for with-clause stripping.
[conPType] :: ConPatternInfo -> Maybe (Arg Type)
noConPatternInfo :: ConPatternInfo

-- | Build partial <a>ConPatternInfo</a> from <a>ConInfo</a>
toConPatternInfo :: ConInfo -> ConPatternInfo

-- | Build <a>ConInfo</a> from <a>ConPatternInfo</a>.
fromConPatternInfo :: ConPatternInfo -> ConInfo

-- | Extract pattern variables in left-to-right order. A <a>DotP</a> is
--   also treated as variable (see docu for <a>Clause</a>).
patternVars :: Arg (Pattern' a) -> [Arg (Either a Term)]

-- | Does the pattern perform a match that could fail?
properlyMatching :: DeBruijnPattern -> Bool

-- | Substitutions.
data Substitution' a

-- | Identity substitution. <tt>Γ ⊢ IdS : Γ</tt>
IdS :: Substitution' a

-- | Empty substitution, lifts from the empty context. Apply this to closed
--   terms you want to use in a non-empty context. <tt>Γ ⊢ EmptyS : ()</tt>
EmptyS :: Substitution' a

-- | Substitution extension, `<tt>cons'</tt>. <tt> Γ ⊢ u : Aρ Γ ⊢ ρ : Δ
--   ---------------------- Γ ⊢ u :# ρ : Δ, A </tt>
(:#) :: a -> Substitution' a -> Substitution' a

-- | Strengthening substitution. First argument is
--   <tt><b>IMPOSSIBLE</b></tt>. Apply this to a term which does not
--   contain variable 0 to lower all de Bruijn indices by one. <tt> Γ ⊢ ρ :
--   Δ --------------------------- Γ ⊢ Strengthen ρ : Δ, A </tt>
Strengthen :: Empty -> (Substitution' a) -> Substitution' a

-- | Weakning substitution, lifts to an extended context. <tt> Γ ⊢ ρ : Δ
--   ------------------- Γ, Ψ ⊢ Wk |Ψ| ρ : Δ </tt>
Wk :: !Int -> (Substitution' a) -> Substitution' a

-- | Lifting substitution. Use this to go under a binder. <tt>Lift 1 ρ ==
--   var 0 :# Wk 1 ρ</tt>. <tt> Γ ⊢ ρ : Δ ------------------------- Γ, Ψρ ⊢
--   Lift |Ψ| ρ : Δ, Ψ </tt>
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 <tt>Shared</tt> 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 <a>DontCare</a> is it is not already a <tt>DontCare</tt>.
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 <a>DontCare</a> 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

-- | Convert <a>Proj</a> projection eliminations according to their
--   <a>ProjOrigin</a> into <a>Def</a> projection applications.
unSpine' :: (ProjOrigin -> Bool) -> Term -> Term

-- | A view distinguishing the neutrals <tt>Var</tt>, <tt>Def</tt>, and
--   <tt>MetaV</tt> which can be projected.
hasElims :: Term -> Maybe (Elims -> Term, Elims)

-- | Drop <a>Apply</a> constructor. (Unsafe!)
argFromElim :: Elim' a -> Arg a

-- | Drop <a>Apply</a> constructor. (Safe)
isApplyElim :: Elim' a -> Maybe (Arg a)

-- | Drop <a>Apply</a> constructors. (Safe)
allApplyElims :: [Elim' a] -> Maybe [Arg a]

-- | Split at first non-<a>Apply</a>
splitApplyElims :: [Elim' a] -> ([Arg a], [Elim' a])
class IsProjElim e
isProjElim :: IsProjElim e => e -> Maybe (ProjOrigin, QName)

-- | Discard <tt>Proj f</tt> entries.
dropProjElims :: IsProjElim e => [e] -> [e]

-- | Discards <tt>Proj f</tt> entries.
argsFromElims :: Elims -> Args

-- | Drop <a>Proj</a> constructors. (Safe)
allProjElims :: Elims -> Maybe [(ProjOrigin, QName)]

-- | A <a>null</a> 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:
--   
--   <ul>
--   <li>sort and color annotations,</li>
--   <li>projections.</li>
--   </ul>
class TermSize a where termSize = getSum . tsize
termSize :: TermSize a => a -> Int
tsize :: TermSize a => a -> Sum Int
pDom :: LensHiding a => a -> Doc -> Doc

-- | A meta variable identifier is just a natural number.
newtype MetaId
MetaId :: Nat -> MetaId
[metaId] :: MetaId -> Nat
instance Data.Generics.Geniplate.UniverseBi [Agda.Syntax.Internal.Term] Agda.Syntax.Internal.Term
instance Agda.Utils.Pretty.Pretty a => Agda.Utils.Pretty.Pretty (Agda.Syntax.Internal.Substitution' a)
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Internal.Term
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Internal.Clause
instance Agda.Utils.Pretty.Pretty a => Agda.Utils.Pretty.Pretty (Agda.Syntax.Internal.Tele (Agda.Syntax.Common.Dom a))
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Internal.Level
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Internal.PlusLevel
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Internal.LevelAtom
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Internal.Sort
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Internal.Type
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Internal.Elim
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Internal.DBPatVar
instance Agda.Utils.Pretty.Pretty a => Agda.Utils.Pretty.Pretty (Agda.Syntax.Internal.Pattern' a)
instance Control.DeepSeq.NFData Agda.Syntax.Internal.Term
instance Control.DeepSeq.NFData Agda.Syntax.Internal.Type
instance Control.DeepSeq.NFData Agda.Syntax.Internal.Sort
instance Control.DeepSeq.NFData Agda.Syntax.Internal.Level
instance Control.DeepSeq.NFData Agda.Syntax.Internal.PlusLevel
instance Control.DeepSeq.NFData Agda.Syntax.Internal.LevelAtom
instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Agda.Syntax.Internal.Elim' a)
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Internal.Elims Agda.Syntax.Internal.Term
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Internal.Args Agda.Syntax.Internal.Term
instance Data.Generics.Geniplate.UniverseBi ([Agda.Syntax.Internal.Type], [Agda.Syntax.Internal.Clause]) Agda.Syntax.Internal.Term
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Internal.Elims Agda.Syntax.Internal.Pattern
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Internal.Args Agda.Syntax.Internal.Pattern
instance Data.Generics.Geniplate.UniverseBi ([Agda.Syntax.Internal.Type], [Agda.Syntax.Internal.Clause]) Agda.Syntax.Internal.Pattern
instance Data.Traversable.Traversable Agda.Syntax.Internal.Substitution'
instance Data.Foldable.Foldable Agda.Syntax.Internal.Substitution'
instance GHC.Base.Functor Agda.Syntax.Internal.Substitution'
instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Internal.Substitution' a)
instance GHC.Show.Show Agda.Syntax.Internal.Clause
instance Data.Traversable.Traversable Agda.Syntax.Internal.Pattern'
instance Data.Foldable.Foldable Agda.Syntax.Internal.Pattern'
instance GHC.Base.Functor Agda.Syntax.Internal.Pattern'
instance GHC.Show.Show x => GHC.Show.Show (Agda.Syntax.Internal.Pattern' x)
instance GHC.Show.Show Agda.Syntax.Internal.ConPatternInfo
instance GHC.Show.Show Agda.Syntax.Internal.DBPatVar
instance Data.Traversable.Traversable Agda.Syntax.Internal.Blocked
instance Data.Foldable.Foldable Agda.Syntax.Internal.Blocked
instance GHC.Base.Functor Agda.Syntax.Internal.Blocked
instance GHC.Show.Show t => GHC.Show.Show (Agda.Syntax.Internal.Blocked t)
instance Data.Traversable.Traversable Agda.Syntax.Internal.Type'
instance Data.Foldable.Foldable Agda.Syntax.Internal.Type'
instance GHC.Base.Functor Agda.Syntax.Internal.Type'
instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Internal.Type' a)
instance GHC.Show.Show Agda.Syntax.Internal.Sort
instance GHC.Show.Show Agda.Syntax.Internal.LevelAtom
instance GHC.Show.Show Agda.Syntax.Internal.PlusLevel
instance GHC.Show.Show Agda.Syntax.Internal.Level
instance GHC.Show.Show Agda.Syntax.Internal.Term
instance GHC.Show.Show Agda.Syntax.Internal.NotBlocked
instance Data.Traversable.Traversable Agda.Syntax.Internal.Tele
instance Data.Foldable.Foldable Agda.Syntax.Internal.Tele
instance GHC.Base.Functor Agda.Syntax.Internal.Tele
instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Internal.Tele a)
instance Data.Traversable.Traversable Agda.Syntax.Internal.Abs
instance Data.Foldable.Foldable Agda.Syntax.Internal.Abs
instance GHC.Base.Functor Agda.Syntax.Internal.Abs
instance Data.Traversable.Traversable Agda.Syntax.Internal.Elim'
instance Data.Foldable.Foldable Agda.Syntax.Internal.Elim'
instance GHC.Base.Functor Agda.Syntax.Internal.Elim'
instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Internal.Elim' a)
instance GHC.Classes.Eq Agda.Syntax.Internal.ConHead
instance GHC.Classes.Ord Agda.Syntax.Internal.ConHead
instance GHC.Show.Show Agda.Syntax.Internal.ConHead
instance Agda.Syntax.Position.HasRange Agda.Syntax.Internal.ConHead
instance Agda.Syntax.Position.SetRange Agda.Syntax.Internal.ConHead
instance Agda.Syntax.Internal.LensConName Agda.Syntax.Internal.ConHead
instance Agda.Utils.Functor.Decoration Agda.Syntax.Internal.Abs
instance Agda.Utils.Functor.Decoration Agda.Syntax.Internal.Type'
instance Agda.Syntax.Internal.LensSort (Agda.Syntax.Internal.Type' a)
instance Agda.Syntax.Internal.LensSort a => Agda.Syntax.Internal.LensSort (Agda.Syntax.Common.Dom a)
instance Agda.Syntax.Internal.LensSort a => Agda.Syntax.Internal.LensSort (Agda.Syntax.Internal.Abs a)
instance Data.Semigroup.Semigroup Agda.Syntax.Internal.NotBlocked
instance GHC.Base.Monoid Agda.Syntax.Internal.NotBlocked
instance GHC.Base.Applicative Agda.Syntax.Internal.Blocked
instance Data.Semigroup.Semigroup Agda.Syntax.Internal.Blocked_
instance GHC.Base.Monoid Agda.Syntax.Internal.Blocked_
instance Agda.Syntax.Position.HasRange Agda.Syntax.Internal.Clause
instance Agda.Syntax.Abstract.Name.IsProjP (Agda.Syntax.Internal.Pattern' a)
instance Agda.Utils.Null.Null (Agda.Syntax.Internal.Substitution' a)
instance Agda.Syntax.Internal.SgTel (Agda.Syntax.Internal.ArgName, Agda.Syntax.Common.Dom Agda.Syntax.Internal.Type)
instance Agda.Syntax.Internal.SgTel (Agda.Syntax.Common.Dom (Agda.Syntax.Internal.ArgName, Agda.Syntax.Internal.Type))
instance Agda.Syntax.Internal.SgTel (Agda.Syntax.Common.Dom Agda.Syntax.Internal.Type)
instance Agda.Syntax.Internal.Suggest GHC.Base.String GHC.Base.String
instance Agda.Syntax.Internal.Suggest (Agda.Syntax.Internal.Abs a) (Agda.Syntax.Internal.Abs b)
instance Agda.Syntax.Internal.Suggest GHC.Base.String (Agda.Syntax.Internal.Abs b)
instance Agda.Syntax.Internal.Suggest Agda.Syntax.Abstract.Name.Name (Agda.Syntax.Internal.Abs b)
instance Agda.Syntax.Internal.IsProjElim Agda.Syntax.Internal.Elim
instance Agda.Utils.Null.Null (Agda.Syntax.Internal.Tele a)
instance Agda.Utils.Null.Null Agda.Syntax.Internal.Clause
instance GHC.Show.Show a => GHC.Show.Show (Agda.Syntax.Internal.Abs a)
instance Agda.Utils.Size.Sized (Agda.Syntax.Internal.Tele a)
instance Agda.Utils.Size.Sized a => Agda.Utils.Size.Sized (Agda.Syntax.Internal.Abs a)
instance (Data.Foldable.Foldable t, Agda.Syntax.Internal.TermSize a) => Agda.Syntax.Internal.TermSize (t a)
instance Agda.Syntax.Internal.TermSize Agda.Syntax.Internal.Term
instance Agda.Syntax.Internal.TermSize Agda.Syntax.Internal.Sort
instance Agda.Syntax.Internal.TermSize Agda.Syntax.Internal.Level
instance Agda.Syntax.Internal.TermSize Agda.Syntax.Internal.PlusLevel
instance Agda.Syntax.Internal.TermSize Agda.Syntax.Internal.LevelAtom
instance Agda.Syntax.Internal.TermSize a => Agda.Syntax.Internal.TermSize (Agda.Syntax.Internal.Substitution' a)
instance Agda.Syntax.Position.KillRange Agda.Syntax.Internal.ConHead
instance Agda.Syntax.Position.KillRange Agda.Syntax.Internal.Term
instance Agda.Syntax.Position.KillRange Agda.Syntax.Internal.Level
instance Agda.Syntax.Position.KillRange Agda.Syntax.Internal.PlusLevel
instance Agda.Syntax.Position.KillRange Agda.Syntax.Internal.LevelAtom
instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Syntax.Internal.Type' a)
instance Agda.Syntax.Position.KillRange Agda.Syntax.Internal.Sort
instance Agda.Syntax.Position.KillRange Agda.Syntax.Internal.Substitution
instance Agda.Syntax.Position.KillRange Agda.Syntax.Internal.ConPatternInfo
instance Agda.Syntax.Position.KillRange Agda.Syntax.Internal.DBPatVar
instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Syntax.Internal.Pattern' a)
instance Agda.Syntax.Position.KillRange Agda.Syntax.Internal.Clause
instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Syntax.Internal.Tele a)
instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Syntax.Internal.Blocked a)
instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Syntax.Internal.Abs a)
instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Syntax.Internal.Elim' a)


-- | Epic interface data structure, which is serialisable and stored for
--   each compiled file
module Agda.Compiler.Epic.Interface
type Var = String
data Tag
Tag :: Int -> Tag
PrimTag :: Var -> Tag
data Forced
NotForced :: Forced
Forced :: Forced

-- | Filter a list using a list of Bools specifying what to keep.
pairwiseFilter :: [Bool] -> [a] -> [a]
notForced :: ForcedArgs -> [a] -> [a]
forced :: ForcedArgs -> [a] -> [a]
data Relevance
Irr :: Relevance
Rel :: Relevance
type ForcedArgs = [Forced]
type RelevantArgs = [Relevance]
data InjectiveFun
InjectiveFun :: Nat -> Nat -> InjectiveFun
[injArg] :: InjectiveFun -> Nat
[injArity] :: InjectiveFun -> Nat
data EInterface
EInterface :: Map QName Tag -> Set Var -> Map QName Bool -> Map QName Int -> Maybe QName -> Map Var RelevantArgs -> Map QName ForcedArgs -> Map QName InjectiveFun -> EInterface
[constrTags] :: EInterface -> Map QName Tag
[definitions] :: EInterface -> Set Var
[defDelayed] :: EInterface -> Map QName Bool
[conArity] :: EInterface -> Map QName Int
[mainName] :: EInterface -> Maybe QName
[relevantArgs] :: EInterface -> Map Var RelevantArgs
[forcedArgs] :: EInterface -> Map QName ForcedArgs
[injectiveFuns] :: EInterface -> Map QName InjectiveFun
instance GHC.Show.Show Agda.Compiler.Epic.Interface.EInterface
instance GHC.Classes.Eq Agda.Compiler.Epic.Interface.InjectiveFun
instance GHC.Show.Show Agda.Compiler.Epic.Interface.InjectiveFun
instance GHC.Show.Show Agda.Compiler.Epic.Interface.Relevance
instance GHC.Classes.Ord Agda.Compiler.Epic.Interface.Relevance
instance GHC.Classes.Eq Agda.Compiler.Epic.Interface.Relevance
instance GHC.Classes.Eq Agda.Compiler.Epic.Interface.Forced
instance GHC.Show.Show Agda.Compiler.Epic.Interface.Forced
instance GHC.Classes.Ord Agda.Compiler.Epic.Interface.Tag
instance GHC.Classes.Eq Agda.Compiler.Epic.Interface.Tag
instance GHC.Show.Show Agda.Compiler.Epic.Interface.Tag
instance Data.Semigroup.Semigroup Agda.Compiler.Epic.Interface.EInterface
instance GHC.Base.Monoid Agda.Compiler.Epic.Interface.EInterface


-- | Intermediate abstract syntax tree used in the compiler. Pretty close
--   to Epic syntax.
module Agda.Compiler.Epic.AuxAST
type Comment = String
type Inline = Bool
data Fun
Fun :: Inline -> Var -> Maybe QName -> Comment -> [Var] -> Expr -> Fun
[funInline] :: Fun -> Inline
[funName] :: Fun -> Var
[funQName] :: Fun -> Maybe QName
[funComment] :: Fun -> Comment
[funArgs] :: Fun -> [Var]
[funExpr] :: Fun -> Expr
EpicFun :: Var -> Maybe QName -> Comment -> String -> Fun
[funName] :: Fun -> Var
[funQName] :: Fun -> Maybe QName
[funComment] :: Fun -> Comment
[funEpicCode] :: Fun -> String
data Lit
LInt :: Integer -> Lit
LChar :: Char -> Lit
LString :: String -> Lit
LFloat :: Double -> Lit
data Expr
Var :: Var -> Expr
Lit :: Lit -> Expr
Lam :: Var -> Expr -> Expr
Con :: Tag -> QName -> [Expr] -> Expr
App :: Var -> [Expr] -> Expr
Case :: Expr -> [Branch] -> Expr
If :: Expr -> Expr -> Expr -> Expr
Let :: Var -> Expr -> Expr -> Expr
Lazy :: Expr -> Expr
UNIT :: Expr
IMPOSSIBLE :: Expr
data Branch
Branch :: Tag -> QName -> [Var] -> Expr -> Branch
[brTag] :: Branch -> Tag
[brName] :: Branch -> QName
[brVars] :: Branch -> [Var]
[brExpr] :: Branch -> Expr
BrInt :: Int -> Expr -> Branch
[brInt] :: Branch -> Int
[brExpr] :: Branch -> Expr
Default :: Expr -> Branch
[brExpr] :: Branch -> Expr
getBrVars :: Branch -> [Var]

-- | Smart constructor for let expressions to avoid unneceessary lets
lett :: Var -> Expr -> Expr -> Expr

-- | Some things are pointless to make lazy
lazy :: Expr -> Expr

-- | If casing on the same expression in a sub-expression, we know what
--   branch to pick
casee :: Expr -> [Branch] -> Expr

-- | Smart constructor for applications to avoid empty applications
apps :: Var -> [Expr] -> Expr

-- | Substitution
subst :: Var -> Var -> Expr -> Expr
substs :: [(Var, Var)] -> Expr -> Expr
substBranch :: Var -> Var -> Branch -> Branch

-- | Get the free variables in an expression
fv :: Expr -> [Var]
instance GHC.Show.Show Agda.Compiler.Epic.AuxAST.Fun
instance GHC.Classes.Ord Agda.Compiler.Epic.AuxAST.Fun
instance GHC.Classes.Eq Agda.Compiler.Epic.AuxAST.Fun
instance GHC.Classes.Eq Agda.Compiler.Epic.AuxAST.Expr
instance GHC.Classes.Ord Agda.Compiler.Epic.AuxAST.Expr
instance GHC.Show.Show Agda.Compiler.Epic.AuxAST.Expr
instance GHC.Classes.Eq Agda.Compiler.Epic.AuxAST.Branch
instance GHC.Classes.Ord Agda.Compiler.Epic.AuxAST.Branch
instance GHC.Show.Show Agda.Compiler.Epic.AuxAST.Branch
instance GHC.Classes.Eq Agda.Compiler.Epic.AuxAST.Lit
instance GHC.Classes.Ord Agda.Compiler.Epic.AuxAST.Lit
instance GHC.Show.Show Agda.Compiler.Epic.AuxAST.Lit


-- | The abstract syntax. This is what you get after desugaring and scope
--   analysis of the concrete syntax. The type checker works on abstract
--   syntax, producing internal syntax (<a>Agda.Syntax.Internal</a>).
module Agda.Syntax.Abstract
type Args = [NamedArg Expr]

-- | Expressions after scope checking (operators parsed, names resolved).
data Expr

-- | Bound variable.
Var :: Name -> Expr

-- | Constant: axiom, function, data or record type.
Def :: QName -> Expr

-- | Projection (overloaded).
Proj :: ProjOrigin -> AmbiguousQName -> Expr

-- | Constructor (overloaded).
Con :: AmbiguousQName -> Expr

-- | Pattern synonym.
PatternSyn :: QName -> Expr

-- | Macro.
Macro :: QName -> Expr

-- | Literal.
Lit :: Literal -> Expr

-- | Meta variable for interaction. The <a>InteractionId</a> is usually
--   identical with the <a>metaNumber</a> of <a>MetaInfo</a>. However, if
--   you want to print an interaction meta as just <tt>?</tt> instead of
--   <tt>?n</tt>, you should set the <a>metaNumber</a> to <a>Nothing</a>
--   while keeping the <a>InteractionId</a>.
QuestionMark :: MetaInfo -> InteractionId -> Expr

-- | Meta variable for hidden argument (must be inferred locally).
Underscore :: MetaInfo -> Expr

-- | <tt>.e</tt>, for postfix projection.
Dot :: ExprInfo -> Expr -> Expr

-- | Ordinary (binary) application.
App :: ExprInfo -> Expr -> (NamedArg Expr) -> Expr

-- | With application.
WithApp :: ExprInfo -> Expr -> [Expr] -> Expr

-- | <tt>λ bs → e</tt>.
Lam :: ExprInfo -> LamBinding -> Expr -> Expr

-- | <tt>λ()</tt> or <tt>λ{}</tt>.
AbsurdLam :: ExprInfo -> Hiding -> Expr
ExtendedLam :: ExprInfo -> DefInfo -> QName -> [Clause] -> Expr

-- | Dependent function space <tt>Γ → A</tt>.
Pi :: ExprInfo -> Telescope -> Expr -> Expr

-- | Non-dependent function space.
Fun :: ExprInfo -> (Arg Expr) -> Expr -> Expr

-- | <tt>Set</tt>, <tt>Set1</tt>, <tt>Set2</tt>, ...
Set :: ExprInfo -> Integer -> Expr

-- | <tt>Prop</tt> (no longer supported, used as dummy type).
Prop :: ExprInfo -> Expr

-- | <tt>let bs in e</tt>.
Let :: ExprInfo -> [LetBinding] -> Expr -> Expr

-- | Only used when printing telescopes.
ETel :: Telescope -> Expr

-- | Record construction.
Rec :: ExprInfo -> RecordAssigns -> Expr

-- | Record update.
RecUpdate :: ExprInfo -> Expr -> Assigns -> Expr

-- | Scope annotation.
ScopedExpr :: ScopeInfo -> Expr -> Expr

-- | Binds <tt>Name</tt> to current type in <tt>Expr</tt>.
QuoteGoal :: ExprInfo -> Name -> Expr -> Expr

-- | Returns the current context.
QuoteContext :: ExprInfo -> Expr

-- | Quote an identifier <a>QName</a>.
Quote :: ExprInfo -> Expr

-- | Quote a term.
QuoteTerm :: ExprInfo -> Expr

-- | The splicing construct: unquote ...
Unquote :: ExprInfo -> Expr

-- | <pre>
--   tactic e x1 .. xn | y1 | .. | yn
--   </pre>
Tactic :: ExprInfo -> Expr -> [NamedArg Expr] -> [NamedArg Expr] -> Expr

-- | For printing <tt>DontCare</tt> from <tt>Syntax.Internal</tt>.
DontCare :: Expr -> Expr

-- | Record field assignment <tt>f = e</tt>.
type Assign = FieldAssignment' Expr
type Assigns = [Assign]
type RecordAssign = Either Assign ModuleName
type RecordAssigns = [RecordAssign]

-- | Is a type signature a <tt>postulate</tt> 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 ScopeCopyInfo
ScopeCopyInfo :: Ren ModuleName -> Ren QName -> ScopeCopyInfo
[renModules] :: ScopeCopyInfo -> Ren ModuleName
[renNames] :: ScopeCopyInfo -> Ren QName
initCopyInfo :: ScopeCopyInfo
data Declaration

-- | Type signature (can be irrelevant, but not hidden).
--   
--   The fourth argument contains an optional assignment of polarities to
--   arguments.
Axiom :: Axiom -> DefInfo -> ArgInfo -> (Maybe [Occurrence]) -> 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 <tt>ImportDirective</tt> is for highlighting purposes.
Apply :: ModuleInfo -> ModuleName -> ModuleApplication -> ScopeCopyInfo -> ImportDirective -> Declaration

-- | The <tt>ImportDirective</tt> 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 <a>LamBinding</a>s are <a>DomainFree</a> and
--   binds the parameters of the datatype.
DataSig :: DefInfo -> QName -> Telescope -> Expr -> Declaration

-- | the <a>LamBinding</a>s are <a>DomainFree</a> and binds the parameters
--   of the datatype.
DataDef :: DefInfo -> QName -> [LamBinding] -> [Constructor] -> Declaration

-- | lone record signature
RecSig :: DefInfo -> QName -> Telescope -> Expr -> Declaration

-- | The <a>Expr</a> gives the constructor type telescope, <tt>(x1 :
--   A1)..(xn : An) -&gt; Prop</tt>, 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

-- | <tt>tel. M args</tt>: applies <tt>M</tt> to <tt>args</tt> and
--   abstracts <tt>tel</tt>.
SectionApp :: Telescope -> ModuleName -> [NamedArg Expr] -> ModuleApplication

-- | <pre>
--   M {{...}}
--   </pre>
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
StaticPragma :: QName -> Pragma
InlinePragma :: QName -> Pragma
DisplayPragma :: QName -> [NamedArg Pattern] -> Expr -> Pragma

-- | Bindings that are valid in a <tt>let</tt>.
data LetBinding

-- | <pre>
--   LetBind info rel name type defn
--   </pre>
LetBind :: LetInfo -> ArgInfo -> Name -> Expr -> Expr -> LetBinding

-- | Irrefutable pattern binding.
LetPatBind :: LetInfo -> Pattern -> Expr -> LetBinding

-- | <tt>LetApply mi newM (oldM args) renamings dir</tt>. The
--   <tt>ImportDirective</tt> is for highlighting purposes.
LetApply :: ModuleInfo -> ModuleName -> ModuleApplication -> ScopeCopyInfo -> ImportDirective -> LetBinding

-- | only for highlighting and abstractToConcrete
LetOpen :: ModuleInfo -> ModuleName -> ImportDirective -> LetBinding

-- | Only used for highlighting. Refers to the first occurrence of
--   <tt>x</tt> in <tt>let x : A; x = e</tt>.
LetDeclaredVariable :: Name -> LetBinding

-- | Only <a>Axiom</a>s.
type TypeSignature = Declaration
type Constructor = TypeSignature
type Field = TypeSignature

-- | A lambda binding is either domain free or typed.
data LamBinding

-- | . <tt>x</tt> or <tt>{x}</tt> or <tt>.x</tt> or <tt>.{x}</tt>
DomainFree :: ArgInfo -> Name -> LamBinding

-- | . <tt>(xs:e)</tt> or <tt>{xs:e}</tt> or <tt>(let Ds)</tt>
DomainFull :: TypedBindings -> LamBinding

-- | Typed bindings with hiding information.
data TypedBindings

-- | . <tt>(xs : e)</tt> or <tt>{xs : e}</tt>
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, <tt>(x y : A)</tt> to
--   <tt>(x : A)(y : A)</tt> before type-checking. However, this would be
--   slightly problematic:
--   
--   <ol>
--   <li>We would have to typecheck the type <tt>A</tt> several times.</li>
--   <li>If <tt>A</tt> contains a meta variable or hole, it would be
--   duplicated by such a translation.</li>
--   </ol>
--   
--   While 1. is only slightly inefficient, 2. would be an outright bug.
--   Duplicating <tt>A</tt> could not be done naively, we would have to
--   make sure that the metas of the copy are aliases of the metas of the
--   original.
data TypedBinding

-- | As in telescope <tt>(x y z : A)</tt> or type <tt>(x y z : A) -&gt;
--   B</tt>.
TBind :: Range -> [WithHiding Name] -> Expr -> TypedBinding

-- | E.g. <tt>(let x = e)</tt> or <tt>(let open M)</tt>.
TLet :: Range -> [LetBinding] -> TypedBinding
type Telescope = [TypedBindings]
data NamedDotPattern
NamedDot :: Name -> Term -> Type -> NamedDotPattern

-- | We could throw away <tt>where</tt> clauses at this point and translate
--   them to <tt>let</tt>. It's not obvious how to remember that the
--   <tt>let</tt> was really a <tt>where</tt> clause though, so for the
--   time being we keep it here.
data Clause' lhs
Clause :: lhs -> [NamedDotPattern] -> RHS -> [Declaration] -> Bool -> Clause' lhs
[clauseLHS] :: Clause' lhs -> lhs

-- | Only in with-clauses where we inherit some already checked dot
--   patterns from the parent. These live in the context of the parent
--   clause left-hand side.
[clauseNamedDots] :: Clause' lhs -> [NamedDotPattern]
[clauseRHS] :: Clause' lhs -> RHS
[clauseWhereDecls] :: Clause' lhs -> [Declaration]
[clauseCatchall] :: Clause' lhs -> Bool
type Clause = Clause' LHS
type SpineClause = Clause' SpineLHS
data RHS
RHS :: Expr -> Maybe Expr -> RHS
[rhsExpr] :: RHS -> Expr

-- | We store the original concrete expression in case we have to reproduce
--   it during interactive case splitting. <a>Nothing</a> for internally
--   generated rhss.
[rhsConcrete] :: RHS -> Maybe Expr
AbsurdRHS :: RHS

-- | The <a>QName</a> is the name of the with function.
WithRHS :: QName -> [Expr] -> [Clause] -> RHS
RewriteRHS :: [(QName, Expr)] -> RHS -> [Declaration] -> RHS

-- | The <a>QName</a>s are the names of the generated with functions, one
--   for each <a>Expr</a>.
[rewriteExprs] :: RHS -> [(QName, Expr)]

-- | The RHS should not be another <tt>RewriteRHS</tt>.
[rewriteRHS] :: RHS -> RHS

-- | The where clauses are attached to the <tt>RewriteRHS</tt> by
[rewriteWhereDecls] :: RHS -> [Declaration]

-- | The lhs of a clause in spine view (inside-out). Projection patterns
--   are contained in <tt>spLhsPats</tt>, represented as <tt>ProjP d</tt>.
data SpineLHS
SpineLHS :: LHSInfo -> QName -> [NamedArg Pattern] -> [Pattern] -> SpineLHS

-- | Range.
[spLhsInfo] :: SpineLHS -> LHSInfo

-- | Name of function we are defining.
[spLhsDefName] :: SpineLHS -> QName

-- | Function parameters (patterns).
[spLhsPats] :: SpineLHS -> [NamedArg Pattern]

-- | <tt>with</tt> patterns (after <tt>|</tt>).
[spLhsWithPats] :: SpineLHS -> [Pattern]

-- | The lhs of a clause in focused (projection-application) view
--   (outside-in). Projection patters are represented as <a>LHSProj</a>s.
data LHS
LHS :: LHSInfo -> LHSCore -> [Pattern] -> LHS

-- | Range.
[lhsInfo] :: LHS -> LHSInfo

-- | Copatterns.
[lhsCore] :: LHS -> LHSCore

-- | <tt>with</tt> patterns (after <tt>|</tt>).
[lhsWithPats] :: LHS -> [Pattern]

-- | The lhs minus <tt>with</tt>-patterns in projection-application view.
--   Parameterised over the type <tt>e</tt> of dot patterns.
data LHSCore' e

-- | The head applied to ordinary patterns.
LHSHead :: QName -> [NamedArg (Pattern' e)] -> LHSCore' e

-- | Head <tt>f</tt>.
[lhsDefName] :: LHSCore' e -> QName

-- | Applied to patterns <tt>ps</tt>.
[lhsPats] :: LHSCore' e -> [NamedArg (Pattern' e)]

-- | Projection
LHSProj :: AmbiguousQName -> NamedArg (LHSCore' e) -> [NamedArg (Pattern' e)] -> LHSCore' e

-- | Record projection identifier.
[lhsDestructor] :: LHSCore' e -> AmbiguousQName

-- | Main branch.
[lhsFocus] :: LHSCore' e -> NamedArg (LHSCore' e)

-- | Further applied to patterns.
[lhsPatsRight] :: LHSCore' e -> [NamedArg (Pattern' e)]
type LHSCore = LHSCore' Expr

-- | Convert a focused lhs to spine view and back.
class LHSToSpine a b
lhsToSpine :: LHSToSpine a b => a -> b
spineToLhs :: LHSToSpine a b => b -> a

-- | Clause instance.

-- | List instance (for clauses).

-- | LHS instance.
lhsCoreToSpine :: LHSCore' e -> QNamed [NamedArg (Pattern' e)]
spineToLhsCore :: IsProjP e => QNamed [NamedArg (Pattern' e)] -> LHSCore' e

-- | Add applicative patterns (non-projection patterns) to the right.
lhsCoreApp :: IsProjP e => LHSCore' e -> [NamedArg (Pattern' e)] -> LHSCore' e

-- | Add projection and applicative patterns to the right.
lhsCoreAddSpine :: IsProjP e => LHSCore' e -> [NamedArg (Pattern' e)] -> LHSCore' e

-- | Used for checking pattern linearity.
lhsCoreAllPatterns :: LHSCore' e -> [Pattern' e]

-- | Used in AbstractToConcrete.
lhsCoreToPattern :: LHSCore -> Pattern
mapLHSHead :: (QName -> [NamedArg Pattern] -> LHSCore) -> LHSCore -> LHSCore

-- | Parameterised over the type of dot patterns.
data Pattern' e
VarP :: Name -> Pattern' e
ConP :: ConPatInfo -> AmbiguousQName -> [NamedArg (Pattern' e)] -> Pattern' e

-- | Destructor pattern <tt>d</tt>.
ProjP :: PatInfo -> ProjOrigin -> AmbiguousQName -> Pattern' e

-- | Defined pattern: function definition <tt>f ps</tt>. It is also abused
--   to convert destructor patterns into concrete syntax thus, we put
--   AmbiguousQName here as well.
DefP :: PatInfo -> AmbiguousQName -> [NamedArg (Pattern' e)] -> Pattern' e

-- | Underscore pattern entered by user. Or generated at type checking for
--   implicit arguments.
WildP :: PatInfo -> Pattern' e
AsP :: PatInfo -> Name -> (Pattern' e) -> Pattern' e
DotP :: PatInfo -> Origin -> e -> Pattern' e
AbsurdP :: PatInfo -> Pattern' e
LitP :: Literal -> Pattern' e
PatternSynP :: PatInfo -> QName -> [NamedArg (Pattern' e)] -> Pattern' e
RecP :: PatInfo -> [FieldAssignment' (Pattern' e)] -> Pattern' e
type Pattern = Pattern' Expr
type Patterns = [NamedArg Pattern]
class MaybePostfixProjP a
maybePostfixProjP :: MaybePostfixProjP a => a -> Maybe (ProjOrigin, AmbiguousQName)

-- | Does not compare <a>ScopeInfo</a> fields. Does not distinguish between
--   prefix and postfix projections.

-- | Does not compare <a>ScopeInfo</a> fields.

-- | Extracts all the names which are declared in a <a>Declaration</a>.
--   This does not include open public or let expressions, but it does
--   include local modules, where clauses and the names of extended
--   lambdas.
class AllNames a
allNames :: AllNames a => a -> Seq QName

-- | The name defined by the given axiom.
--   
--   Precondition: The declaration has to be a (scoped) <a>Axiom</a>.
axiomName :: Declaration -> QName

-- | Are we in an abstract block?
--   
--   In that case some definition is abstract.
class AnyAbstract a
anyAbstract :: AnyAbstract a => a -> Bool

-- | Turn an <a>AbstractName</a> to an expression.
nameExpr :: AbstractName -> Expr
app :: Expr -> [NamedArg Expr] -> Expr
mkLet :: ExprInfo -> [LetBinding] -> Expr -> Expr
patternToExpr :: Pattern -> Expr
type PatternSynDefn = ([Arg Name], Pattern' Void)
type PatternSynDefns = Map QName PatternSynDefn
lambdaLiftExpr :: [Name] -> Expr -> Expr
substPattern :: [(Name, Pattern)] -> Pattern -> Pattern
class SubstExpr a
substExpr :: SubstExpr a => [(Name, Expr)] -> a -> a
insertImplicitPatSynArgs :: HasRange a => (Range -> a) -> Range -> [Arg Name] -> [NamedArg a] -> Maybe ([(Name, a)], [Arg Name])
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Abstract.Declaration Agda.Syntax.Common.RString
instance Agda.Syntax.Abstract.AllNames a => Agda.Syntax.Abstract.AllNames [a]
instance Agda.Syntax.Abstract.AllNames a => Agda.Syntax.Abstract.AllNames (GHC.Base.Maybe a)
instance Agda.Syntax.Abstract.AllNames a => Agda.Syntax.Abstract.AllNames (Agda.Syntax.Common.Arg a)
instance Agda.Syntax.Abstract.AllNames a => Agda.Syntax.Abstract.AllNames (Agda.Syntax.Common.Named name a)
instance (Agda.Syntax.Abstract.AllNames a, Agda.Syntax.Abstract.AllNames b) => Agda.Syntax.Abstract.AllNames (a, b)
instance Agda.Syntax.Abstract.AllNames Agda.Syntax.Abstract.Name.QName
instance Agda.Syntax.Abstract.AllNames Agda.Syntax.Abstract.Declaration
instance Agda.Syntax.Abstract.AllNames Agda.Syntax.Abstract.Clause
instance Agda.Syntax.Abstract.AllNames Agda.Syntax.Abstract.RHS
instance Agda.Syntax.Abstract.AllNames Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Abstract.AllNames Agda.Syntax.Abstract.LamBinding
instance Agda.Syntax.Abstract.AllNames Agda.Syntax.Abstract.TypedBindings
instance Agda.Syntax.Abstract.AllNames Agda.Syntax.Abstract.TypedBinding
instance Agda.Syntax.Abstract.AllNames Agda.Syntax.Abstract.LetBinding
instance Agda.Syntax.Abstract.AllNames Agda.Syntax.Abstract.ModuleApplication
instance Agda.Syntax.Abstract.AnyAbstract a => Agda.Syntax.Abstract.AnyAbstract [a]
instance Agda.Syntax.Abstract.AnyAbstract Agda.Syntax.Abstract.Declaration
instance Agda.Syntax.Abstract.SubstExpr a => Agda.Syntax.Abstract.SubstExpr [a]
instance Agda.Syntax.Abstract.SubstExpr a => Agda.Syntax.Abstract.SubstExpr (Agda.Syntax.Common.Arg a)
instance Agda.Syntax.Abstract.SubstExpr a => Agda.Syntax.Abstract.SubstExpr (Agda.Syntax.Common.Named name a)
instance (Agda.Syntax.Abstract.SubstExpr a, Agda.Syntax.Abstract.SubstExpr b) => Agda.Syntax.Abstract.SubstExpr (a, b)
instance (Agda.Syntax.Abstract.SubstExpr a, Agda.Syntax.Abstract.SubstExpr b) => Agda.Syntax.Abstract.SubstExpr (Data.Either.Either a b)
instance Agda.Syntax.Abstract.SubstExpr Agda.Syntax.Concrete.Name.Name
instance Agda.Syntax.Abstract.SubstExpr Agda.Syntax.Abstract.Name.ModuleName
instance Agda.Syntax.Abstract.SubstExpr Agda.Syntax.Abstract.Assign
instance Agda.Syntax.Abstract.SubstExpr Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Abstract.SubstExpr Agda.Syntax.Abstract.LetBinding
instance Agda.Syntax.Abstract.SubstExpr Agda.Syntax.Abstract.TypedBindings
instance Agda.Syntax.Abstract.SubstExpr Agda.Syntax.Abstract.TypedBinding
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Abstract.Declaration Agda.Syntax.Info.ModuleInfo
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Abstract.Declaration Agda.Syntax.Abstract.Name.ModuleName
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Abstract.Declaration Agda.Syntax.Abstract.Declaration
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Abstract.Declaration (Agda.Syntax.Abstract.Pattern' Data.Void.Void)
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Abstract.Declaration Agda.Syntax.Abstract.Pattern
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Abstract.Declaration Agda.Syntax.Abstract.TypedBinding
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Abstract.Declaration Agda.Syntax.Abstract.LamBinding
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Abstract.Declaration Agda.Syntax.Abstract.LetBinding
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Abstract.Declaration Agda.Syntax.Abstract.Expr
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Abstract.Declaration Agda.Syntax.Abstract.Name.AmbiguousQName
instance Data.Generics.Geniplate.UniverseBi Agda.Syntax.Abstract.Declaration Agda.Syntax.Abstract.Name.QName
instance GHC.Classes.Eq Agda.Syntax.Abstract.SpineLHS
instance GHC.Show.Show Agda.Syntax.Abstract.SpineLHS
instance GHC.Classes.Eq Agda.Syntax.Abstract.Pragma
instance GHC.Show.Show Agda.Syntax.Abstract.Pragma
instance GHC.Classes.Eq Agda.Syntax.Abstract.LamBinding
instance GHC.Show.Show Agda.Syntax.Abstract.LamBinding
instance GHC.Classes.Eq Agda.Syntax.Abstract.ModuleApplication
instance GHC.Show.Show Agda.Syntax.Abstract.ModuleApplication
instance GHC.Classes.Eq Agda.Syntax.Abstract.LetBinding
instance GHC.Show.Show Agda.Syntax.Abstract.LetBinding
instance GHC.Classes.Eq Agda.Syntax.Abstract.TypedBinding
instance GHC.Show.Show Agda.Syntax.Abstract.TypedBinding
instance GHC.Classes.Eq Agda.Syntax.Abstract.TypedBindings
instance GHC.Show.Show Agda.Syntax.Abstract.TypedBindings
instance GHC.Show.Show Agda.Syntax.Abstract.Declaration
instance GHC.Show.Show Agda.Syntax.Abstract.RHS
instance GHC.Classes.Eq lhs => GHC.Classes.Eq (Agda.Syntax.Abstract.Clause' lhs)
instance Data.Traversable.Traversable Agda.Syntax.Abstract.Clause'
instance Data.Foldable.Foldable Agda.Syntax.Abstract.Clause'
instance GHC.Base.Functor Agda.Syntax.Abstract.Clause'
instance GHC.Show.Show lhs => GHC.Show.Show (Agda.Syntax.Abstract.Clause' lhs)
instance GHC.Show.Show Agda.Syntax.Abstract.LHS
instance GHC.Show.Show Agda.Syntax.Abstract.Expr
instance GHC.Classes.Eq e => GHC.Classes.Eq (Agda.Syntax.Abstract.LHSCore' e)
instance Data.Traversable.Traversable Agda.Syntax.Abstract.LHSCore'
instance Data.Foldable.Foldable Agda.Syntax.Abstract.LHSCore'
instance GHC.Base.Functor Agda.Syntax.Abstract.LHSCore'
instance GHC.Show.Show e => GHC.Show.Show (Agda.Syntax.Abstract.LHSCore' e)
instance GHC.Classes.Eq e => GHC.Classes.Eq (Agda.Syntax.Abstract.Pattern' e)
instance Data.Traversable.Traversable Agda.Syntax.Abstract.Pattern'
instance Data.Foldable.Foldable Agda.Syntax.Abstract.Pattern'
instance GHC.Base.Functor Agda.Syntax.Abstract.Pattern'
instance GHC.Show.Show e => GHC.Show.Show (Agda.Syntax.Abstract.Pattern' e)
instance GHC.Show.Show Agda.Syntax.Abstract.NamedDotPattern
instance GHC.Show.Show Agda.Syntax.Abstract.ScopeCopyInfo
instance GHC.Classes.Eq Agda.Syntax.Abstract.ScopeCopyInfo
instance GHC.Show.Show Agda.Syntax.Abstract.Axiom
instance GHC.Classes.Ord Agda.Syntax.Abstract.Axiom
instance GHC.Classes.Eq Agda.Syntax.Abstract.Axiom
instance Agda.Utils.Pretty.Pretty Agda.Syntax.Abstract.ScopeCopyInfo
instance Agda.Syntax.Abstract.GetDefInfo Agda.Syntax.Abstract.Declaration
instance GHC.Classes.Eq Agda.Syntax.Abstract.NamedDotPattern
instance GHC.Classes.Eq Agda.Syntax.Abstract.RHS
instance GHC.Classes.Eq Agda.Syntax.Abstract.LHS
instance Agda.Syntax.Abstract.LHSToSpine Agda.Syntax.Abstract.Clause Agda.Syntax.Abstract.SpineClause
instance Agda.Syntax.Abstract.LHSToSpine a b => Agda.Syntax.Abstract.LHSToSpine [a] [b]
instance Agda.Syntax.Abstract.LHSToSpine Agda.Syntax.Abstract.LHS Agda.Syntax.Abstract.SpineLHS
instance Agda.Syntax.Abstract.Name.IsProjP (Agda.Syntax.Abstract.Pattern' e)
instance Agda.Syntax.Abstract.Name.IsProjP Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Abstract.Name.IsProjP e => Agda.Syntax.Abstract.MaybePostfixProjP (Agda.Syntax.Abstract.Pattern' e)
instance Agda.Syntax.Abstract.MaybePostfixProjP a => Agda.Syntax.Abstract.MaybePostfixProjP (Agda.Syntax.Common.Arg a)
instance Agda.Syntax.Abstract.MaybePostfixProjP a => Agda.Syntax.Abstract.MaybePostfixProjP (Agda.Syntax.Common.Named n a)
instance GHC.Classes.Eq Agda.Syntax.Abstract.Expr
instance GHC.Classes.Eq Agda.Syntax.Abstract.Declaration
instance Agda.Syntax.Common.Underscore Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Common.LensHiding Agda.Syntax.Abstract.TypedBindings
instance Agda.Syntax.Common.LensHiding Agda.Syntax.Abstract.LamBinding
instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.LamBinding
instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.TypedBindings
instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.TypedBinding
instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.Declaration
instance Agda.Syntax.Position.HasRange (Agda.Syntax.Abstract.Pattern' e)
instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.SpineLHS
instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.LHS
instance Agda.Syntax.Position.HasRange (Agda.Syntax.Abstract.LHSCore' e)
instance Agda.Syntax.Position.HasRange a => Agda.Syntax.Position.HasRange (Agda.Syntax.Abstract.Clause' a)
instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.RHS
instance Agda.Syntax.Position.HasRange Agda.Syntax.Abstract.LetBinding
instance Agda.Syntax.Position.SetRange (Agda.Syntax.Abstract.Pattern' a)
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.LamBinding
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.TypedBindings
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.TypedBinding
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.Declaration
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.ModuleApplication
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.ScopeCopyInfo
instance Agda.Syntax.Position.KillRange e => Agda.Syntax.Position.KillRange (Agda.Syntax.Abstract.Pattern' e)
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.SpineLHS
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.LHS
instance Agda.Syntax.Position.KillRange e => Agda.Syntax.Position.KillRange (Agda.Syntax.Abstract.LHSCore' e)
instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.Syntax.Abstract.Clause' a)
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.NamedDotPattern
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.RHS
instance Agda.Syntax.Position.KillRange Agda.Syntax.Abstract.LetBinding

module Agda.Syntax.Abstract.Views
data AppView
Application :: Expr -> [NamedArg Expr] -> AppView

-- | Gather applications to expose head and spine.
--   
--   Note: everything is an application, possibly of itself to 0 arguments
appView :: Expr -> AppView
maybeProjTurnPostfix :: Expr -> Maybe Expr
unAppView :: AppView -> Expr

-- | Gather top-level <a>AsP</a>atterns to expose underlying pattern.
asView :: Pattern -> ([Name], Pattern)

-- | Check whether we are dealing with a universe.
isSet :: Expr -> Bool

-- | Remove top <a>ScopedExpr</a> wrappers.
unScope :: Expr -> Expr

-- | Remove <a>ScopedExpr</a> wrappers everywhere.
--   
--   NB: Unless the implementation of <a>ExprLike</a> for clauses has been
--   finished, this does not work for clauses yet.
deepUnscope :: ExprLike a => a -> a
deepUnscopeDecls :: [Declaration] -> [Declaration]
deepUnscopeDecl :: Declaration -> [Declaration]

-- | Apply an expression rewriting to every subexpression, inside-out. See
--   <a>Agda.Syntax.Internal.Generic</a>.
class ExprLike a where recurseExpr = traverse . recurseExpr foldExpr f = getConst . recurseExpr (\ pre post -> Const (f pre) <* post) traverseExpr f = recurseExpr (\ pre post -> f =<< post) mapExpr f = runIdentity . traverseExpr (Identity . f)

-- | The first expression is pre-traversal, the second one post-traversal.
recurseExpr :: (ExprLike a, Applicative m) => (Expr -> m Expr -> m Expr) -> a -> m a

-- | The first expression is pre-traversal, the second one post-traversal.
recurseExpr :: (ExprLike a, Traversable f, ExprLike a', a ~ f a', Applicative m) => (Expr -> m Expr -> m Expr) -> a -> m a
foldExpr :: (ExprLike a, Monoid m) => (Expr -> m) -> a -> m
traverseExpr :: (ExprLike a, Monad m) => (Expr -> m Expr) -> a -> m a
mapExpr :: ExprLike a => (Expr -> Expr) -> (a -> a)
instance Agda.Syntax.Abstract.Views.ExprLike Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Abstract.Views.ExprLike a => Agda.Syntax.Abstract.Views.ExprLike (Agda.Syntax.Common.Arg a)
instance Agda.Syntax.Abstract.Views.ExprLike a => Agda.Syntax.Abstract.Views.ExprLike (Agda.Syntax.Common.Named x a)
instance Agda.Syntax.Abstract.Views.ExprLike a => Agda.Syntax.Abstract.Views.ExprLike [a]
instance (Agda.Syntax.Abstract.Views.ExprLike a, Agda.Syntax.Abstract.Views.ExprLike b) => Agda.Syntax.Abstract.Views.ExprLike (a, b)
instance Agda.Syntax.Abstract.Views.ExprLike Data.Void.Void
instance Agda.Syntax.Abstract.Views.ExprLike a => Agda.Syntax.Abstract.Views.ExprLike (Agda.Syntax.Concrete.FieldAssignment' a)
instance (Agda.Syntax.Abstract.Views.ExprLike a, Agda.Syntax.Abstract.Views.ExprLike b) => Agda.Syntax.Abstract.Views.ExprLike (Data.Either.Either a b)
instance Agda.Syntax.Abstract.Views.ExprLike Agda.Syntax.Abstract.Name.ModuleName
instance Agda.Syntax.Abstract.Views.ExprLike Agda.Syntax.Abstract.Name.QName
instance Agda.Syntax.Abstract.Views.ExprLike Agda.Syntax.Abstract.LamBinding
instance Agda.Syntax.Abstract.Views.ExprLike Agda.Syntax.Abstract.TypedBindings
instance Agda.Syntax.Abstract.Views.ExprLike Agda.Syntax.Abstract.TypedBinding
instance Agda.Syntax.Abstract.Views.ExprLike Agda.Syntax.Abstract.LetBinding
instance Agda.Syntax.Abstract.Views.ExprLike a => Agda.Syntax.Abstract.Views.ExprLike (Agda.Syntax.Abstract.Pattern' a)
instance Agda.Syntax.Abstract.Views.ExprLike a => Agda.Syntax.Abstract.Views.ExprLike (Agda.Syntax.Abstract.Clause' a)
instance Agda.Syntax.Abstract.Views.ExprLike Agda.Syntax.Abstract.RHS
instance Agda.Syntax.Abstract.Views.ExprLike Agda.Syntax.Abstract.ModuleApplication
instance Agda.Syntax.Abstract.Views.ExprLike Agda.Syntax.Abstract.Pragma
instance Agda.Syntax.Abstract.Views.ExprLike Agda.Syntax.Abstract.LHS
instance Agda.Syntax.Abstract.Views.ExprLike a => Agda.Syntax.Abstract.Views.ExprLike (Agda.Syntax.Abstract.LHSCore' a)
instance Agda.Syntax.Abstract.Views.ExprLike Agda.Syntax.Abstract.SpineLHS
instance Agda.Syntax.Abstract.Views.ExprLike Agda.Syntax.Abstract.Declaration


-- | Extract used definitions from terms.
module Agda.Syntax.Internal.Defs

-- | <tt>getDefs' lookup emb a</tt> extracts all used definitions
--   (functions, data/record types) from <tt>a</tt>, embedded into a monoid
--   via <tt>emb</tt>. Instantiations of meta variables are obtained via
--   <tt>lookup</tt>.
--   
--   Typical monoid instances would be <tt>[QName]</tt> or <tt>Set
--   QName</tt>. Note that <tt>emb</tt> can also choose to discard a used
--   definition by mapping to the unit of the monoid.
getDefs' :: (GetDefs a, Monoid b) => (MetaId -> Maybe Term) -> (QName -> b) -> a -> b

-- | Inputs to and outputs of <tt>getDefs'</tt> are organized as a monad.
type GetDefsM b = ReaderT (GetDefsEnv b) (Writer b)
data GetDefsEnv b
GetDefsEnv :: (MetaId -> Maybe Term) -> (QName -> b) -> GetDefsEnv b
[lookupMeta] :: GetDefsEnv b -> MetaId -> Maybe Term
[embDef] :: GetDefsEnv b -> QName -> b

-- | What it takes to get the used definitions.
class Monad m => MonadGetDefs m
doDef :: MonadGetDefs m => QName -> m ()
doMeta :: MonadGetDefs m => MetaId -> m ()

-- | Getting the used definitions.
class GetDefs a
getDefs :: (GetDefs a, MonadGetDefs m) => a -> m ()
instance GHC.Base.Monoid b => Agda.Syntax.Internal.Defs.MonadGetDefs (Agda.Syntax.Internal.Defs.GetDefsM b)
instance Agda.Syntax.Internal.Defs.GetDefs Agda.Syntax.Internal.Clause
instance Agda.Syntax.Internal.Defs.GetDefs Agda.Syntax.Internal.Term
instance Agda.Syntax.Internal.Defs.GetDefs Agda.Syntax.Common.MetaId
instance Agda.Syntax.Internal.Defs.GetDefs Agda.Syntax.Internal.Type
instance Agda.Syntax.Internal.Defs.GetDefs Agda.Syntax.Internal.Sort
instance Agda.Syntax.Internal.Defs.GetDefs Agda.Syntax.Internal.Level
instance Agda.Syntax.Internal.Defs.GetDefs Agda.Syntax.Internal.PlusLevel
instance Agda.Syntax.Internal.Defs.GetDefs Agda.Syntax.Internal.LevelAtom
instance Agda.Syntax.Internal.Defs.GetDefs a => Agda.Syntax.Internal.Defs.GetDefs (GHC.Base.Maybe a)
instance Agda.Syntax.Internal.Defs.GetDefs a => Agda.Syntax.Internal.Defs.GetDefs [a]
instance Agda.Syntax.Internal.Defs.GetDefs a => Agda.Syntax.Internal.Defs.GetDefs (Agda.Syntax.Internal.Elim' a)
instance Agda.Syntax.Internal.Defs.GetDefs a => Agda.Syntax.Internal.Defs.GetDefs (Agda.Syntax.Common.Arg a)
instance Agda.Syntax.Internal.Defs.GetDefs a => Agda.Syntax.Internal.Defs.GetDefs (Agda.Syntax.Common.Dom a)
instance Agda.Syntax.Internal.Defs.GetDefs a => Agda.Syntax.Internal.Defs.GetDefs (Agda.Syntax.Internal.Abs a)
instance (Agda.Syntax.Internal.Defs.GetDefs a, Agda.Syntax.Internal.Defs.GetDefs b) => Agda.Syntax.Internal.Defs.GetDefs (a, b)

module Agda.Syntax.Internal.Generic
class TermLike a
traverseTerm :: TermLike a => (Term -> Term) -> a -> a
traverseTermM :: (TermLike a, Monad m) => (Term -> m Term) -> a -> m a
foldTerm :: (TermLike a, Monoid m) => (Term -> m) -> a -> m

-- | Put it in a monad to make it possible to do strictly.
copyTerm :: (TermLike a, Monad m) => a -> m a
instance Agda.Syntax.Internal.Generic.TermLike GHC.Types.Bool
instance Agda.Syntax.Internal.Generic.TermLike GHC.Types.Int
instance Agda.Syntax.Internal.Generic.TermLike GHC.Integer.Type.Integer
instance Agda.Syntax.Internal.Generic.TermLike GHC.Types.Char
instance Agda.Syntax.Internal.Generic.TermLike Agda.Syntax.Abstract.Name.QName
instance Agda.Syntax.Internal.Generic.TermLike a => Agda.Syntax.Internal.Generic.TermLike (Agda.Syntax.Internal.Elim' a)
instance Agda.Syntax.Internal.Generic.TermLike a => Agda.Syntax.Internal.Generic.TermLike (Agda.Syntax.Common.Arg a)
instance Agda.Syntax.Internal.Generic.TermLike a => Agda.Syntax.Internal.Generic.TermLike (Agda.Syntax.Common.Dom a)
instance Agda.Syntax.Internal.Generic.TermLike a => Agda.Syntax.Internal.Generic.TermLike [a]
instance Agda.Syntax.Internal.Generic.TermLike a => Agda.Syntax.Internal.Generic.TermLike (GHC.Base.Maybe a)
instance (Agda.Syntax.Internal.Generic.TermLike a, Agda.Syntax.Internal.Generic.TermLike b) => Agda.Syntax.Internal.Generic.TermLike (a, b)
instance (Agda.Syntax.Internal.Generic.TermLike a, Agda.Syntax.Internal.Generic.TermLike b, Agda.Syntax.Internal.Generic.TermLike c) => Agda.Syntax.Internal.Generic.TermLike (a, b, c)
instance (Agda.Syntax.Internal.Generic.TermLike a, Agda.Syntax.Internal.Generic.TermLike b, Agda.Syntax.Internal.Generic.TermLike c, Agda.Syntax.Internal.Generic.TermLike d) => Agda.Syntax.Internal.Generic.TermLike (a, b, c, d)
instance Agda.Syntax.Internal.Generic.TermLike a => Agda.Syntax.Internal.Generic.TermLike (Agda.Syntax.Internal.Abs a)
instance Agda.Syntax.Internal.Generic.TermLike a => Agda.Syntax.Internal.Generic.TermLike (Agda.Utils.Pointer.Ptr a)
instance Agda.Syntax.Internal.Generic.TermLike a => Agda.Syntax.Internal.Generic.TermLike (Agda.Syntax.Internal.Blocked a)
instance Agda.Syntax.Internal.Generic.TermLike Agda.Syntax.Internal.Term
instance Agda.Syntax.Internal.Generic.TermLike Agda.Syntax.Internal.Level
instance Agda.Syntax.Internal.Generic.TermLike Agda.Syntax.Internal.PlusLevel
instance Agda.Syntax.Internal.Generic.TermLike Agda.Syntax.Internal.LevelAtom
instance Agda.Syntax.Internal.Generic.TermLike Agda.Syntax.Internal.Type
instance Agda.Syntax.Internal.Generic.TermLike Agda.Syntax.Internal.EqualityView

module Agda.Syntax.Internal.Pattern

-- | Translate the clause patterns to terms with free variables bound by
--   the clause telescope.
--   
--   Precondition: no projection patterns.
clauseArgs :: Clause -> Args

-- | Translate the clause patterns to an elimination spine with free
--   variables bound by the clause telescope.
clauseElims :: Clause -> Elims

-- | Arity of a function, computed from clauses.
class FunArity a
funArity :: FunArity a => a -> Int

-- | Get the number of initial <a>Apply</a> patterns.

-- | Get the number of initial <a>Apply</a> patterns in a clause.

-- | Get the number of common initial <a>Apply</a> patterns in a list of
--   clauses.

-- | Label the pattern variables from left to right using one label for
--   each variable pattern and one for each dot pattern.
class LabelPatVars a b i | b -> i
labelPatVars :: LabelPatVars a b i => a -> State [i] b

-- | Intended, but unpractical due to the absence of type-level lambda, is:
--   <tt>labelPatVars :: f (Pattern' x) -&gt; State [i] (f (Pattern'
--   (i,x)))</tt>
unlabelPatVars :: LabelPatVars a b i => b -> a

-- | Augment pattern variables with their de Bruijn index.
numberPatVars :: LabelPatVars a b Int => Int -> Permutation -> a -> b
unnumberPatVars :: LabelPatVars a b i => b -> a
dbPatPerm :: [NamedArg DeBruijnPattern] -> Maybe Permutation

-- | Computes the permutation from the clause telescope to the pattern
--   variables.
--   
--   Use as <tt>fromMaybe <b>IMPOSSIBLE</b> . dbPatPerm</tt> to crash in a
--   controlled way if a de Bruijn index is out of scope here.
--   
--   The first argument controls whether dot patterns counts as variables
--   or not.
dbPatPerm' :: Bool -> [NamedArg DeBruijnPattern] -> Maybe Permutation

-- | Computes the permutation from the clause telescope to the pattern
--   variables.
--   
--   Use as <tt>fromMaybe <b>IMPOSSIBLE</b> . clausePerm</tt> to crash in a
--   controlled way if a de Bruijn index is out of scope here.
clausePerm :: Clause -> Maybe Permutation

-- | Turn a pattern into a term. Projection patterns are turned into
--   projection eliminations, other patterns into apply elimination.
patternToElim :: Arg DeBruijnPattern -> Elim
patternsToElims :: [NamedArg DeBruijnPattern] -> [Elim]
patternToTerm :: DeBruijnPattern -> Term
class MapNamedArg f
mapNamedArg :: MapNamedArg f => (NamedArg a -> NamedArg b) -> NamedArg (f a) -> NamedArg (f b)
instance Agda.Syntax.Abstract.Name.IsProjP p => Agda.Syntax.Internal.Pattern.FunArity [p]
instance Agda.Syntax.Internal.Pattern.FunArity Agda.Syntax.Internal.Clause
instance Agda.Syntax.Internal.Pattern.FunArity [Agda.Syntax.Internal.Clause]
instance Agda.Syntax.Internal.Pattern.LabelPatVars a b i => Agda.Syntax.Internal.Pattern.LabelPatVars (Agda.Syntax.Common.Arg a) (Agda.Syntax.Common.Arg b) i
instance Agda.Syntax.Internal.Pattern.LabelPatVars a b i => Agda.Syntax.Internal.Pattern.LabelPatVars (Agda.Syntax.Common.Named x a) (Agda.Syntax.Common.Named x b) i
instance Agda.Syntax.Internal.Pattern.LabelPatVars a b i => Agda.Syntax.Internal.Pattern.LabelPatVars [a] [b] i
instance Agda.Syntax.Internal.Pattern.LabelPatVars Agda.Syntax.Internal.Pattern Agda.Syntax.Internal.DeBruijnPattern GHC.Types.Int
instance Agda.Syntax.Internal.Pattern.MapNamedArg Agda.Syntax.Internal.Pattern'


-- | Case trees.
--   
--   After coverage checking, pattern matching is translated to case trees,
--   i.e., a tree of successive case splits on one variable at a time.
module Agda.TypeChecking.CompiledClause
data WithArity c
WithArity :: Int -> c -> WithArity c
[arity] :: WithArity c -> Int
[content] :: WithArity c -> c

-- | Branches in a case tree.
data Case c
Branches :: Bool -> Map QName (WithArity c) -> Map Literal c -> Maybe c -> Case c

-- | We are constructing a record here (copatterns). <a>conBranches</a>
--   lists projections.
[projPatterns] :: Case c -> Bool

-- | Map from constructor (or projection) names to their arity and the case
--   subtree. (Projections have arity 0.)
[conBranches] :: Case c -> Map QName (WithArity c)

-- | Map from literal to case subtree.
[litBranches] :: Case c -> Map Literal c

-- | (Possibly additional) catch-all clause.
[catchAllBranch] :: Case c -> Maybe c

-- | Case tree with bodies.
data CompiledClauses

-- | <tt>Case n bs</tt> stands for a match on the <tt>n</tt>-th argument
--   (counting from zero) with <tt>bs</tt> as the case branches. If the
--   <tt>n</tt>-th argument is a projection, we have only
--   <a>conBranches</a> with arity 0.
Case :: (Arg Int) -> (Case CompiledClauses) -> CompiledClauses

-- | <tt>Done xs b</tt> stands for the body <tt>b</tt> where the
--   <tt>xs</tt> contains hiding and name suggestions for the free
--   variables. This is needed to build lambdas on the right hand side for
--   partial applications which can still reduce.
Done :: [Arg ArgName] -> Term -> CompiledClauses

-- | Absurd case.
Fail :: CompiledClauses
litCase :: Literal -> c -> Case c
conCase :: QName -> WithArity c -> Case c
projCase :: QName -> c -> Case c
catchAll :: c -> Case c

-- | Check whether a case tree has a catch-all clause.
hasCatchAll :: CompiledClauses -> Bool
prettyMap :: (Show k, Pretty v) => Map k v -> [Doc]
instance Data.Traversable.Traversable Agda.TypeChecking.CompiledClause.Case
instance Data.Foldable.Foldable Agda.TypeChecking.CompiledClause.Case
instance GHC.Base.Functor Agda.TypeChecking.CompiledClause.Case
instance Data.Traversable.Traversable Agda.TypeChecking.CompiledClause.WithArity
instance Data.Foldable.Foldable Agda.TypeChecking.CompiledClause.WithArity
instance GHC.Base.Functor Agda.TypeChecking.CompiledClause.WithArity
instance GHC.Base.Monoid c => Data.Semigroup.Semigroup (Agda.TypeChecking.CompiledClause.WithArity c)
instance GHC.Base.Monoid c => GHC.Base.Monoid (Agda.TypeChecking.CompiledClause.WithArity c)
instance GHC.Base.Monoid m => Data.Semigroup.Semigroup (Agda.TypeChecking.CompiledClause.Case m)
instance GHC.Base.Monoid m => GHC.Base.Monoid (Agda.TypeChecking.CompiledClause.Case m)
instance Agda.Utils.Null.Null (Agda.TypeChecking.CompiledClause.Case m)
instance Agda.Utils.Pretty.Pretty a => GHC.Show.Show (Agda.TypeChecking.CompiledClause.Case a)
instance GHC.Show.Show Agda.TypeChecking.CompiledClause.CompiledClauses
instance Agda.Utils.Pretty.Pretty a => Agda.Utils.Pretty.Pretty (Agda.TypeChecking.CompiledClause.WithArity a)
instance Agda.Utils.Pretty.Pretty a => Agda.Utils.Pretty.Pretty (Agda.TypeChecking.CompiledClause.Case a)
instance Agda.Utils.Pretty.Pretty Agda.TypeChecking.CompiledClause.CompiledClauses
instance Agda.Syntax.Position.KillRange c => Agda.Syntax.Position.KillRange (Agda.TypeChecking.CompiledClause.WithArity c)
instance Agda.Syntax.Position.KillRange c => Agda.Syntax.Position.KillRange (Agda.TypeChecking.CompiledClause.Case c)
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.CompiledClause.CompiledClauses


-- | Split tree for transforming pattern clauses into case trees.
--   
--   The coverage checker generates a split tree from the clauses. The
--   clause compiler uses it to transform clauses to case trees.
--   
--   The initial problem is a set of clauses. The root node designates on
--   which argument to split and has subtrees for all the constructors.
--   Splitting continues until there is only a single clause left at each
--   leaf of the split tree.
module Agda.TypeChecking.Coverage.SplitTree
type SplitTree = SplitTree' QName
type SplitTrees = SplitTrees' QName

-- | Abstract case tree shape.
data SplitTree' a

-- | No more splits coming. We are at a single, all-variable clause.
SplittingDone :: Int -> SplitTree' a

-- | The number of variables bound in the clause
[splitBindings] :: SplitTree' a -> Int

-- | A split is necessary.
SplitAt :: Arg Int -> SplitTrees' a -> SplitTree' a

-- | Arg. no to split at.
[splitArg] :: SplitTree' a -> Arg Int

-- | Sub split trees.
[splitTrees] :: SplitTree' a -> SplitTrees' a

-- | Split tree branching. A finite map from constructor names to
--   splittrees A list representation seems appropriate, since we are
--   expecting not so many constructors per data type, and there is no need
--   for random access.
type SplitTrees' a = [(a, SplitTree' a)]
data SplitTreeLabel a
SplitTreeLabel :: Maybe a -> Maybe (Arg Int) -> Maybe Int -> SplitTreeLabel a

-- | <a>Nothing</a> for root of split tree
[lblConstructorName] :: SplitTreeLabel a -> Maybe a
[lblSplitArg] :: SplitTreeLabel a -> Maybe (Arg Int)
[lblBindings] :: SplitTreeLabel a -> Maybe Int

-- | Convert a split tree into a <a>Tree</a> (for printing).
toTree :: SplitTree' a -> Tree (SplitTreeLabel a)
toTrees :: SplitTrees' a -> Forest (SplitTreeLabel a)
instance GHC.Show.Show a => GHC.Show.Show (Agda.TypeChecking.Coverage.SplitTree.SplitTreeLabel a)
instance GHC.Show.Show a => GHC.Show.Show (Agda.TypeChecking.Coverage.SplitTree.SplitTree' a)


-- | Computing the free variables of a term lazily.
--   
--   We implement a reduce (traversal into monoid) over internal syntax for
--   a generic collection (monoid with singletons). This should allow a
--   more efficient test for the presence of a particular variable.
--   
--   Worst-case complexity does not change (i.e. the case when a variable
--   does not occur), but best case-complexity does matter. For instance,
--   see <a>mkAbs</a>: each time we construct a dependent function type, we
--   check it is actually dependent.
--   
--   The distinction between rigid and strongly rigid occurrences comes
--   from: Jason C. Reed, PhD thesis, 2009, page 96 (see also his LFMTP
--   2009 paper)
--   
--   The main idea is that x = t(x) is unsolvable if x occurs strongly
--   rigidly in t. It might have a solution if the occurrence is not
--   strongly rigid, e.g.
--   
--   x = f -&gt; suc (f (x ( y -&gt; k))) has x = f -&gt; suc (f (suc k))
--   
--   <ul>
--   <li><i>Jason C. Reed, PhD thesis, page 106</i></li>
--   </ul>
--   
--   Under coinductive constructors, occurrences are never strongly rigid.
--   Also, function types and lambdas do not establish strong rigidity.
--   Only inductive constructors do so. (See issue 1271).
module Agda.TypeChecking.Free.Lazy
type MetaSet = Set MetaId

-- | Depending on the surrounding context of a variable, it's occurrence
--   can be classified as flexible or rigid, with finer distinctions.
--   
--   The constructors are listed in increasing order (wrt. information
--   content).
data FlexRig

-- | In arguments of metas.
Flexible :: MetaSet -> FlexRig

-- | In arguments to variables and definitions.
WeaklyRigid :: FlexRig

-- | In top position, or only under inductive record constructors.
Unguarded :: FlexRig

-- | Under at least one and only inductive constructors.
StronglyRigid :: FlexRig

-- | <a>FlexRig</a> composition. For accumulating the context of a
--   variable.
--   
--   <a>Flexible</a> is dominant. Once we are under a meta, we are flexible
--   regardless what else comes.
--   
--   <a>WeaklyRigid</a> is next in strength. Destroys strong rigidity.
--   
--   <a>StronglyRigid</a> is still dominant over <a>Unguarded</a>.
--   
--   <a>Unguarded</a> is the unit. It is the top (identity) context.
composeFlexRig :: FlexRig -> FlexRig -> FlexRig

-- | Occurrence of free variables is classified by several dimensions.
--   Currently, we have <a>FlexRig</a> and <a>Relevance</a>.
data VarOcc
VarOcc :: FlexRig -> Relevance -> VarOcc
[varFlexRig] :: VarOcc -> FlexRig
[varRelevance] :: VarOcc -> Relevance

-- | When we extract information about occurrence, we care most about about
--   <a>StronglyRigid</a> <a>Relevant</a> occurrences.
maxVarOcc :: VarOcc -> VarOcc -> VarOcc
topVarOcc :: VarOcc
botVarOcc :: VarOcc
type VarMap = IntMap VarOcc

-- | Where should we skip sorts in free variable analysis?
data IgnoreSorts

-- | Do not skip.
IgnoreNot :: IgnoreSorts

-- | Skip when annotation to a type.
IgnoreInAnnotations :: IgnoreSorts

-- | Skip unconditionally.
IgnoreAll :: IgnoreSorts

-- | The current context.
data FreeEnv c
FreeEnv :: !IgnoreSorts -> !Int -> !FlexRig -> !Relevance -> SingleVar c -> FreeEnv c

-- | Ignore free variables in sorts.
[feIgnoreSorts] :: FreeEnv c -> !IgnoreSorts

-- | Under how many binders have we stepped?
[feBinders] :: FreeEnv c -> !Int

-- | Are we flexible or rigid?
[feFlexRig] :: FreeEnv c -> !FlexRig

-- | What is the current relevance?
[feRelevance] :: FreeEnv c -> !Relevance

-- | Method to return a single variable.
[feSingleton] :: FreeEnv c -> SingleVar c
type Variable = (Int, VarOcc)
type SingleVar c = Variable -> c

-- | The initial context.
initFreeEnv :: SingleVar c -> FreeEnv c
type FreeM c = Reader (FreeEnv c) c

-- | Base case: a variable.
variable :: (Monoid c) => Int -> FreeM c

-- | Going under a binder.
bind :: FreeM a -> FreeM a
bind' :: Nat -> FreeM a -> FreeM a

-- | Changing the <a>FlexRig</a> context.
go :: FlexRig -> FreeM a -> FreeM a

-- | Changing the <a>Relevance</a>.
goRel :: Relevance -> FreeM a -> FreeM a

-- | What happens to the variables occurring under a constructor?
underConstructor :: ConHead -> FreeM a -> FreeM a

-- | Gather free variables in a collection.
class Free' a c
freeVars' :: (Free' a c, Monoid c) => a -> FreeM c
instance GHC.Show.Show Agda.TypeChecking.Free.Lazy.IgnoreSorts
instance GHC.Classes.Eq Agda.TypeChecking.Free.Lazy.IgnoreSorts
instance GHC.Show.Show Agda.TypeChecking.Free.Lazy.VarOcc
instance GHC.Classes.Eq Agda.TypeChecking.Free.Lazy.VarOcc
instance GHC.Show.Show Agda.TypeChecking.Free.Lazy.FlexRig
instance GHC.Classes.Ord Agda.TypeChecking.Free.Lazy.FlexRig
instance GHC.Classes.Eq Agda.TypeChecking.Free.Lazy.FlexRig
instance GHC.Base.Monoid c => Data.Semigroup.Semigroup (Agda.TypeChecking.Free.Lazy.FreeM c)
instance GHC.Base.Monoid c => GHC.Base.Monoid (Agda.TypeChecking.Free.Lazy.FreeM c)
instance Agda.TypeChecking.Free.Lazy.Free' Agda.Syntax.Internal.Term c
instance Agda.TypeChecking.Free.Lazy.Free' a c => Agda.TypeChecking.Free.Lazy.Free' (Agda.Syntax.Internal.Type' a) c
instance Agda.TypeChecking.Free.Lazy.Free' Agda.Syntax.Internal.Sort c
instance Agda.TypeChecking.Free.Lazy.Free' Agda.Syntax.Internal.Level c
instance Agda.TypeChecking.Free.Lazy.Free' Agda.Syntax.Internal.PlusLevel c
instance Agda.TypeChecking.Free.Lazy.Free' Agda.Syntax.Internal.LevelAtom c
instance Agda.TypeChecking.Free.Lazy.Free' a c => Agda.TypeChecking.Free.Lazy.Free' [a] c
instance Agda.TypeChecking.Free.Lazy.Free' a c => Agda.TypeChecking.Free.Lazy.Free' (GHC.Base.Maybe a) c
instance (Agda.TypeChecking.Free.Lazy.Free' a c, Agda.TypeChecking.Free.Lazy.Free' b c) => Agda.TypeChecking.Free.Lazy.Free' (a, b) c
instance Agda.TypeChecking.Free.Lazy.Free' a c => Agda.TypeChecking.Free.Lazy.Free' (Agda.Syntax.Internal.Elim' a) c
instance Agda.TypeChecking.Free.Lazy.Free' a c => Agda.TypeChecking.Free.Lazy.Free' (Agda.Syntax.Common.Arg a) c
instance Agda.TypeChecking.Free.Lazy.Free' a c => Agda.TypeChecking.Free.Lazy.Free' (Agda.Syntax.Common.Dom a) c
instance Agda.TypeChecking.Free.Lazy.Free' a c => Agda.TypeChecking.Free.Lazy.Free' (Agda.Syntax.Internal.Abs a) c
instance Agda.TypeChecking.Free.Lazy.Free' a c => Agda.TypeChecking.Free.Lazy.Free' (Agda.Syntax.Internal.Tele a) c
instance Agda.TypeChecking.Free.Lazy.Free' Agda.Syntax.Internal.Clause c
instance Agda.TypeChecking.Free.Lazy.Free' Agda.Syntax.Internal.EqualityView c


-- | Computing the free variables of a term.
--   
--   This is the old version of '<a>Free'</a>, using <tt>IntSet</tt>s for
--   the separate variable categories. We keep it as a specification.
--   
--   The distinction between rigid and strongly rigid occurrences comes
--   from: Jason C. Reed, PhD thesis, 2009, page 96 (see also his LFMTP
--   2009 paper)
--   
--   The main idea is that x = t(x) is unsolvable if x occurs strongly
--   rigidly in t. It might have a solution if the occurrence is not
--   strongly rigid, e.g.
--   
--   x = f -&gt; suc (f (x ( y -&gt; k))) has x = f -&gt; suc (f (suc k))
--   
--   <ul>
--   <li><i>Jason C. Reed, PhD thesis, page 106</i></li>
--   </ul>
--   
--   Under coinductive constructors, occurrences are never strongly rigid.
--   Also, function types and lambdas do not establish strong rigidity.
--   Only inductive constructors do so. (See issue 1271).
module Agda.TypeChecking.Free.Old

-- | Free variables of a term, (disjointly) partitioned into strongly and
--   and weakly rigid variables, flexible variables and irrelevant
--   variables.
data FreeVars
FV :: VarSet -> VarSet -> VarSet -> VarSet -> VarSet -> VarSet -> FreeVars

-- | Variables under only and at least one inductive constructor(s).
[stronglyRigidVars] :: FreeVars -> VarSet

-- | Variables at top or only under inductive record constructors λs and
--   Πs. The purpose of recording these separately is that they can still
--   become strongly rigid if put under a constructor whereas weakly rigid
--   ones stay weakly rigid.
[unguardedVars] :: FreeVars -> VarSet

-- | Ordinary rigid variables, e.g., in arguments of variables.
[weaklyRigidVars] :: FreeVars -> VarSet

-- | Variables occuring in arguments of metas. These are only potentially
--   free, depending how the meta variable is instantiated.
[flexibleVars] :: FreeVars -> VarSet

-- | Variables in irrelevant arguments and under a <tt>DontCare</tt>, i.e.,
--   in irrelevant positions.
[irrelevantVars] :: FreeVars -> VarSet

-- | Variables in <a>UnusedArg</a>uments.
[unusedVars] :: FreeVars -> VarSet
class Free a

-- | Where should we skip sorts in free variable analysis?
data IgnoreSorts

-- | Do not skip.
IgnoreNot :: IgnoreSorts

-- | Skip when annotation to a type.
IgnoreInAnnotations :: IgnoreSorts

-- | Skip unconditionally.
IgnoreAll :: IgnoreSorts

-- | Doesn't go inside solved metas, but collects the variables from a
--   metavariable application <tt>X ts</tt> as <tt>flexibleVars</tt>.
freeVars :: Free a => a -> FreeVars
freeVarsIgnore :: Free a => IgnoreSorts -> a -> FreeVars

-- | <tt>allVars fv</tt> includes irrelevant variables.
allVars :: FreeVars -> VarSet

-- | All but the irrelevant variables.
relevantVars :: FreeVars -> VarSet

-- | Rigid variables: either strongly rigid, unguarded, or weakly rigid.
rigidVars :: FreeVars -> VarSet
freeIn :: Free a => Nat -> a -> Bool

-- | Is the variable bound by the abstraction actually used?
isBinderUsed :: Free a => Abs a -> Bool
freeInIgnoringSorts :: Free a => Nat -> a -> Bool
freeInIgnoringSortAnn :: Free a => Nat -> a -> Bool
relevantIn :: Free a => Nat -> a -> Bool
relevantInIgnoringSortAnn :: Free a => Nat -> a -> Bool
data Occurrence
NoOccurrence :: Occurrence
Irrelevantly :: Occurrence

-- | Under at least one and only inductive constructors.
StronglyRigid :: Occurrence

-- | In top position, or only under inductive record constructors.
Unguarded :: Occurrence

-- | In arguments to variables and definitions.
WeaklyRigid :: Occurrence

-- | In arguments of metas.
Flexible :: Occurrence
Unused :: Occurrence
occurrence :: Nat -> FreeVars -> Occurrence
instance GHC.Show.Show Agda.TypeChecking.Free.Old.IgnoreSorts
instance GHC.Classes.Eq Agda.TypeChecking.Free.Old.IgnoreSorts
instance GHC.Show.Show Agda.TypeChecking.Free.Old.Occurrence
instance GHC.Classes.Eq Agda.TypeChecking.Free.Old.Occurrence
instance GHC.Show.Show Agda.TypeChecking.Free.Old.FreeVars
instance GHC.Classes.Eq Agda.TypeChecking.Free.Old.FreeVars
instance Data.Semigroup.Semigroup Agda.TypeChecking.Free.Old.FreeVars
instance GHC.Base.Monoid Agda.TypeChecking.Free.Old.FreeVars
instance Data.Semigroup.Semigroup Agda.TypeChecking.Free.Old.FreeT
instance GHC.Base.Monoid Agda.TypeChecking.Free.Old.FreeT
instance Agda.TypeChecking.Free.Old.Free Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Free.Old.Free Agda.Syntax.Internal.Type
instance Agda.TypeChecking.Free.Old.Free Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.Free.Old.Free Agda.Syntax.Internal.Level
instance Agda.TypeChecking.Free.Old.Free Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.Free.Old.Free Agda.Syntax.Internal.LevelAtom
instance Agda.TypeChecking.Free.Old.Free a => Agda.TypeChecking.Free.Old.Free [a]
instance Agda.TypeChecking.Free.Old.Free a => Agda.TypeChecking.Free.Old.Free (GHC.Base.Maybe a)
instance (Agda.TypeChecking.Free.Old.Free a, Agda.TypeChecking.Free.Old.Free b) => Agda.TypeChecking.Free.Old.Free (a, b)
instance Agda.TypeChecking.Free.Old.Free a => Agda.TypeChecking.Free.Old.Free (Agda.Syntax.Internal.Elim' a)
instance Agda.TypeChecking.Free.Old.Free a => Agda.TypeChecking.Free.Old.Free (Agda.Syntax.Common.Arg a)
instance Agda.TypeChecking.Free.Old.Free a => Agda.TypeChecking.Free.Old.Free (Agda.Syntax.Common.Dom a)
instance Agda.TypeChecking.Free.Old.Free a => Agda.TypeChecking.Free.Old.Free (Agda.Syntax.Internal.Abs a)
instance Agda.TypeChecking.Free.Old.Free a => Agda.TypeChecking.Free.Old.Free (Agda.Syntax.Internal.Tele a)
instance Agda.TypeChecking.Free.Old.Free Agda.Syntax.Internal.Clause

module Agda.TypeChecking.Substitute.DeBruijn

-- | Things we can substitute for a variable. Needs to be able to represent
--   variables, e.g. for substituting under binders.
class DeBruijn a where deBruijnVar = debruijnNamedVar underscore debruijnNamedVar _ = deBruijnVar

-- | Produce a variable without name suggestion.
deBruijnVar :: DeBruijn a => Int -> a

-- | Produce a variable with name suggestion.
debruijnNamedVar :: DeBruijn a => String -> Int -> a

-- | Are we dealing with a variable? If yes, what is its index?
deBruijnView :: DeBruijn a => a -> Maybe Int

-- | We can substitute <tt>Term</tt>s for variables.
instance Agda.TypeChecking.Substitute.DeBruijn.DeBruijn Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Substitute.DeBruijn.DeBruijn Agda.Syntax.Internal.LevelAtom
instance Agda.TypeChecking.Substitute.DeBruijn.DeBruijn Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.Substitute.DeBruijn.DeBruijn Agda.Syntax.Internal.Level


-- | Computing the free variables of a term.
--   
--   The distinction between rigid and strongly rigid occurrences comes
--   from: Jason C. Reed, PhD thesis, 2009, page 96 (see also his LFMTP
--   2009 paper)
--   
--   The main idea is that x = t(x) is unsolvable if x occurs strongly
--   rigidly in t. It might have a solution if the occurrence is not
--   strongly rigid, e.g.
--   
--   x = f -&gt; suc (f (x ( y -&gt; k))) has x = f -&gt; suc (f (suc k))
--   
--   <ul>
--   <li><i>Jason C. Reed, PhD thesis, page 106</i></li>
--   </ul>
--   
--   Under coinductive constructors, occurrences are never strongly rigid.
--   Also, function types and lambdas do not establish strong rigidity.
--   Only inductive constructors do so. (See issue 1271).
module Agda.TypeChecking.Free

-- | Free variables of a term, (disjointly) partitioned into strongly and
--   and weakly rigid variables, flexible variables and irrelevant
--   variables.
data FreeVars
FV :: VarSet -> VarSet -> VarSet -> IntMap MetaSet -> VarSet -> VarSet -> FreeVars

-- | Variables under only and at least one inductive constructor(s).
[stronglyRigidVars] :: FreeVars -> VarSet

-- | Variables at top or only under inductive record constructors λs and
--   Πs. The purpose of recording these separately is that they can still
--   become strongly rigid if put under a constructor whereas weakly rigid
--   ones stay weakly rigid.
[unguardedVars] :: FreeVars -> VarSet

-- | Ordinary rigid variables, e.g., in arguments of variables.
[weaklyRigidVars] :: FreeVars -> VarSet

-- | Variables occuring in arguments of metas. These are only potentially
--   free, depending how the meta variable is instantiated. The set
--   contains the id's of the meta variables that this variable is an
--   argument to.
[flexibleVars] :: FreeVars -> IntMap MetaSet

-- | Variables in irrelevant arguments and under a <tt>DontCare</tt>, i.e.,
--   in irrelevant positions.
[irrelevantVars] :: FreeVars -> VarSet

-- | Variables in <a>UnusedArg</a>uments.
[unusedVars] :: FreeVars -> VarSet
type Free a = Free' a Any

-- | Gather free variables in a collection.
class Free' a c
freeVars' :: (Free' a c, Monoid c) => a -> FreeM c
type FreeV a = Free' a FreeVars
type FreeVS a = Free' a VarSet

-- | Where should we skip sorts in free variable analysis?
data IgnoreSorts

-- | Do not skip.
IgnoreNot :: IgnoreSorts

-- | Skip when annotation to a type.
IgnoreInAnnotations :: IgnoreSorts

-- | Skip unconditionally.
IgnoreAll :: IgnoreSorts
runFree :: (Monoid c, Free' a c) => SingleVar c -> IgnoreSorts -> a -> c

-- | Rigid variables: either strongly rigid, unguarded, or weakly rigid.
rigidVars :: FreeVars -> VarSet

-- | All but the irrelevant variables.
relevantVars :: FreeVars -> VarSet

-- | <tt>allVars fv</tt> includes irrelevant variables.
allVars :: FreeVars -> VarSet

-- | Collect all free variables.
allFreeVars :: Free' a VarSet => a -> VarSet

-- | Collect all relevant free variables, excluding the "unused" ones.
allRelevantVars :: Free' a VarSet => a -> VarSet

-- | Collect all relevant free variables, excluding the "unused" ones,
--   possibly ignoring sorts.
allRelevantVarsIgnoring :: Free' a VarSet => IgnoreSorts -> a -> VarSet

-- | Collect all relevant free variables.
allRelevantOrUnusedVars :: Free' a VarSet => a -> VarSet

-- | Collect all relevant free variables, possibly ignoring sorts.
allRelevantOrUnusedVarsIgnoring :: Free' a VarSet => IgnoreSorts -> a -> VarSet
freeIn :: Free a => Nat -> a -> Bool
freeInIgnoringSorts :: Free a => Nat -> a -> Bool

-- | Is the variable bound by the abstraction actually used?
isBinderUsed :: Free a => Abs a -> Bool
relevantIn :: Free a => Nat -> a -> Bool
relevantInIgnoringSortAnn :: Free a => Nat -> a -> Bool
data Occurrence
NoOccurrence :: Occurrence
Irrelevantly :: Occurrence

-- | Under at least one and only inductive constructors.
StronglyRigid :: Occurrence

-- | In top position, or only under inductive record constructors.
Unguarded :: Occurrence

-- | In arguments to variables and definitions.
WeaklyRigid :: Occurrence

-- | In arguments of metas.
Flexible :: MetaSet -> Occurrence
Unused :: Occurrence

-- | Compute an occurrence of a single variable in a piece of internal
--   syntax.
occurrence :: FreeV a => Nat -> a -> Occurrence

-- | Is the term entirely closed (no free variables)?
closed :: Free' a All => a -> Bool

-- | Doesn't go inside solved metas, but collects the variables from a
--   metavariable application <tt>X ts</tt> as <tt>flexibleVars</tt>.
freeVars :: (Monoid c, Singleton Variable c, Free' a c) => a -> c
freeVars' :: (Free' a c, Monoid c) => a -> FreeM c
instance GHC.Show.Show Agda.TypeChecking.Free.Occurrence
instance GHC.Classes.Eq Agda.TypeChecking.Free.Occurrence
instance GHC.Show.Show Agda.TypeChecking.Free.FreeVars
instance GHC.Classes.Eq Agda.TypeChecking.Free.FreeVars
instance Agda.Utils.Null.Null Agda.TypeChecking.Free.FreeVars
instance Data.Semigroup.Semigroup Agda.TypeChecking.Free.FreeVars
instance GHC.Base.Monoid Agda.TypeChecking.Free.FreeVars
instance Agda.Utils.Singleton.Singleton Agda.TypeChecking.Free.Lazy.Variable Agda.TypeChecking.Free.FreeVars

module Agda.TypeChecking.Substitute.Class

-- | Apply something to a bunch of arguments. Preserves blocking tags
--   (application can never resolve blocking).
class Apply t where apply t args = applyE t $ map Apply args applyE t es = apply t $ map argFromElim es
apply :: Apply t => t -> Args -> t
applyE :: Apply t => t -> Elims -> t

-- | Apply to some default arguments.
applys :: Apply t => t -> [Term] -> t

-- | Apply to a single default argument.
apply1 :: Apply t => t -> Term -> t

-- | <tt>(abstract args v) <a>apply</a> args --&gt; v[args]</tt>.
class Abstract t
abstract :: Abstract t => Telescope -> t -> t

-- | 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 <a>Term</a> 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.
--   <tt>substUnder n u == subst n (raise n u)</tt>.
substUnder :: Subst t a => Nat -> t -> a -> a
idS :: Substitution' a
wkS :: Int -> Substitution' a -> Substitution' a
raiseS :: Int -> Substitution' a
consS :: DeBruijn a => a -> Substitution' a -> Substitution' a

-- | To replace index <tt>n</tt> by term <tt>u</tt>, do <tt>applySubst
--   (singletonS n u)</tt>.
singletonS :: DeBruijn a => Int -> a -> Substitution' a

-- | Single substitution without disturbing any deBruijn indices. <tt> Γ,
--   A, Δ ⊢ u : A --------------------------------- </tt>Γ, A, Δ ⊢ inplace
--   |Δ| u : Γ, A, Δ
inplaceS :: Subst a a => Int -> a -> Substitution' a

-- | Lift a substitution under k binders.
liftS :: Int -> Substitution' a -> Substitution' a
dropS :: Int -> Substitution' a -> Substitution' a

-- | <pre>
--   applySubst (ρ <a>composeS</a> σ) v == applySubst ρ (applySubst σ v)
--   </pre>
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

-- | 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
--   <b>IMPOSSIBLE</b> in the case where the variable shouldn't be used but
--   we cannot use <a>noabsApp</a>. 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

-- | <tt>underAbs k a b</tt> applies <tt>k</tt> to <tt>a</tt> and the
--   content of abstraction <tt>b</tt> and puts the abstraction back.
--   <tt>a</tt> is raised if abstraction was proper such that at point of
--   application of <tt>k</tt> and the content of <tt>b</tt> are at the
--   same context. Precondition: <tt>a</tt> and <tt>b</tt> are at the same
--   context at call time.
underAbs :: Subst t a => (a -> b -> b) -> a -> Abs b -> Abs b

-- | <tt>underLambdas n k a b</tt> drops <tt>n</tt> initial <a>Lam</a>s
--   from <tt>b</tt>, performs operation <tt>k</tt> on <tt>a</tt> and the
--   body of <tt>b</tt>, and puts the <a>Lam</a>s back. <tt>a</tt> is
--   raised correctly according to the number of abstractions.
underLambdas :: Subst Term a => Int -> (a -> Term -> Term) -> a -> Term -> Term

module Agda.TypeChecking.Monad.Base
data TCState
TCSt :: !PreScopeState -> !PostScopeState -> !PersistentTCState -> TCState

-- | The state which is frozen after scope checking.
[stPreScopeState] :: TCState -> !PreScopeState

-- | The state which is modified after scope checking.
[stPostScopeState] :: TCState -> !PostScopeState

-- | State which is forever, like a diamond.
[stPersistentState] :: TCState -> !PersistentTCState
class Monad m => ReadTCState m
getTCState :: ReadTCState m => m TCState
data PreScopeState
PreScopeState :: !CompressedFile -> !Signature -> !(Set ModuleName) -> !ModuleToSource -> !VisitedModules -> !ScopeInfo -> !PatternSynDefns -> !PatternSynDefns -> !PragmaOptions -> !(BuiltinThings PrimFun) -> !DisplayForms -> !InstanceTable -> !(Set String) -> !(Set String) -> ![String] -> !InteractionId -> PreScopeState

-- | Highlighting info for tokens (but not those tokens for which
--   highlighting exists in <a>stSyntaxInfo</a>).
[stPreTokens] :: PreScopeState -> !CompressedFile

-- | Imported declared identifiers. Those most not be serialized!
[stPreImports] :: PreScopeState -> !Signature
[stPreImportedModules] :: PreScopeState -> !(Set ModuleName)
[stPreModuleToSource] :: PreScopeState -> !ModuleToSource
[stPreVisitedModules] :: PreScopeState -> !VisitedModules
[stPreScope] :: PreScopeState -> !ScopeInfo

-- | Pattern synonyms of the current file. Serialized.
[stPrePatternSyns] :: PreScopeState -> !PatternSynDefns

-- | Imported pattern synonyms. Must not be serialized!
[stPrePatternSynImports] :: PreScopeState -> !PatternSynDefns

-- | Options applying to the current file. <tt>OPTIONS</tt> pragmas only
--   affect this field.
[stPrePragmaOptions] :: PreScopeState -> !PragmaOptions
[stPreImportedBuiltins] :: PreScopeState -> !(BuiltinThings PrimFun)

-- | Display forms added by someone else to imported identifiers
[stPreImportedDisplayForms] :: PreScopeState -> !DisplayForms
[stPreImportedInstanceDefs] :: PreScopeState -> !InstanceTable

-- | Imports that should be generated by the compiler / MAlonzo (this
--   includes imports from imported modules).
[stPreHaskellImports] :: PreScopeState -> !(Set String)

-- | Imports that should be generated by the compiler / UHC backend (this
--   includes imports from imported modules).
[stPreHaskellImportsUHC] :: PreScopeState -> !(Set String)

-- | Inline Haskell code that should be inserted by the GHC backend
[stPreHaskellCode] :: PreScopeState -> ![String]
[stPreFreshInteractionId] :: PreScopeState -> !InteractionId
type DisambiguatedNames = IntMap QName
data PostScopeState
PostScopeState :: !CompressedFile -> !DisambiguatedNames -> !MetaStore -> !InteractionPoints -> !InteractionPoints -> !Constraints -> !Constraints -> !Bool -> !(Set QName) -> !Signature -> !ModuleParamDict -> !DisplayForms -> !(Maybe ModuleName) -> !TempInstanceTable -> !Statistics -> ![TCWarning] -> !(Map MutualId MutualBlock) -> !(BuiltinThings PrimFun) -> !MetaId -> !MutualId -> !CtxId -> !ProblemId -> !Int -> !NameId -> PostScopeState

-- | Highlighting info.
[stPostSyntaxInfo] :: PostScopeState -> !CompressedFile

-- | Disambiguation carried out by the type checker. Maps position of first
--   name character to disambiguated <tt><a>QName</a></tt> for each
--   <tt><a>AmbiguousQName</a></tt> already passed by the type checker.
[stPostDisambiguatedNames] :: PostScopeState -> !DisambiguatedNames
[stPostMetaStore] :: PostScopeState -> !MetaStore
[stPostInteractionPoints] :: PostScopeState -> !InteractionPoints

-- | Interaction points that have been filled by a give or solve action.
[stPostSolvedInteractionPoints] :: PostScopeState -> !InteractionPoints
[stPostAwakeConstraints] :: PostScopeState -> !Constraints
[stPostSleepingConstraints] :: PostScopeState -> !Constraints

-- | Dirty when a constraint is added, used to prevent pointer update.
--   Currently unused.
[stPostDirty] :: PostScopeState -> !Bool

-- | Definitions to be considered during occurs check. Initialized to the
--   current mutual block before the check. During occurs check, we remove
--   definitions from this set as soon we have checked them.
[stPostOccursCheckDefs] :: PostScopeState -> !(Set QName)

-- | Declared identifiers of the current file. These will be serialized
--   after successful type checking.
[stPostSignature] :: PostScopeState -> !Signature

-- | TODO: can these be moved into the <tt>TCEnv</tt>?
[stPostModuleParameters] :: PostScopeState -> !ModuleParamDict

-- | Display forms we add for imported identifiers
[stPostImportsDisplayForms] :: PostScopeState -> !DisplayForms

-- | The current module is available after it has been type checked.
[stPostCurrentModule] :: PostScopeState -> !(Maybe ModuleName)
[stPostInstanceDefs] :: PostScopeState -> !TempInstanceTable

-- | Counters to collect various statistics about meta variables etc. Only
--   for current file.
[stPostStatistics] :: PostScopeState -> !Statistics
[stPostTCWarnings] :: PostScopeState -> ![TCWarning]
[stPostMutualBlocks] :: PostScopeState -> !(Map MutualId MutualBlock)
[stPostLocalBuiltins] :: PostScopeState -> !(BuiltinThings PrimFun)
[stPostFreshMetaId] :: PostScopeState -> !MetaId
[stPostFreshMutualId] :: PostScopeState -> !MutualId
[stPostFreshCtxId] :: PostScopeState -> !CtxId
[stPostFreshProblemId] :: PostScopeState -> !ProblemId
[stPostFreshInt] :: PostScopeState -> !Int
[stPostFreshNameId] :: PostScopeState -> !NameId

-- | A mutual block of names in the signature.
data MutualBlock
MutualBlock :: MutualInfo -> Set QName -> MutualBlock

-- | The original info of the mutual block.
[mutualInfo] :: MutualBlock -> MutualInfo
[mutualNames] :: MutualBlock -> Set QName

-- | A part of the state which is not reverted when an error is thrown or
--   the state is reset.
data PersistentTCState
PersistentTCSt :: DecodedModules -> CommandLineOptions -> InteractionOutputCallback -> !Benchmark -> !Statistics -> !(Maybe LoadedFileCache) -> PersistentTCState
[stDecodedModules] :: PersistentTCState -> DecodedModules
[stPersistentOptions] :: PersistentTCState -> CommandLineOptions

-- | Callback function to call when there is a response to give to the
--   interactive frontend. See the documentation of
--   <a>InteractionOutputCallback</a>.
[stInteractionOutputCallback] :: PersistentTCState -> InteractionOutputCallback

-- | Structure to track how much CPU time was spent on which Agda phase.
--   Needs to be a strict field to avoid space leaks!
[stBenchmark] :: PersistentTCState -> !Benchmark

-- | Should be strict field.
[stAccumStatistics] :: PersistentTCState -> !Statistics

-- | Cached typechecking state from the last loaded file. Should be Nothing
--   when checking imports.
[stLoadedFileCache] :: PersistentTCState -> !(Maybe LoadedFileCache)
data LoadedFileCache
LoadedFileCache :: !CachedTypeCheckLog -> !CurrentTypeCheckLog -> LoadedFileCache
[lfcCached] :: LoadedFileCache -> !CachedTypeCheckLog
[lfcCurrent] :: LoadedFileCache -> !CurrentTypeCheckLog

-- | A log of what the type checker does and states after the action is
--   completed. The cached version is stored first executed action first.
type CachedTypeCheckLog = [(TypeCheckAction, PostScopeState)]

-- | Like <a>CachedTypeCheckLog</a>, but storing the log for an ongoing
--   type checking of a module. Stored in reverse order (last performed
--   action first).
type CurrentTypeCheckLog = [(TypeCheckAction, PostScopeState)]

-- | A complete log for a module will look like this:
--   
--   <ul>
--   <li><a>Pragmas</a></li>
--   <li><a>EnterSection</a>, entering the main module.</li>
--   <li>'Decl'/'EnterSection'/'LeaveSection', for declarations and nested
--   modules</li>
--   <li><a>LeaveSection</a>, leaving the main module.</li>
--   </ul>
data TypeCheckAction
EnterSection :: !ModuleInfo -> !ModuleName -> ![TypedBindings] -> TypeCheckAction
LeaveSection :: !ModuleName -> TypeCheckAction

-- | Never a Section or ScopeDecl
Decl :: !Declaration -> TypeCheckAction
Pragmas :: !PragmaOptions -> TypeCheckAction

-- | Empty persistent state.
initPersistentState :: PersistentTCState

-- | Empty state of type checker.
initPreScopeState :: PreScopeState
initPostScopeState :: PostScopeState
initState :: TCState
stTokens :: Lens' CompressedFile TCState
stImports :: Lens' Signature TCState
stImportedModules :: Lens' (Set ModuleName) TCState
stModuleToSource :: Lens' ModuleToSource TCState
stVisitedModules :: Lens' VisitedModules TCState
stScope :: Lens' ScopeInfo TCState
stPatternSyns :: Lens' PatternSynDefns TCState
stPatternSynImports :: Lens' PatternSynDefns TCState
stPragmaOptions :: Lens' PragmaOptions TCState
stImportedBuiltins :: Lens' (BuiltinThings PrimFun) TCState
stHaskellImports :: Lens' (Set String) TCState
stHaskellImportsUHC :: Lens' (Set String) TCState
stHaskellCode :: Lens' [String] TCState
stFreshInteractionId :: Lens' InteractionId TCState
stFreshNameId :: Lens' NameId TCState
stSyntaxInfo :: Lens' CompressedFile TCState
stDisambiguatedNames :: Lens' DisambiguatedNames TCState
stMetaStore :: Lens' MetaStore TCState
stInteractionPoints :: Lens' InteractionPoints TCState
stSolvedInteractionPoints :: Lens' InteractionPoints TCState
stAwakeConstraints :: Lens' Constraints TCState
stSleepingConstraints :: Lens' Constraints TCState
stDirty :: Lens' Bool TCState
stOccursCheckDefs :: Lens' (Set QName) TCState
stSignature :: Lens' Signature TCState
stModuleParameters :: Lens' (ModuleParamDict) TCState
stImportsDisplayForms :: Lens' DisplayForms TCState
stImportedDisplayForms :: Lens' DisplayForms TCState
stCurrentModule :: Lens' (Maybe ModuleName) TCState
stImportedInstanceDefs :: Lens' InstanceTable TCState
stInstanceDefs :: Lens' TempInstanceTable TCState
stStatistics :: Lens' Statistics TCState
stTCWarnings :: Lens' [TCWarning] TCState
stMutualBlocks :: Lens' (Map MutualId MutualBlock) TCState
stLocalBuiltins :: Lens' (BuiltinThings PrimFun) TCState
stFreshMetaId :: Lens' MetaId TCState
stFreshMutualId :: Lens' MutualId TCState
stFreshCtxId :: Lens' CtxId TCState
stFreshProblemId :: Lens' ProblemId TCState
stFreshInt :: Lens' Int TCState
stBuiltinThings :: TCState -> BuiltinThings PrimFun
class Enum i => HasFresh i where nextFresh' = succ
freshLens :: HasFresh i => Lens' i TCState
nextFresh' :: HasFresh i => i -> i
nextFresh :: HasFresh i => TCState -> (i, TCState)
fresh :: (HasFresh i, MonadState TCState m) => m i
newtype ProblemId
ProblemId :: Nat -> ProblemId
freshName :: (MonadState TCState m, HasFresh NameId) => Range -> String -> m Name
freshNoName :: (MonadState TCState m, HasFresh NameId) => Range -> m Name
freshNoName_ :: (MonadState TCState m, HasFresh NameId) => m Name

-- | Create a fresh name from <tt>a</tt>.
class FreshName a
freshName_ :: (FreshName a, MonadState TCState m, HasFresh NameId) => a -> m Name

-- | Maps top-level module names to the corresponding source file names.
type ModuleToSource = Map TopLevelModuleName AbsolutePath

-- | Maps source file names to the corresponding top-level module names.
type SourceToModule = Map AbsolutePath TopLevelModuleName

-- | Creates a <a>SourceToModule</a> map based on <a>stModuleToSource</a>.
--   
--   O(n log n).
--   
--   For a single reverse lookup in <a>stModuleToSource</a>, rather use
--   <tt>lookupModuleFromSourse</tt>.
sourceToModule :: TCM SourceToModule

-- | Lookup an <a>AbsolutePath</a> in <a>sourceToModule</a>.
--   
--   O(n).
lookupModuleFromSource :: AbsolutePath -> TCM (Maybe TopLevelModuleName)
data ModuleInfo
ModuleInfo :: Interface -> Bool -> ModuleInfo
[miInterface] :: ModuleInfo -> Interface

-- | <a>True</a> if warnings were encountered when the module was type
--   checked.
[miWarnings] :: ModuleInfo -> Bool
type VisitedModules = Map TopLevelModuleName ModuleInfo
type DecodedModules = Map TopLevelModuleName Interface
data Interface
Interface :: Hash -> [(ModuleName, Hash)] -> ModuleName -> Map ModuleName Scope -> ScopeInfo -> Signature -> DisplayForms -> BuiltinThings (String, QName) -> Set String -> Set String -> [String] -> HighlightingInfo -> [OptionsPragma] -> PatternSynDefns -> Interface

-- | Hash of the source code.
[iSourceHash] :: Interface -> Hash

-- | Imported modules and their hashes.
[iImportedModules] :: Interface -> [(ModuleName, Hash)]

-- | Module name of this interface.
[iModuleName] :: Interface -> ModuleName

-- | Scope defined by this module.
[iScope] :: Interface -> Map ModuleName Scope

-- | Scope after we loaded this interface. Used in <a>AtTopLevel</a> and
--   <a>interactionLoop</a>.
--   
--   Andreas, AIM XX: For performance reason, this field is not serialized,
--   so if you deserialize an interface, <tt>iInsideScope</tt> will be
--   empty. You need to type-check the file to get <tt>iInsideScope</tt>.
[iInsideScope] :: Interface -> ScopeInfo
[iSignature] :: Interface -> Signature

-- | Display forms added for imported identifiers.
[iDisplayForms] :: Interface -> DisplayForms
[iBuiltin] :: Interface -> BuiltinThings (String, QName)

-- | Haskell imports listed in (transitively) imported modules are not
--   included here.
[iHaskellImports] :: Interface -> Set String

-- | Haskell imports listed in (transitively) imported modules are not
--   included here.
[iHaskellImportsUHC] :: Interface -> Set String

-- | Inline Haskell code
[iHaskellCode] :: Interface -> [String]
[iHighlighting] :: Interface -> HighlightingInfo

-- | Pragma options set in the file.
[iPragmaOptions] :: Interface -> [OptionsPragma]
[iPatternSyns] :: Interface -> PatternSynDefns

-- | Combines the source hash and the (full) hashes of the imported
--   modules.
iFullHash :: Interface -> Hash
data Closure a
Closure :: Signature -> TCEnv -> ScopeInfo -> ModuleParamDict -> a -> Closure a
[clSignature] :: Closure a -> Signature
[clEnv] :: Closure a -> TCEnv
[clScope] :: Closure a -> ScopeInfo

-- | Since module parameters are currently stored in <a>TCState</a> not in
--   <a>TCEnv</a>, we save them here. The map contains for each
--   <a>ModuleName</a> <tt>M</tt> with module telescope <tt>Γ_M</tt> a
--   substitution <tt>Γ ⊢ ρ_M : Γ_M</tt> from the current context <tt>Γ =
--   envContext (clEnv)</tt>.
[clModuleParameters] :: Closure a -> ModuleParamDict
[clValue] :: Closure a -> a
buildClosure :: a -> TCM (Closure a)
type Constraints = [ProblemConstraint]
data ProblemConstraint
PConstr :: [ProblemId] -> Closure Constraint -> ProblemConstraint
[constraintProblems] :: ProblemConstraint -> [ProblemId]
[theConstraint] :: ProblemConstraint -> Closure Constraint
data Constraint
ValueCmp :: Comparison -> Type -> Term -> Term -> Constraint
ElimCmp :: [Polarity] -> Type -> Term -> [Elim] -> [Elim] -> Constraint
TypeCmp :: Comparison -> Type -> Type -> Constraint

-- | the two types are for the error message only
TelCmp :: Type -> Type -> Comparison -> Telescope -> Telescope -> Constraint
SortCmp :: Comparison -> Sort -> Sort -> Constraint
LevelCmp :: Comparison -> Level -> Level -> Constraint
UnBlock :: MetaId -> Constraint
Guarded :: Constraint -> ProblemId -> Constraint

-- | The range is the one of the absurd pattern.
IsEmpty :: Range -> Type -> Constraint

-- | Check that the <a>Term</a> is either not a SIZELT or a non-empty
--   SIZELT.
CheckSizeLtSat :: Term -> Constraint

-- | the first argument is the instance argument, the second one is the
--   meta on which the constraint may be blocked on and the third one is
--   the list of candidates (or Nothing if we haven’t determined the list
--   of candidates yet)
FindInScope :: MetaId -> (Maybe MetaId) -> (Maybe [Candidate]) -> Constraint
data Comparison
CmpEq :: Comparison
CmpLeq :: Comparison

-- | An extension of <a>Comparison</a> to <tt>&gt;=</tt>.
data CompareDirection
DirEq :: CompareDirection
DirLeq :: CompareDirection
DirGeq :: CompareDirection

-- | Embed <a>Comparison</a> into <a>CompareDirection</a>.
fromCmp :: Comparison -> CompareDirection

-- | Flip the direction of comparison.
flipCmp :: CompareDirection -> CompareDirection

-- | Turn a <a>Comparison</a> function into a <a>CompareDirection</a>
--   function.
--   
--   Property: <tt>dirToCmp f (fromCmp cmp) = f cmp</tt>
dirToCmp :: (Comparison -> a -> a -> c) -> CompareDirection -> a -> a -> c

-- | A thing tagged with the context it came from.
data Open a
OpenThing :: [CtxId] -> a -> Open a
[openThingCtxIds] :: Open a -> [CtxId]
[openThing] :: Open a -> a
data Local a

-- | Local to a given module, the value should have module parameters as
--   free variables.
Local :: ModuleName -> a -> Local a

-- | Global value, should be closed.
Global :: a -> Local a
isGlobal :: Local a -> Bool

-- | Parametrized since it is used without MetaId when creating a new meta.
data Judgement a
HasType :: a -> Type -> Judgement a
[jMetaId] :: Judgement a -> a
[jMetaType] :: Judgement a -> Type
IsSort :: a -> Type -> Judgement a
[jMetaId] :: Judgement a -> a
[jMetaType] :: Judgement a -> Type
data MetaVariable
MetaVar :: MetaInfo -> MetaPriority -> Permutation -> Judgement MetaId -> MetaInstantiation -> Set Listener -> Frozen -> MetaVariable
[mvInfo] :: MetaVariable -> MetaInfo

-- | some metavariables are more eager to be instantiated
[mvPriority] :: MetaVariable -> MetaPriority

-- | a metavariable doesn't have to depend on all variables in the context,
--   this "permutation" will throw away the ones it does not depend on
[mvPermutation] :: MetaVariable -> Permutation
[mvJudgement] :: MetaVariable -> Judgement MetaId
[mvInstantiation] :: MetaVariable -> MetaInstantiation

-- | meta variables scheduled for eta-expansion but blocked by this one
[mvListeners] :: MetaVariable -> Set Listener

-- | are we past the point where we can instantiate this meta variable?
[mvFrozen] :: MetaVariable -> Frozen
data Listener
EtaExpand :: MetaId -> Listener
CheckConstraint :: Nat -> ProblemConstraint -> Listener

-- | Frozen meta variable cannot be instantiated by unification. This
--   serves to prevent the completion of a definition by its use outside of
--   the current block. (See issues 118, 288, 399).
data Frozen

-- | Do not instantiate.
Frozen :: Frozen
Instantiable :: Frozen
data MetaInstantiation

-- | solved by term (abstracted over some free variables)
InstV :: [Arg String] -> Term -> MetaInstantiation

-- | unsolved
Open :: MetaInstantiation

-- | open, to be instantiated as "implicit from scope"
OpenIFS :: MetaInstantiation

-- | solution blocked by unsolved constraints
BlockedConst :: Term -> MetaInstantiation
PostponedTypeCheckingProblem :: (Closure TypeCheckingProblem) -> (TCM Bool) -> MetaInstantiation
data TypeCheckingProblem
CheckExpr :: Expr -> Type -> TypeCheckingProblem
CheckArgs :: ExpandHidden -> Range -> [NamedArg Expr] -> Type -> Type -> (Args -> Type -> TCM Term) -> TypeCheckingProblem

-- | <tt>(λ (xs : t₀) → e) : t</tt> This is not an instance of
--   <a>CheckExpr</a> as the domain type has already been checked. For
--   example, when checking <tt>(λ (x y : Fin _) → e) : (x : Fin n) →
--   ?</tt> we want to postpone <tt>(λ (y : Fin n) → e) : ?</tt> where
--   <tt>Fin n</tt> is a <a>Type</a> rather than an <a>Expr</a>.
CheckLambda :: (Arg ([WithHiding Name], Maybe Type)) -> Expr -> Type -> TypeCheckingProblem

-- | First argument is computation and the others are hole and goal type
UnquoteTactic :: Term -> Term -> Type -> TypeCheckingProblem

-- | Meta variable priority: When we have an equation between
--   meta-variables, which one should be instantiated?
--   
--   Higher value means higher priority to be instantiated.
newtype MetaPriority
MetaPriority :: Int -> MetaPriority
data RunMetaOccursCheck
RunMetaOccursCheck :: RunMetaOccursCheck
DontRunMetaOccursCheck :: RunMetaOccursCheck

-- | <tt>MetaInfo</tt> is cloned from one meta to the next during pruning.
data MetaInfo
MetaInfo :: Closure Range -> RunMetaOccursCheck -> MetaNameSuggestion -> MetaInfo
[miClosRange] :: MetaInfo -> Closure Range

-- | Run the extended occurs check that goes in definitions?
[miMetaOccursCheck] :: MetaInfo -> RunMetaOccursCheck

-- | Used for printing. <tt>Just x</tt> if meta-variable comes from omitted
--   argument with name <tt>x</tt>.
[miNameSuggestion] :: MetaInfo -> MetaNameSuggestion

-- | Name suggestion for meta variable. Empty string means no suggestion.
type MetaNameSuggestion = String

-- | For printing, we couple a meta with its name suggestion.
data NamedMeta
NamedMeta :: MetaNameSuggestion -> MetaId -> NamedMeta
[nmSuggestion] :: NamedMeta -> MetaNameSuggestion
[nmid] :: NamedMeta -> MetaId
type MetaStore = Map MetaId MetaVariable
normalMetaPriority :: MetaPriority
lowMetaPriority :: MetaPriority
highMetaPriority :: MetaPriority
getMetaInfo :: MetaVariable -> Closure Range
getMetaScope :: MetaVariable -> ScopeInfo
getMetaEnv :: MetaVariable -> TCEnv
getMetaSig :: MetaVariable -> Signature
getMetaRelevance :: MetaVariable -> Relevance

-- | Interaction points are created by the scope checker who sets the
--   range. The meta variable is created by the type checker and then
--   hooked up to the interaction point.
data InteractionPoint
InteractionPoint :: Range -> Maybe MetaId -> IPClause -> InteractionPoint

-- | The position of the interaction point.
[ipRange] :: InteractionPoint -> Range

-- | The meta variable, if any, holding the type etc.
[ipMeta] :: InteractionPoint -> Maybe MetaId

-- | The clause of the interaction point (if any). Used for case splitting.
[ipClause] :: InteractionPoint -> IPClause

-- | Data structure managing the interaction points.
type InteractionPoints = Map InteractionId InteractionPoint

-- | Which clause is an interaction point located in?
data IPClause
IPClause :: QName -> Int -> RHS -> IPClause

-- | The name of the function.
[ipcQName] :: IPClause -> QName

-- | The number of the clause of this function.
[ipcClauseNo] :: IPClause -> Int

-- | The original AST clause rhs.
[ipcClause] :: IPClause -> RHS

-- | The interaction point is not in the rhs of a clause.
IPNoClause :: IPClause
data Signature
Sig :: Sections -> Definitions -> RewriteRuleMap -> Signature
[_sigSections] :: Signature -> Sections
[_sigDefinitions] :: Signature -> Definitions

-- | The rewrite rules defined in this file.
[_sigRewriteRules] :: Signature -> RewriteRuleMap
sigSections :: Lens' Sections Signature
sigDefinitions :: Lens' Definitions Signature
sigRewriteRules :: Lens' RewriteRuleMap Signature
type Sections = Map ModuleName Section
type Definitions = HashMap QName Definition
type RewriteRuleMap = HashMap QName RewriteRules
type DisplayForms = HashMap QName [LocalDisplayForm]
data Section
Section :: Telescope -> Section
[_secTelescope] :: Section -> Telescope
secTelescope :: Lens' Telescope Section
emptySignature :: Signature

-- | A <tt>DisplayForm</tt> is in essence a rewrite rule <tt> q ts --&gt;
--   dt </tt> for a defined symbol (could be a constructor as well)
--   <tt>q</tt>. The right hand side is a <a>DisplayTerm</a> which is used
--   to <tt>reify</tt> to a more readable <a>Syntax</a>.
--   
--   The patterns <tt>ts</tt> are just terms, but <tt>var 0</tt> is
--   interpreted as a hole. Each occurrence of <tt>var 0</tt> is a new hole
--   (pattern var). For each *occurrence* of <tt>var0</tt> the rhs
--   <tt>dt</tt> has a free variable. These are instantiated when matching
--   a display form against a term <tt>q vs</tt> succeeds.
data DisplayForm
Display :: Nat -> Elims -> DisplayTerm -> DisplayForm

-- | Number <tt>n</tt> of free variables in <a>dfRHS</a>.
[dfFreeVars] :: DisplayForm -> Nat

-- | Left hand side patterns, where <tt>var 0</tt> stands for a pattern
--   variable. There should be <tt>n</tt> occurrences of <tt>var0</tt> in
--   <a>dfPats</a>. The <a>ArgInfo</a> is ignored in these patterns.
[dfPats] :: DisplayForm -> Elims

-- | Right hand side, with <tt>n</tt> free variables.
[dfRHS] :: DisplayForm -> DisplayTerm
type LocalDisplayForm = Local DisplayForm

-- | A structured presentation of a <a>Term</a> for reification into
--   <a>Syntax</a>.
data DisplayTerm

-- | <tt>(f vs | ws) es</tt>. The first <a>DisplayTerm</a> is the parent
--   function <tt>f</tt> with its args <tt>vs</tt>. The list of
--   <a>DisplayTerm</a>s are the with expressions <tt>ws</tt>. The
--   <a>Elims</a> are additional arguments <tt>es</tt> (possible in case
--   the with-application is of function type) or projections (if it is of
--   record type).
DWithApp :: DisplayTerm -> [DisplayTerm] -> Elims -> DisplayTerm

-- | <tt>c vs</tt>.
DCon :: ConHead -> ConInfo -> [Arg DisplayTerm] -> DisplayTerm

-- | <tt>d vs</tt>.
DDef :: QName -> [Elim' DisplayTerm] -> DisplayTerm

-- | <tt>.v</tt>.
DDot :: Term -> DisplayTerm

-- | <tt>v</tt>.
DTerm :: Term -> DisplayTerm

-- | By default, we have no display form.
defaultDisplayForm :: QName -> [LocalDisplayForm]
defRelevance :: Definition -> Relevance

-- | Non-linear (non-constructor) first-order pattern.
data NLPat

-- | Matches anything (modulo non-linearity) that only contains bound
--   variables that occur in the given arguments.
PVar :: (Maybe CtxId) -> !Int -> [Arg Int] -> NLPat

-- | Matches anything (e.g. irrelevant terms).
PWild :: NLPat

-- | Matches <tt>f es</tt>
PDef :: QName -> PElims -> NLPat

-- | Matches <tt>λ x → t</tt>
PLam :: ArgInfo -> (Abs NLPat) -> NLPat

-- | Matches <tt>(x : A) → B</tt>
PPi :: (Dom NLPType) -> (Abs NLPType) -> NLPat

-- | Matches <tt>x es</tt> where x is a lambda-bound variable
PBoundVar :: {-# UNPACK #-} !Int -> PElims -> NLPat

-- | Matches the term modulo β (ideally βη).
PTerm :: Term -> NLPat
type PElims = [Elim' NLPat]
data NLPType
NLPType :: NLPat -> NLPat -> NLPType
[nlpTypeLevel] :: NLPType -> NLPat
[nlpTypeUnEl] :: NLPType -> NLPat
type RewriteRules = [RewriteRule]

-- | Rewrite rules can be added independently from function clauses.
data RewriteRule
RewriteRule :: QName -> Telescope -> QName -> PElims -> Term -> Type -> RewriteRule

-- | Name of rewrite rule <tt>q : Γ → f ps ≡ rhs</tt> where <tt>≡</tt> is
--   the rewrite relation.
[rewName] :: RewriteRule -> QName

-- | <tt>Γ</tt>.
[rewContext] :: RewriteRule -> Telescope

-- | <tt>f</tt>.
[rewHead] :: RewriteRule -> QName

-- | <tt>Γ ⊢ ps : t</tt>.
[rewPats] :: RewriteRule -> PElims

-- | <tt>Γ ⊢ rhs : t</tt>.
[rewRHS] :: RewriteRule -> Term

-- | <tt>Γ ⊢ t</tt>.
[rewType] :: RewriteRule -> Type
data Definition
Defn :: ArgInfo -> QName -> Type -> [Polarity] -> [Occurrence] -> [LocalDisplayForm] -> MutualId -> CompiledRepresentation -> Maybe QName -> Bool -> Bool -> Defn -> Definition

-- | Hiding should not be used.
[defArgInfo] :: Definition -> ArgInfo
[defName] :: Definition -> QName

-- | Type of the lifted definition.
[defType] :: Definition -> Type

-- | Variance information on arguments of the definition. Does not include
--   info for dropped parameters to projection(-like) functions and
--   constructors.
[defPolarity] :: Definition -> [Polarity]

-- | Positivity information on arguments of the definition. Does not
--   include info for dropped parameters to projection(-like) functions and
--   constructors.
[defArgOccurrences] :: Definition -> [Occurrence]
[defDisplay] :: Definition -> [LocalDisplayForm]
[defMutual] :: Definition -> MutualId
[defCompiledRep] :: Definition -> CompiledRepresentation

-- | <tt>Just q</tt> when this definition is an instance of class q
[defInstance] :: Definition -> Maybe QName

-- | Has this function been created by a module instantiation?
[defCopy] :: Definition -> Bool

-- | Is the def matched against in a rewrite rule?
[defMatchable] :: Definition -> Bool
[theDef] :: Definition -> Defn
theDefLens :: Lens' Defn Definition

-- | Create a definition with sensible defaults.
defaultDefn :: ArgInfo -> QName -> Type -> Defn -> Definition
type HaskellCode = String
type HaskellType = String
type EpicCode = String
type JSCode = String
data HaskellRepresentation
HsDefn :: HaskellType -> HaskellCode -> HaskellRepresentation
HsType :: HaskellType -> HaskellRepresentation
data HaskellExport
HsExport :: HaskellType -> String -> HaskellExport
data CoreRepresentation

-- | Core code for functions.
CrDefn :: CoreExpr -> CoreRepresentation

-- | Core type for agda type.
CrType :: CoreType -> CoreRepresentation

-- | Core constructor for agda constructor.
CrConstr :: CoreConstr -> CoreRepresentation

-- | Polarity for equality and subtype checking.
data Polarity

-- | monotone
Covariant :: Polarity

-- | antitone
Contravariant :: Polarity

-- | no information (mixed variance)
Invariant :: Polarity

-- | constant
Nonvariant :: Polarity
data CompiledRepresentation
CompiledRep :: Maybe HaskellRepresentation -> Maybe HaskellExport -> Maybe EpicCode -> Maybe JSCode -> Maybe CoreRepresentation -> CompiledRepresentation
[compiledHaskell] :: CompiledRepresentation -> Maybe HaskellRepresentation
[exportHaskell] :: CompiledRepresentation -> Maybe HaskellExport
[compiledEpic] :: CompiledRepresentation -> Maybe EpicCode
[compiledJS] :: CompiledRepresentation -> Maybe JSCode
[compiledCore] :: CompiledRepresentation -> Maybe CoreRepresentation
noCompiledRep :: CompiledRepresentation

-- | Additional information for extended lambdas.
data ExtLamInfo
ExtLamInfo :: Int -> Int -> ExtLamInfo
[extLamNumHidden] :: ExtLamInfo -> Int
[extLamNumNonHid] :: ExtLamInfo -> Int

-- | Additional information for projection <a>Function</a>s.
data Projection
Projection :: Bool -> QName -> Arg QName -> Int -> ProjLams -> Projection

-- | <tt>False</tt> if only projection-like, <tt>True</tt> if record
--   projection.
[projProper] :: Projection -> Bool

-- | The original projection name (current name could be from module
--   application).
[projOrig] :: Projection -> QName

-- | Type projected from. Record type if <tt>projProper = Just{}</tt>. Also
--   stores <tt>ArgInfo</tt> of the principal argument.
[projFromType] :: Projection -> Arg QName

-- | Index of the record argument. Start counting with 1, because 0 means
--   that it is already applied to the record value. This can happen in
--   module instantiation, but then either the record value is <tt>var
--   0</tt>, or <tt>funProjection == Nothing</tt>.
[projIndex] :: Projection -> Int

-- | Term <tt>t</tt> to be be applied to record parameters and record
--   value. The parameters will be dropped. In case of a proper projection,
--   a postfix projection application will be created: <tt>t = pars r -&gt;
--   r .p</tt> (Invariant: the number of abstractions equals
--   <a>projIndex</a>.) In case of a projection-like function, just the
--   function symbol is returned as <a>Def</a>: <tt>t = pars -&gt; f</tt>.
[projLams] :: Projection -> ProjLams

-- | Abstractions to build projection function (dropping parameters).
newtype ProjLams
ProjLams :: [Arg ArgName] -> ProjLams
[getProjLams] :: ProjLams -> [Arg ArgName]

-- | Building the projection function (which drops the parameters).
projDropPars :: Projection -> ProjOrigin -> Term

-- | The info of the principal (record) argument.
projArgInfo :: Projection -> ArgInfo

-- | Should a record type admit eta-equality?
data EtaEquality

-- | User specifed 'eta-equality' or 'no-eta-equality'
Specified :: !Bool -> EtaEquality

-- | Positivity checker inferred whether eta is safe/
Inferred :: !Bool -> EtaEquality
etaEqualityToBool :: EtaEquality -> Bool

-- | Make sure we do not overwrite a user specification.
setEtaEquality :: EtaEquality -> Bool -> EtaEquality
data FunctionFlag

-- | Should calls to this function be normalised at compile-time?
FunStatic :: FunctionFlag

-- | Should calls to this function be inlined by the compiler?
FunInline :: FunctionFlag

-- | Is this function a macro?
FunMacro :: FunctionFlag
data Defn

-- | Postulate.
Axiom :: Defn

-- | Returned by <tt>getConstInfo</tt> if definition is abstract.
AbstractDefn :: Defn
Function :: [Clause] -> Maybe CompiledClauses -> Maybe Compiled -> FunctionInverse -> [QName] -> IsAbstract -> Delayed -> Maybe Projection -> Set FunctionFlag -> Maybe Bool -> Maybe ExtLamInfo -> Maybe QName -> Bool -> Defn
[funClauses] :: Defn -> [Clause]

-- | <a>Nothing</a> while function is still type-checked. <tt>Just cc</tt>
--   after type and coverage checking and translation to case trees.
[funCompiled] :: Defn -> Maybe CompiledClauses

-- | Intermediate representation for compiler backends.
[funTreeless] :: Defn -> Maybe Compiled
[funInv] :: Defn -> FunctionInverse

-- | Mutually recursive functions, <tt>data</tt>s and <tt>record</tt>s.
--   Does not include this function.
[funMutual] :: Defn -> [QName]
[funAbstr] :: Defn -> IsAbstract

-- | Are the clauses of this definition delayed?
[funDelayed] :: Defn -> Delayed

-- | Is it a record projection? If yes, then return the name of the record
--   type and index of the record argument. Start counting with 1, because
--   0 means that it is already applied to the record. (Can happen in
--   module instantiation.) This information is used in the termination
--   checker.
[funProjection] :: Defn -> Maybe Projection
[funFlags] :: Defn -> Set FunctionFlag

-- | Has this function been termination checked? Did it pass?
[funTerminates] :: Defn -> Maybe Bool

-- | Is this function generated from an extended lambda? If yes, then
--   return the number of hidden and non-hidden lambda-lifted arguments
[funExtLam] :: Defn -> Maybe ExtLamInfo

-- | Is this a generated with-function? If yes, then what's the name of the
--   parent function.
[funWith] :: Defn -> Maybe QName

-- | Is this a function defined by copatterns?
[funCopatternLHS] :: Defn -> Bool
Datatype :: Nat -> Permutation -> Drop Permutation -> Nat -> Induction -> (Maybe Clause) -> [QName] -> Sort -> [QName] -> IsAbstract -> Defn

-- | Number of parameters.
[dataPars] :: Defn -> Nat

-- | Parameters that are maybe small.
[dataSmallPars] :: Defn -> Permutation

-- | Parameters that appear in indices.
[dataNonLinPars] :: Defn -> Drop Permutation

-- | Number of indices.
[dataIxs] :: Defn -> Nat

-- | <tt>data</tt> or <tt>codata</tt> (legacy).
[dataInduction] :: Defn -> Induction

-- | This might be in an instantiated module.
[dataClause] :: Defn -> (Maybe Clause)

-- | Constructor names.
[dataCons] :: Defn -> [QName]
[dataSort] :: Defn -> Sort

-- | Mutually recursive functions, <tt>data</tt>s and <tt>record</tt>s.
--   Does not include this data type.
[dataMutual] :: Defn -> [QName]
[dataAbstr] :: Defn -> IsAbstract
Record :: Nat -> Maybe Clause -> ConHead -> Bool -> [Arg QName] -> Telescope -> [QName] -> EtaEquality -> Maybe Induction -> Bool -> IsAbstract -> Defn

-- | Number of parameters.
[recPars] :: Defn -> Nat
[recClause] :: Defn -> Maybe Clause

-- | Constructor name and fields.
[recConHead] :: Defn -> ConHead
[recNamedCon] :: Defn -> Bool
[recFields] :: Defn -> [Arg QName]

-- | The record field telescope. (Includes record parameters.) Note:
--   <tt>TelV recTel _ == telView' recConType</tt>. Thus, <tt>recTel</tt>
--   is redundant.
[recTel] :: Defn -> Telescope

-- | Mutually recursive functions, <tt>data</tt>s and <tt>record</tt>s.
--   Does not include this record.
[recMutual] :: Defn -> [QName]

-- | Eta-expand at this record type. <tt>False</tt> for unguarded recursive
--   records and coinductive records unless the user specifies otherwise.
[recEtaEquality'] :: Defn -> EtaEquality

-- | <a>Inductive</a> or <a>CoInductive</a>? Matters only for recursive
--   records. <a>Nothing</a> means that the user did not specify it, which
--   is an error for recursive records.
[recInduction] :: Defn -> Maybe Induction

-- | Recursive record. Infers <tt>recEtaEquality = False</tt>. Projections
--   are not size-preserving.
[recRecursive] :: Defn -> Bool
[recAbstr] :: Defn -> IsAbstract
Constructor :: Nat -> ConHead -> QName -> IsAbstract -> Induction -> [Bool] -> Defn

-- | Number of parameters.
[conPars] :: Defn -> Nat

-- | Name of (original) constructor and fields. (This might be in a module
--   instance.)
[conSrcCon] :: Defn -> ConHead

-- | Name of datatype or record type.
[conData] :: Defn -> QName
[conAbstr] :: Defn -> IsAbstract

-- | Inductive or coinductive?
[conInd] :: Defn -> Induction

-- | Which arguments are erased at runtime (computed during compilation to
--   treeless)
[conErased] :: Defn -> [Bool]

-- | Primitive or builtin functions.
Primitive :: IsAbstract -> String -> [Clause] -> Maybe CompiledClauses -> Defn
[primAbstr] :: Defn -> IsAbstract
[primName] :: Defn -> String

-- | <a>null</a> for primitive functions, <tt>not null</tt> for builtin
--   functions.
[primClauses] :: Defn -> [Clause]

-- | <a>Nothing</a> for primitive functions, <tt><a>Just</a> something</tt>
--   for builtin functions.
[primCompiled] :: Defn -> Maybe CompiledClauses
recEtaEquality :: Defn -> Bool

-- | A template for creating <a>Function</a> definitions, with sensible
--   defaults.
emptyFunction :: Defn
funFlag :: FunctionFlag -> Lens' Bool Defn
funStatic :: Lens' Bool Defn
funInline :: Lens' Bool Defn
funMacro :: Lens' Bool Defn
isMacro :: Defn -> Bool

-- | Checking whether we are dealing with a function yet to be defined.
isEmptyFunction :: Defn -> Bool
isCopatternLHS :: [Clause] -> Bool
recCon :: Defn -> QName
defIsRecord :: Defn -> Bool
defIsDataOrRecord :: Defn -> Bool
newtype Fields
Fields :: [(Name, Type)] -> Fields

-- | Did we encounter a simplifying reduction? In terms of CIC, that would
--   be a iota-reduction. In terms of Agda, this is a constructor or
--   literal pattern that matched. Just beta-reduction (substitution) or
--   delta-reduction (unfolding of definitions) does not count as
--   simplifying?
data Simplification
YesSimplification :: Simplification
NoSimplification :: Simplification
data Reduced no yes
NoReduction :: no -> Reduced no yes
YesReduction :: Simplification -> yes -> Reduced no yes

-- | Three cases: 1. not reduced, 2. reduced, but blocked, 3. reduced, not
--   blocked.
data IsReduced
NotReduced :: IsReduced
Reduced :: (Blocked ()) -> IsReduced
data MaybeReduced a
MaybeRed :: IsReduced -> a -> MaybeReduced a
[isReduced] :: MaybeReduced a -> IsReduced
[ignoreReduced] :: MaybeReduced a -> a
type MaybeReducedArgs = [MaybeReduced (Arg Term)]
type MaybeReducedElims = [MaybeReduced Elim]
notReduced :: a -> MaybeReduced a
reduced :: Blocked (Arg Term) -> MaybeReduced (Arg Term)

-- | Controlling <tt>reduce</tt>.
data AllowedReduction

-- | (Projection and) projection-like functions may be reduced.
ProjectionReductions :: AllowedReduction

-- | Functions marked INLINE may be reduced.
InlineReductions :: AllowedReduction

-- | Copattern definitions may be reduced.
CopatternReductions :: AllowedReduction

-- | Functions which are not projections may be reduced.
FunctionReductions :: AllowedReduction

-- | Reduce <tt><a>Level</a></tt> terms.
LevelReductions :: AllowedReduction

-- | Functions that have not passed termination checking.
NonTerminatingReductions :: AllowedReduction
type AllowedReductions = [AllowedReduction]

-- | Not quite all reductions (skip non-terminating reductions)
allReductions :: AllowedReductions
data PrimFun
PrimFun :: QName -> Arity -> ([Arg Term] -> ReduceM (Reduced MaybeReducedArgs Term)) -> PrimFun
[primFunName] :: PrimFun -> QName
[primFunArity] :: PrimFun -> Arity
[primFunImplementation] :: PrimFun -> [Arg Term] -> ReduceM (Reduced MaybeReducedArgs Term)
defClauses :: Definition -> [Clause]
defCompiled :: Definition -> Maybe CompiledClauses
defParameters :: Definition -> Maybe Nat
defJSDef :: Definition -> Maybe JSCode
defEpicDef :: Definition -> Maybe EpicCode
defCoreDef :: Definition -> Maybe CoreRepresentation

-- | Are the clauses of this definition delayed?
defDelayed :: Definition -> Delayed

-- | Has the definition failed the termination checker?
defNonterminating :: Definition -> Bool
defAbstract :: Definition -> IsAbstract
type FunctionInverse = FunctionInverse' Clause
data FunctionInverse' c
NotInjective :: FunctionInverse' c
Inverse :: (Map TermHead c) -> FunctionInverse' c
data TermHead
SortHead :: TermHead
PiHead :: TermHead
ConsHead :: QName -> TermHead
newtype MutualId
MutId :: Int32 -> MutualId
type Statistics = Map String Integer
data Call
CheckClause :: Type -> SpineClause -> Call
CheckPattern :: Pattern -> Telescope -> Type -> Call
CheckLetBinding :: LetBinding -> Call
InferExpr :: Expr -> Call
CheckExprCall :: Expr -> Type -> Call
CheckDotPattern :: Expr -> Term -> Call
CheckPatternShadowing :: SpineClause -> Call
CheckProjection :: Range -> QName -> Type -> Call
IsTypeCall :: Expr -> Sort -> Call
IsType_ :: Expr -> Call
InferVar :: Name -> Call
InferDef :: QName -> Call
CheckArguments :: Range -> [NamedArg Expr] -> Type -> Type -> Call
CheckDataDef :: Range -> Name -> [LamBinding] -> [Constructor] -> Call
CheckRecDef :: Range -> Name -> [LamBinding] -> [Constructor] -> Call
CheckConstructor :: QName -> Telescope -> Sort -> Constructor -> Call
CheckFunDef :: Range -> Name -> [Clause] -> Call
CheckPragma :: Range -> Pragma -> Call
CheckPrimitive :: Range -> Name -> Expr -> Call
CheckIsEmpty :: Range -> Type -> Call
CheckWithFunctionType :: Expr -> Call
CheckSectionApplication :: Range -> ModuleName -> ModuleApplication -> Call
ScopeCheckExpr :: Expr -> Call
ScopeCheckDeclaration :: NiceDeclaration -> Call
ScopeCheckLHS :: QName -> Pattern -> Call
NoHighlighting :: Call

-- | Interaction command: show module contents.
ModuleContents :: Call

-- | used by <tt>setCurrentRange</tt>
SetRange :: Range -> Call

-- | The instance table is a <tt>Map</tt> associating to every name of
--   record<i>data type</i>postulate its list of instances
type InstanceTable = Map QName (Set QName)

-- | When typechecking something of the following form:
--   
--   instance x : _ x = y
--   
--   it's not yet known where to add <tt>x</tt>, so we add it to a list of
--   unresolved instances and we'll deal with it later.
type TempInstanceTable = (InstanceTable, Set QName)
data BuiltinDescriptor
BuiltinData :: (TCM Type) -> [String] -> BuiltinDescriptor
BuiltinDataCons :: (TCM Type) -> BuiltinDescriptor
BuiltinPrim :: String -> (Term -> TCM ()) -> BuiltinDescriptor
BuiltinPostulate :: Relevance -> (TCM Type) -> BuiltinDescriptor

-- | Builtin of any kind. Type can be checked (<tt>Just t</tt>) or inferred
--   (<tt>Nothing</tt>). The second argument is the hook for the
--   verification function.
BuiltinUnknown :: (Maybe (TCM Type)) -> (Term -> Type -> TCM ()) -> BuiltinDescriptor
data BuiltinInfo
BuiltinInfo :: String -> BuiltinDescriptor -> BuiltinInfo
[builtinName] :: BuiltinInfo -> String
[builtinDesc] :: BuiltinInfo -> BuiltinDescriptor
type BuiltinThings pf = Map String (Builtin pf)
data Builtin pf
Builtin :: Term -> Builtin pf
Prim :: pf -> Builtin pf

-- | How much highlighting should be sent to the user interface?
data HighlightingLevel
None :: HighlightingLevel
NonInteractive :: HighlightingLevel

-- | This includes both non-interactive highlighting and interactive
--   highlighting of the expression that is currently being type-checked.
Interactive :: HighlightingLevel

-- | How should highlighting be sent to the user interface?
data HighlightingMethod

-- | Via stdout.
Direct :: HighlightingMethod

-- | Both via files and via stdout.
Indirect :: HighlightingMethod

-- | <tt>ifTopLevelAndHighlightingLevelIs l m</tt> runs <tt>m</tt> when
--   we're type-checking the top-level module and the highlighting level is
--   <i>at least</i> <tt>l</tt>.
ifTopLevelAndHighlightingLevelIs :: MonadTCM tcm => HighlightingLevel -> tcm () -> tcm ()
data ModuleParameters
ModuleParams :: Substitution -> ModuleParameters

-- | <tt>Δ ⊢ σ : Γ</tt> for a <tt>module M Γ</tt> where <tt>Δ</tt> is the
--   current context <tt>envContext</tt>.
[mpSubstitution] :: ModuleParameters -> Substitution
defaultModuleParameters :: ModuleParameters
type ModuleParamDict = Map ModuleName ModuleParameters  The map contains for each 'ModuleName' @M@ with module telescope @Γ_M@ a substitution @Γ ⊢ ρ_M : Γ_M@ from the current context @Γ = envContext (clEnv)@.
data TCEnv
TCEnv :: Context -> LetBindings -> ModuleName -> Maybe AbsolutePath -> [(ModuleName, Nat)] -> [TopLevelModuleName] -> Maybe MutualId -> TerminationCheck () -> Bool -> Bool -> Bool -> [ProblemId] -> AbstractMode -> Relevance -> Bool -> Range -> Range -> IPClause -> Maybe (Closure Call) -> HighlightingLevel -> HighlightingMethod -> !Int -> Bool -> ExpandHidden -> Maybe QName -> Simplification -> AllowedReductions -> Bool -> Bool -> Bool -> Bool -> UnquoteFlags -> !Int -> TCEnv
[envContext] :: TCEnv -> Context
[envLetBindings] :: TCEnv -> LetBindings
[envCurrentModule] :: TCEnv -> ModuleName

-- | The path to the file that is currently being type-checked.
--   <a>Nothing</a> if we do not have a file (like in interactive mode see
--   <tt>CommandLine</tt>).
[envCurrentPath] :: TCEnv -> Maybe AbsolutePath

-- | anonymous modules and their number of free variables
[envAnonymousModules] :: TCEnv -> [(ModuleName, Nat)]

-- | to detect import cycles
[envImportPath] :: TCEnv -> [TopLevelModuleName]

-- | the current (if any) mutual block
[envMutualBlock] :: TCEnv -> Maybe MutualId

-- | are we inside the scope of a termination pragma
[envTerminationCheck] :: TCEnv -> TerminationCheck ()

-- | Are we currently in the process of solving active constraints?
[envSolvingConstraints] :: TCEnv -> Bool

-- | Have we stepped into the where-declarations of a clause? Everything
--   under a <tt>where</tt> will be checked with this flag on.
[envCheckingWhere] :: TCEnv -> Bool

-- | Are we allowed to assign metas?
[envAssignMetas] :: TCEnv -> Bool
[envActiveProblems] :: TCEnv -> [ProblemId]

-- | When checking the typesignature of a public definition or the body of
--   a non-abstract definition this is true. To prevent information about
--   abstract things leaking outside the module.
[envAbstractMode] :: TCEnv -> AbstractMode

-- | Are we checking an irrelevant argument? (=<tt>Irrelevant</tt>) Then
--   top-level irrelevant declarations are enabled. Other value:
--   <tt>Relevant</tt>, then only relevant decls. are avail.
[envRelevance] :: TCEnv -> Relevance

-- | Sometimes we want to disable display forms.
[envDisplayFormsEnabled] :: TCEnv -> Bool
[envRange] :: TCEnv -> Range

-- | Interactive highlighting uses this range rather than <a>envRange</a>.
[envHighlightingRange] :: TCEnv -> Range

-- | What is the current clause we are type-checking? Will be recorded in
--   interaction points in this clause.
[envClause] :: TCEnv -> IPClause

-- | what we're doing at the moment
[envCall] :: TCEnv -> Maybe (Closure Call)

-- | Set to <a>None</a> when imported modules are type-checked.
[envHighlightingLevel] :: TCEnv -> HighlightingLevel
[envHighlightingMethod] :: TCEnv -> HighlightingMethod

-- | This number indicates how far away from the top-level module Agda has
--   come when chasing modules. The level of a given module is not
--   necessarily the same as the length, in the module dependency graph, of
--   the shortest path from the top-level module; it depends on in which
--   order Agda chooses to chase dependencies.
[envModuleNestingLevel] :: TCEnv -> !Int

-- | When True, allows destructively shared updating terms during
--   evaluation or unification. This is disabled when doing speculative
--   checking, like solve instance metas, or when updating might break
--   abstraction, as is the case when checking abstract definitions.
[envAllowDestructiveUpdate] :: TCEnv -> Bool

-- | When type-checking an alias f=e, we do not want to insert hidden
--   arguments in the end, because these will become unsolved metas.
[envExpandLast] :: TCEnv -> ExpandHidden

-- | We are reducing an application of this function. (For debugging of
--   incomplete matches only.)
[envAppDef] :: TCEnv -> Maybe QName

-- | Did we encounter a simplification (proper match) during the current
--   reduction process?
[envSimplification] :: TCEnv -> Simplification
[envAllowedReductions] :: TCEnv -> AllowedReductions

-- | Can we compare blocked things during conversion? No by default. Yes
--   for rewriting feature.
[envCompareBlocked] :: TCEnv -> Bool

-- | When <tt>True</tt>, types will be omitted from printed pi types if
--   they can be inferred.
[envPrintDomainFreePi] :: TCEnv -> Bool

-- | When <tt>True</tt>, throw away meta numbers and meta elims. This is
--   used for reifying terms for feeding into the user's source code, e.g.,
--   for the interaction tactics <tt>solveAll</tt>.
[envPrintMetasBare] :: TCEnv -> Bool

-- | Used by the scope checker to make sure that certain forms of
--   expressions are not used inside dot patterns: extended lambdas and
--   let-expressions.
[envInsideDotPattern] :: TCEnv -> Bool
[envUnquoteFlags] :: TCEnv -> UnquoteFlags

-- | Until we get a termination checker for instance search (#1743) we
--   limit the search depth to ensure termination.
[envInstanceDepth] :: TCEnv -> !Int
initEnv :: TCEnv
disableDestructiveUpdate :: TCM a -> TCM a
data UnquoteFlags
UnquoteFlags :: Bool -> UnquoteFlags
[_unquoteNormalise] :: UnquoteFlags -> Bool
defaultUnquoteFlags :: UnquoteFlags
unquoteNormalise :: Lens' Bool UnquoteFlags
eUnquoteNormalise :: Lens' Bool TCEnv
eContext :: Lens' Context TCEnv
eLetBindings :: Lens' LetBindings TCEnv
eCurrentModule :: Lens' ModuleName TCEnv
eCurrentPath :: Lens' (Maybe AbsolutePath) TCEnv
eAnonymousModules :: Lens' [(ModuleName, Nat)] TCEnv
eImportPath :: Lens' [TopLevelModuleName] TCEnv
eMutualBlock :: Lens' (Maybe MutualId) TCEnv
eTerminationCheck :: Lens' (TerminationCheck ()) TCEnv
eSolvingConstraints :: Lens' Bool TCEnv
eCheckingWhere :: Lens' Bool TCEnv
eAssignMetas :: Lens' Bool TCEnv
eActiveProblems :: Lens' [ProblemId] TCEnv
eAbstractMode :: Lens' AbstractMode TCEnv
eRelevance :: Lens' Relevance TCEnv
eDisplayFormsEnabled :: Lens' Bool TCEnv
eRange :: Lens' Range TCEnv
eHighlightingRange :: Lens' Range TCEnv
eCall :: Lens' (Maybe (Closure Call)) TCEnv
eHighlightingLevel :: Lens' HighlightingLevel TCEnv
eHighlightingMethod :: Lens' HighlightingMethod TCEnv
eModuleNestingLevel :: Lens' Int TCEnv
eAllowDestructiveUpdate :: Lens' Bool TCEnv
eExpandLast :: Lens' ExpandHidden TCEnv
eAppDef :: Lens' (Maybe QName) TCEnv
eSimplification :: Lens' Simplification TCEnv
eAllowedReductions :: Lens' AllowedReductions TCEnv
eCompareBlocked :: Lens' Bool TCEnv
ePrintDomainFreePi :: Lens' Bool TCEnv
eInsideDotPattern :: Lens' Bool TCEnv
eUnquoteFlags :: Lens' UnquoteFlags TCEnv
eInstanceDepth :: Lens' Int TCEnv

-- | The <tt>Context</tt> is a stack of <a>ContextEntry</a>s.
type Context = [ContextEntry]
data ContextEntry
Ctx :: CtxId -> Dom (Name, Type) -> ContextEntry
[ctxId] :: ContextEntry -> CtxId
[ctxEntry] :: ContextEntry -> Dom (Name, Type)
newtype CtxId
CtxId :: Nat -> CtxId
type LetBindings = Map Name (Open (Term, Dom Type))
data AbstractMode

-- | Abstract things in the current module can be accessed.
AbstractMode :: AbstractMode

-- | No abstract things can be accessed.
ConcreteMode :: AbstractMode

-- | All abstract things can be accessed.
IgnoreAbstractMode :: AbstractMode
aDefToMode :: IsAbstract -> AbstractMode
aModeToDef :: AbstractMode -> IsAbstract
data ExpandHidden

-- | Add implicit arguments in the end until type is no longer hidden
--   <a>Pi</a>.
ExpandLast :: ExpandHidden

-- | Do not append implicit arguments.
DontExpandLast :: ExpandHidden
data ExplicitToInstance

-- | Explicit arguments are considered as instance arguments
ExplicitToInstance :: ExplicitToInstance
ExplicitStayExplicit :: ExplicitToInstance

-- | A candidate solution for an instance meta is a term with its type. It
--   may be the case that the candidate is not fully applied yet or of the
--   wrong type, hence the need for the type.
data Candidate
Candidate :: Term -> Type -> ExplicitToInstance -> Bool -> Candidate
[candidateTerm] :: Candidate -> Term
[candidateType] :: Candidate -> Type
[candidateEti] :: Candidate -> ExplicitToInstance
[candidateOverlappable] :: Candidate -> Bool

-- | A non-fatal error is an error which does not prevent us from checking
--   the document further and interacting with the user.
data Warning
TerminationIssue :: [TerminationError] -> Warning
NotStrictlyPositive :: QName -> OccursWhere -> Warning

-- | Do not use directly with <a>warning</a>
UnsolvedMetaVariables :: [Range] -> Warning

-- | Do not use directly with <a>warning</a>
UnsolvedInteractionMetas :: [Range] -> Warning

-- | Do not use directly with <a>warning</a>
UnsolvedConstraints :: Constraints -> Warning

-- | In `OldBuiltin old new`, the BUILTIN old has been replaced by new
OldBuiltin :: String -> String -> Warning

-- | If the user wrote just <tt>{--}</tt>.
EmptyRewritePragma :: Warning
ParseWarning :: ParseWarning -> Warning
data TCWarning
TCWarning :: TCState -> Closure Warning -> TCWarning

-- | The state in which the warning was raised.
[tcWarningState] :: TCWarning -> TCState

-- | The warning and the environment in which it was raised.
[tcWarningClosure] :: TCWarning -> Closure Warning
tcWarning :: TCWarning -> Warning

-- | Information about a call.
data CallInfo
CallInfo :: QName -> Range -> Closure Term -> CallInfo

-- | Target function name.
[callInfoTarget] :: CallInfo -> QName

-- | Range of the target function.
[callInfoRange] :: CallInfo -> Range

-- | To be formatted representation of the call.
[callInfoCall] :: CallInfo -> Closure Term

-- | We only <a>show</a> the name of the callee.

-- | Information about a mutual block which did not pass the termination
--   checker.
data TerminationError
TerminationError :: [QName] -> [CallInfo] -> TerminationError

-- | The functions which failed to check. (May not include automatically
--   generated functions.)
[termErrFunctions] :: TerminationError -> [QName]

-- | The problematic call sites.
[termErrCalls] :: TerminationError -> [CallInfo]

-- | Error when splitting a pattern variable into possible constructor
--   patterns.
data SplitError

-- | Neither data type nor record.
NotADatatype :: (Closure Type) -> SplitError

-- | Data type, but in irrelevant position.
IrrelevantDatatype :: (Closure Type) -> SplitError

-- | Split on codata not allowed. UNUSED, but keep! -- |
--   NoRecordConstructor Type -- ^ record type, but no constructor
CoinductiveDatatype :: (Closure Type) -> SplitError
CantSplit :: QName -> Telescope -> Args -> Args -> SplitError

-- | Constructor.
[cantSplitConName] :: SplitError -> QName

-- | Context for indices.
[cantSplitTel] :: SplitError -> Telescope

-- | Inferred indices (from type of constructor).
[cantSplitConIdx] :: SplitError -> Args

-- | Expected indices (from checking pattern).
[cantSplitGivenIdx] :: SplitError -> Args
GenericSplitError :: String -> SplitError
data UnquoteError
BadVisibility :: String -> (Arg Term) -> UnquoteError
ConInsteadOfDef :: QName -> String -> String -> UnquoteError
DefInsteadOfCon :: QName -> String -> String -> UnquoteError
NonCanonical :: String -> Term -> UnquoteError
BlockedOnMeta :: TCState -> MetaId -> UnquoteError
UnquotePanic :: String -> UnquoteError
data TypeError
InternalError :: String -> TypeError
NotImplemented :: String -> TypeError
NotSupported :: String -> TypeError
CompilationError :: String -> TypeError
TerminationCheckFailed :: [TerminationError] -> TypeError
PropMustBeSingleton :: TypeError
DataMustEndInSort :: Term -> TypeError

-- | The target of a constructor isn't an application of its datatype. The
--   <a>Type</a> records what it does target.
ShouldEndInApplicationOfTheDatatype :: Type -> TypeError

-- | The target of a constructor isn't its datatype applied to something
--   that isn't the parameters. First term is the correct target and the
--   second term is the actual target.
ShouldBeAppliedToTheDatatypeParameters :: Term -> Term -> TypeError

-- | Expected a type to be an application of a particular datatype.
ShouldBeApplicationOf :: Type -> QName -> TypeError

-- | constructor, datatype
ConstructorPatternInWrongDatatype :: QName -> QName -> TypeError

-- | Indices.
IndicesNotConstructorApplications :: [Arg Term] -> TypeError

-- | Variables, indices.
IndexVariablesNotDistinct :: [Nat] -> [Arg Term] -> TypeError

-- | Indices (variables), index expressions (with constructors applied to
--   reconstructed parameters), parameters.
IndicesFreeInParameters :: [Nat] -> [Arg Term] -> [Arg Term] -> TypeError

-- | Datatype, constructors.
CantResolveOverloadedConstructorsTargetingSameDatatype :: QName -> [QName] -> TypeError

-- | constructor, type
DoesNotConstructAnElementOf :: QName -> Type -> TypeError

-- | Varying number of arguments for a function.
DifferentArities :: TypeError

-- | The left hand side of a function definition has a hidden argument
--   where a non-hidden was expected.
WrongHidingInLHS :: TypeError

-- | Expected a non-hidden function and found a hidden lambda.
WrongHidingInLambda :: Type -> TypeError

-- | A function is applied to a hidden argument where a non-hidden was
--   expected.
WrongHidingInApplication :: Type -> TypeError

-- | A function is applied to a hidden named argument it does not have.
WrongNamedArgument :: (NamedArg Expr) -> TypeError

-- | Expected a relevant function and found an irrelevant lambda.
WrongIrrelevanceInLambda :: Type -> TypeError

-- | A term is declared as an instance but it’s not allowed
WrongInstanceDeclaration :: TypeError

-- | The given hiding does not correspond to the expected hiding.
HidingMismatch :: Hiding -> Hiding -> TypeError

-- | The given relevance does not correspond to the expected relevane.
RelevanceMismatch :: Relevance -> Relevance -> TypeError

-- | The term does not correspond to an inductive data type.
NotInductive :: Term -> TypeError
UninstantiatedDotPattern :: Expr -> TypeError
IlltypedPattern :: Pattern -> Type -> TypeError
IllformedProjectionPattern :: Pattern -> TypeError
CannotEliminateWithPattern :: (NamedArg Pattern) -> Type -> TypeError
TooManyArgumentsInLHS :: Type -> TypeError
WrongNumberOfConstructorArguments :: QName -> Nat -> Nat -> TypeError
ShouldBeEmpty :: Type -> [DeBruijnPattern] -> TypeError

-- | The given type should have been a sort.
ShouldBeASort :: Type -> TypeError

-- | The given type should have been a pi.
ShouldBePi :: Type -> TypeError
ShouldBeRecordType :: Type -> TypeError
ShouldBeRecordPattern :: DeBruijnPattern -> TypeError
NotAProjectionPattern :: (NamedArg Pattern) -> TypeError
NotAProperTerm :: TypeError
SetOmegaNotValidType :: TypeError

-- | This sort is not a type expression.
InvalidTypeSort :: Sort -> TypeError

-- | This term is not a type expression.
InvalidType :: Term -> TypeError

-- | This term, a function type constructor, lives in <tt>SizeUniv</tt>,
--   which is not allowed.
FunctionTypeInSizeUniv :: Term -> TypeError
SplitOnIrrelevant :: Pattern -> (Dom Type) -> TypeError
DefinitionIsIrrelevant :: QName -> TypeError
VariableIsIrrelevant :: Name -> TypeError
UnequalTerms :: Comparison -> Term -> Term -> Type -> TypeError
UnequalTypes :: Comparison -> Type -> Type -> TypeError

-- | The two function types have different relevance.
UnequalRelevance :: Comparison -> Term -> Term -> TypeError

-- | The two function types have different hiding.
UnequalHiding :: Term -> Term -> TypeError
UnequalSorts :: Sort -> Sort -> TypeError
UnequalBecauseOfUniverseConflict :: Comparison -> Term -> Term -> TypeError

-- | We ended up with an equality constraint where the terms have different
--   types. This is not supported.
HeterogeneousEquality :: Term -> Type -> Term -> Type -> TypeError
NotLeqSort :: Sort -> Sort -> TypeError

-- | The arguments are the meta variable, the parameters it can depend on
--   and the paratemeter that it wants to depend on.
MetaCannotDependOn :: MetaId -> [Nat] -> Nat -> TypeError
MetaOccursInItself :: MetaId -> TypeError
GenericError :: String -> TypeError
GenericDocError :: Doc -> TypeError
BuiltinMustBeConstructor :: String -> Expr -> TypeError
NoSuchBuiltinName :: String -> TypeError
DuplicateBuiltinBinding :: String -> Term -> Term -> TypeError
NoBindingForBuiltin :: String -> TypeError
NoSuchPrimitiveFunction :: String -> TypeError
ShadowedModule :: Name -> [ModuleName] -> TypeError
BuiltinInParameterisedModule :: String -> TypeError
IllegalLetInTelescope :: TypedBinding -> TypeError
NoRHSRequiresAbsurdPattern :: [NamedArg Pattern] -> TypeError
AbsurdPatternRequiresNoRHS :: [NamedArg Pattern] -> TypeError
TooFewFields :: QName -> [Name] -> TypeError
TooManyFields :: QName -> [Name] -> TypeError
DuplicateFields :: [Name] -> TypeError
DuplicateConstructors :: [Name] -> TypeError
WithOnFreeVariable :: Expr -> Term -> TypeError
UnexpectedWithPatterns :: [Pattern] -> TypeError
WithClausePatternMismatch :: Pattern -> Pattern -> TypeError
FieldOutsideRecord :: TypeError
ModuleArityMismatch :: ModuleName -> Telescope -> [NamedArg Expr] -> TypeError
IncompletePatternMatching :: Term -> [Elim] -> TypeError
CoverageFailure :: QName -> [[NamedArg DeBruijnPattern]] -> TypeError
UnreachableClauses :: QName -> [[NamedArg DeBruijnPattern]] -> TypeError
CoverageCantSplitOn :: QName -> Telescope -> Args -> Args -> TypeError
CoverageCantSplitIrrelevantType :: Type -> TypeError
CoverageCantSplitType :: Type -> TypeError
CoverageNoExactSplit :: QName -> Clause -> TypeError
WithoutKError :: Type -> Term -> Term -> TypeError
UnifyConflict :: ConHead -> ConHead -> TypeError
UnifyCycle :: Int -> Term -> TypeError
UnifyIndicesNotVars :: Type -> Term -> Term -> Args -> TypeError
UnificationRecursiveEq :: Type -> Int -> Term -> TypeError
UnificationStuck :: Telescope -> [Term] -> [Term] -> TypeError
SplitError :: SplitError -> TypeError
TooManyPolarities :: QName -> Integer -> TypeError
LocalVsImportedModuleClash :: ModuleName -> TypeError

-- | Some interaction points (holes) have not been filled by user. There
--   are not <tt>UnsolvedMetas</tt> since unification solved them. This is
--   an error, since interaction points are never filled without user
--   interaction.
SolvedButOpenHoles :: TypeError
CyclicModuleDependency :: [TopLevelModuleName] -> TypeError
FileNotFound :: TopLevelModuleName -> [AbsolutePath] -> TypeError
OverlappingProjects :: AbsolutePath -> TopLevelModuleName -> TopLevelModuleName -> TypeError
AmbiguousTopLevelModuleName :: TopLevelModuleName -> [AbsolutePath] -> TypeError

-- | Found module name, expected module name.
ModuleNameUnexpected :: TopLevelModuleName -> TopLevelModuleName -> TypeError
ModuleNameDoesntMatchFileName :: TopLevelModuleName -> [AbsolutePath] -> TypeError
ClashingFileNamesFor :: ModuleName -> [AbsolutePath] -> TypeError

-- | Module name, file from which it was loaded, file which the include
--   path says contains the module. Scope errors
ModuleDefinedInOtherFile :: TopLevelModuleName -> AbsolutePath -> AbsolutePath -> TypeError
BothWithAndRHS :: TypeError
NotInScope :: [QName] -> TypeError
NoSuchModule :: QName -> TypeError
AmbiguousName :: QName -> [QName] -> TypeError
AmbiguousModule :: QName -> [ModuleName] -> TypeError
UninstantiatedModule :: QName -> TypeError
ClashingDefinition :: QName -> QName -> TypeError
ClashingModule :: ModuleName -> ModuleName -> TypeError
ClashingImport :: Name -> QName -> TypeError
ClashingModuleImport :: Name -> ModuleName -> TypeError
PatternShadowsConstructor :: Name -> QName -> TypeError
ModuleDoesntExport :: QName -> [ImportedName] -> TypeError
DuplicateImports :: QName -> [ImportedName] -> TypeError
InvalidPattern :: Pattern -> TypeError
RepeatedVariablesInPattern :: [Name] -> TypeError

-- | The expr was used in the right hand side of an implicit module
--   definition, but it wasn't of the form <tt>m Delta</tt>.
NotAModuleExpr :: Expr -> TypeError
NotAnExpression :: Expr -> TypeError
NotAValidLetBinding :: NiceDeclaration -> TypeError
NotValidBeforeField :: NiceDeclaration -> TypeError
NothingAppliedToHiddenArg :: Expr -> TypeError
NothingAppliedToInstanceArg :: Expr -> TypeError
BadArgumentsToPatternSynonym :: QName -> TypeError
TooFewArgumentsToPatternSynonym :: QName -> TypeError
UnusedVariableInPatternSynonym :: TypeError
NoParseForApplication :: [Expr] -> TypeError
AmbiguousParseForApplication :: [Expr] -> [Expr] -> TypeError
NoParseForLHS :: LHSOrPatSyn -> Pattern -> TypeError
AmbiguousParseForLHS :: LHSOrPatSyn -> Pattern -> [Pattern] -> TypeError
OperatorInformation :: [NotationSection] -> TypeError -> TypeError
OperatorChangeMessage :: TypeError -> TypeError
IFSNoCandidateInScope :: Type -> TypeError
UnquoteFailed :: UnquoteError -> TypeError
DeBruijnIndexOutOfScope :: Nat -> Telescope -> [Name] -> TypeError
SafeFlagPostulate :: Name -> TypeError
SafeFlagPragma :: [String] -> TypeError
SafeFlagNonTerminating :: TypeError
SafeFlagTerminating :: TypeError
SafeFlagPrimTrustMe :: TypeError
SafeFlagNoPositivityCheck :: TypeError
SafeFlagPolarity :: TypeError
NeedOptionCopatterns :: TypeError
NeedOptionRewriting :: TypeError
NonFatalErrors :: [TCWarning] -> TypeError
InstanceSearchDepthExhausted :: Term -> Type -> Int -> TypeError

-- | Distinguish error message when parsing lhs or pattern synonym, resp.
data LHSOrPatSyn
IsLHS :: LHSOrPatSyn
IsPatSyn :: LHSOrPatSyn

-- | Type-checking errors.
data TCErr
TypeError :: TCState -> Closure TypeError -> TCErr

-- | The state in which the error was raised.
[tcErrState] :: TCErr -> TCState

-- | The environment in which the error as raised plus the error.
[tcErrClosErr] :: TCErr -> Closure TypeError
Exception :: Range -> Doc -> TCErr
IOException :: Range -> IOException -> TCErr

-- | The exception which is usually caught. Raised for pattern violations
--   during unification (<tt>assignV</tt>) but also in other situations
--   where we want to backtrack.
PatternErr :: TCErr

-- | Environment of the reduce monad.
data ReduceEnv
ReduceEnv :: TCEnv -> TCState -> ReduceEnv

-- | Read only access to environment.
[redEnv] :: ReduceEnv -> TCEnv

-- | Read only access to state (signature, metas...).
[redSt] :: ReduceEnv -> TCState
mapRedEnv :: (TCEnv -> TCEnv) -> ReduceEnv -> ReduceEnv
mapRedSt :: (TCState -> TCState) -> ReduceEnv -> ReduceEnv
mapRedEnvSt :: (TCEnv -> TCEnv) -> (TCState -> TCState) -> ReduceEnv -> ReduceEnv
newtype ReduceM a
ReduceM :: (ReduceEnv -> a) -> ReduceM a
[unReduceM] :: ReduceM a -> ReduceEnv -> a
fmapReduce :: (a -> b) -> ReduceM a -> ReduceM b
apReduce :: ReduceM (a -> b) -> ReduceM a -> ReduceM b
bindReduce :: ReduceM a -> (a -> ReduceM b) -> ReduceM b
runReduceM :: ReduceM a -> TCM a
runReduceF :: (a -> ReduceM b) -> TCM (a -> b)
newtype TCMT m a
TCM :: (IORef TCState -> TCEnv -> m a) -> TCMT m a
[unTCM] :: TCMT m a -> IORef TCState -> TCEnv -> m a
type TCM = TCMT IO
class (Applicative tcm, MonadIO tcm, MonadReader TCEnv tcm, MonadState TCState tcm) => MonadTCM tcm
liftTCM :: MonadTCM tcm => TCM a -> tcm a

-- | Parse monad
runPM :: PM a -> TCM a

-- | Interaction monad.
type IM = TCMT (InputT IO)
runIM :: IM a -> TCM a

-- | Preserve the state of the failing computation.
catchError_ :: TCM a -> (TCErr -> TCM a) -> TCM a

-- | Execute a finalizer even when an exception is thrown. Does not catch
--   any errors. In case both the regular computation and the finalizer
--   throw an exception, the one of the finalizer is propagated.
finally_ :: TCM a -> TCM b -> TCM a
mapTCMT :: (forall a. m a -> n a) -> TCMT m a -> TCMT n a
pureTCM :: MonadIO m => (TCState -> TCEnv -> a) -> TCMT m a
returnTCMT :: MonadIO m => a -> TCMT m a
bindTCMT :: MonadIO m => TCMT m a -> (a -> TCMT m b) -> TCMT m b
thenTCMT :: MonadIO m => TCMT m a -> TCMT m b -> TCMT m b
fmapTCMT :: MonadIO m => (a -> b) -> TCMT m a -> TCMT m b
apTCMT :: MonadIO m => TCMT m (a -> b) -> TCMT m a -> TCMT m b

-- | We store benchmark statistics in an IORef. This enables benchmarking
--   pure computation, see <a>Agda.Benchmarking</a>.

-- | Short-cutting disjunction forms a monoid.
patternViolation :: TCM a
internalError :: MonadTCM tcm => String -> tcm a
genericError :: MonadTCM tcm => String -> tcm a
genericDocError :: MonadTCM tcm => Doc -> tcm a
typeError :: MonadTCM tcm => TypeError -> tcm a
typeError_ :: MonadTCM tcm => TypeError -> tcm TCErr
warning_ :: MonadTCM tcm => Warning -> tcm TCWarning
warning :: MonadTCM tcm => Warning -> tcm ()

-- | Running the type checking monad (most general form).
runTCM :: MonadIO m => TCEnv -> TCState -> TCMT m a -> m (a, TCState)

-- | Running the type checking monad on toplevel (with initial state).
runTCMTop :: TCM a -> IO (Either TCErr a)
runTCMTop' :: MonadIO m => TCMT m a -> m a

-- | <a>runSafeTCM</a> runs a safe <a>TCM</a> action (a <a>TCM</a> action
--   which cannot fail) in the initial environment.
runSafeTCM :: TCM a -> TCState -> IO (a, TCState)

-- | Runs the given computation in a separate thread, with <i>a copy</i> of
--   the current state and environment.
--   
--   Note that Agda sometimes uses actual, mutable state. If the
--   computation given to <tt>forkTCM</tt> tries to <i>modify</i> this
--   state, then bad things can happen, because accesses are not mutually
--   exclusive. The <tt>forkTCM</tt> function has been added mainly to
--   allow the thread to <i>read</i> (a snapshot of) the current state in a
--   convenient way.
--   
--   Note also that exceptions which are raised in the thread are not
--   propagated to the parent, so the thread should not do anything
--   important.
forkTCM :: TCM a -> TCM ()

-- | Base name for extended lambda patterns
extendedLambdaName :: String

-- | Name of absurdLambda definitions.
absurdLambdaName :: String

-- | Check whether we have an definition from an absurd lambda.
isAbsurdLambdaName :: QName -> Bool
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.TypeError
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.SplitError
instance Agda.Utils.Null.Null Agda.TypeChecking.Monad.Base.Fields
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.UnquoteError
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.MutualBlock
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.MutualBlock
instance GHC.Base.Functor Agda.TypeChecking.Monad.Base.MaybeReduced
instance GHC.Num.Num Agda.TypeChecking.Monad.Base.ProblemId
instance GHC.Real.Integral Agda.TypeChecking.Monad.Base.ProblemId
instance GHC.Real.Real Agda.TypeChecking.Monad.Base.ProblemId
instance GHC.Enum.Enum Agda.TypeChecking.Monad.Base.ProblemId
instance GHC.Classes.Ord Agda.TypeChecking.Monad.Base.ProblemId
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.ProblemId
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.Candidate
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.Constraint
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.ProblemConstraint
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.ModuleParameters
instance Data.Foldable.Foldable Agda.TypeChecking.Monad.Base.Closure
instance GHC.Base.Functor Agda.TypeChecking.Monad.Base.Closure
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.TerminationError
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.Warning
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.TCWarning
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.Section
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.CoreRepresentation
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.CompiledRepresentation
instance Agda.Utils.Null.Null Agda.TypeChecking.Monad.Base.ProjLams
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.ProjLams
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.Projection
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.TermHead
instance GHC.Classes.Ord Agda.TypeChecking.Monad.Base.TermHead
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.TermHead
instance GHC.Base.Functor Agda.TypeChecking.Monad.Base.FunctionInverse'
instance GHC.Show.Show c => GHC.Show.Show (Agda.TypeChecking.Monad.Base.FunctionInverse' c)
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.Defn
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.Definition
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.NLPType
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.NLPat
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.RewriteRule
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.Signature
instance Data.Traversable.Traversable Agda.TypeChecking.Monad.Base.Local
instance Data.Foldable.Foldable Agda.TypeChecking.Monad.Base.Local
instance GHC.Base.Functor Agda.TypeChecking.Monad.Base.Local
instance GHC.Show.Show a => GHC.Show.Show (Agda.TypeChecking.Monad.Base.Local a)
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.DisplayTerm
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.DisplayForm
instance Data.Traversable.Traversable Agda.TypeChecking.Monad.Base.Builtin
instance Data.Foldable.Foldable Agda.TypeChecking.Monad.Base.Builtin
instance GHC.Base.Functor Agda.TypeChecking.Monad.Base.Builtin
instance GHC.Show.Show pf => GHC.Show.Show (Agda.TypeChecking.Monad.Base.Builtin pf)
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.Interface
instance GHC.Num.Num Agda.TypeChecking.Monad.Base.CtxId
instance GHC.Real.Integral Agda.TypeChecking.Monad.Base.CtxId
instance GHC.Real.Real Agda.TypeChecking.Monad.Base.CtxId
instance GHC.Enum.Enum Agda.TypeChecking.Monad.Base.CtxId
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.CtxId
instance GHC.Classes.Ord Agda.TypeChecking.Monad.Base.CtxId
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.CtxId
instance GHC.Base.Functor Agda.TypeChecking.Monad.Base.Open
instance GHC.Show.Show a => GHC.Show.Show (Agda.TypeChecking.Monad.Base.Open a)
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.LHSOrPatSyn
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.LHSOrPatSyn
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.ExplicitToInstance
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.ExplicitToInstance
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.ExpandHidden
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.AbstractMode
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.AbstractMode
instance GHC.Read.Read Agda.TypeChecking.Monad.Base.HighlightingMethod
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.HighlightingMethod
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.HighlightingMethod
instance GHC.Read.Read Agda.TypeChecking.Monad.Base.HighlightingLevel
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.HighlightingLevel
instance GHC.Classes.Ord Agda.TypeChecking.Monad.Base.HighlightingLevel
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.HighlightingLevel
instance GHC.Enum.Enum Agda.TypeChecking.Monad.Base.MutualId
instance GHC.Num.Num Agda.TypeChecking.Monad.Base.MutualId
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.MutualId
instance GHC.Classes.Ord Agda.TypeChecking.Monad.Base.MutualId
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.MutualId
instance GHC.Enum.Bounded Agda.TypeChecking.Monad.Base.AllowedReduction
instance GHC.Enum.Enum Agda.TypeChecking.Monad.Base.AllowedReduction
instance GHC.Classes.Ord Agda.TypeChecking.Monad.Base.AllowedReduction
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.AllowedReduction
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.AllowedReduction
instance GHC.Base.Functor (Agda.TypeChecking.Monad.Base.Reduced no)
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.Simplification
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.Simplification
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.FunctionFlag
instance GHC.Enum.Enum Agda.TypeChecking.Monad.Base.FunctionFlag
instance GHC.Classes.Ord Agda.TypeChecking.Monad.Base.FunctionFlag
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.FunctionFlag
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.EtaEquality
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.EtaEquality
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.ExtLamInfo
instance GHC.Classes.Ord Agda.TypeChecking.Monad.Base.ExtLamInfo
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.ExtLamInfo
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.Polarity
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.Polarity
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.HaskellExport
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.HaskellRepresentation
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.RunMetaOccursCheck
instance GHC.Classes.Ord Agda.TypeChecking.Monad.Base.RunMetaOccursCheck
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.RunMetaOccursCheck
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.MetaPriority
instance GHC.Classes.Ord Agda.TypeChecking.Monad.Base.MetaPriority
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.MetaPriority
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.Frozen
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.Frozen
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.CompareDirection
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.Comparison
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.TCState
instance Agda.Utils.Null.Null Agda.TypeChecking.Monad.Base.MutualBlock
instance Agda.TypeChecking.Monad.Base.HasFresh Agda.Syntax.Common.MetaId
instance Agda.TypeChecking.Monad.Base.HasFresh Agda.TypeChecking.Monad.Base.MutualId
instance Agda.TypeChecking.Monad.Base.HasFresh Agda.Syntax.Common.InteractionId
instance Agda.TypeChecking.Monad.Base.HasFresh Agda.Syntax.Common.NameId
instance Agda.TypeChecking.Monad.Base.HasFresh Agda.TypeChecking.Monad.Base.CtxId
instance Agda.TypeChecking.Monad.Base.HasFresh GHC.Types.Int
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.ProblemId
instance Agda.Utils.Pretty.Pretty Agda.TypeChecking.Monad.Base.ProblemId
instance Agda.TypeChecking.Monad.Base.HasFresh Agda.TypeChecking.Monad.Base.ProblemId
instance Agda.TypeChecking.Monad.Base.FreshName (Agda.Syntax.Position.Range, GHC.Base.String)
instance Agda.TypeChecking.Monad.Base.FreshName GHC.Base.String
instance Agda.TypeChecking.Monad.Base.FreshName Agda.Syntax.Position.Range
instance Agda.TypeChecking.Monad.Base.FreshName ()
instance Agda.Utils.Pretty.Pretty Agda.TypeChecking.Monad.Base.Interface
instance GHC.Show.Show a => GHC.Show.Show (Agda.TypeChecking.Monad.Base.Closure a)
instance Agda.Syntax.Position.HasRange a => Agda.Syntax.Position.HasRange (Agda.TypeChecking.Monad.Base.Closure a)
instance Agda.Syntax.Position.HasRange Agda.TypeChecking.Monad.Base.ProblemConstraint
instance Agda.Syntax.Position.HasRange Agda.TypeChecking.Monad.Base.Constraint
instance Agda.TypeChecking.Free.Lazy.Free' Agda.TypeChecking.Monad.Base.Constraint c
instance Agda.Syntax.Internal.Generic.TermLike Agda.TypeChecking.Monad.Base.Constraint
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.Comparison
instance Agda.Utils.Pretty.Pretty Agda.TypeChecking.Monad.Base.Comparison
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.CompareDirection
instance Agda.Utils.Functor.Decoration Agda.TypeChecking.Monad.Base.Open
instance Agda.Utils.Functor.Decoration Agda.TypeChecking.Monad.Base.Local
instance GHC.Show.Show a => GHC.Show.Show (Agda.TypeChecking.Monad.Base.Judgement a)
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.Listener
instance GHC.Classes.Ord Agda.TypeChecking.Monad.Base.Listener
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.MetaInstantiation
instance Agda.Utils.Pretty.Pretty Agda.TypeChecking.Monad.Base.NamedMeta
instance Agda.Syntax.Position.HasRange Agda.TypeChecking.Monad.Base.MetaInfo
instance Agda.Syntax.Position.HasRange Agda.TypeChecking.Monad.Base.MetaVariable
instance Agda.Syntax.Position.SetRange Agda.TypeChecking.Monad.Base.MetaInfo
instance Agda.Syntax.Position.SetRange Agda.TypeChecking.Monad.Base.MetaVariable
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.InteractionPoint
instance GHC.Classes.Eq Agda.TypeChecking.Monad.Base.IPClause
instance Agda.TypeChecking.Free.Lazy.Free' Agda.TypeChecking.Monad.Base.DisplayForm c
instance Agda.TypeChecking.Free.Lazy.Free' Agda.TypeChecking.Monad.Base.DisplayTerm c
instance Agda.Utils.Null.Null Agda.TypeChecking.Monad.Base.Simplification
instance Data.Semigroup.Semigroup Agda.TypeChecking.Monad.Base.Simplification
instance GHC.Base.Monoid Agda.TypeChecking.Monad.Base.Simplification
instance Agda.Syntax.Internal.IsProjElim e => Agda.Syntax.Internal.IsProjElim (Agda.TypeChecking.Monad.Base.MaybeReduced e)
instance Agda.Utils.Pretty.Pretty Agda.TypeChecking.Monad.Base.Call
instance Agda.Syntax.Position.HasRange Agda.TypeChecking.Monad.Base.Call
instance Agda.TypeChecking.Free.Lazy.Free' Agda.TypeChecking.Monad.Base.Candidate c
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.CallInfo
instance Agda.Utils.Pretty.Pretty Agda.TypeChecking.Monad.Base.CallInfo
instance Agda.Syntax.Abstract.AllNames Agda.TypeChecking.Monad.Base.CallInfo
instance Agda.Utils.Except.Error Agda.TypeChecking.Monad.Base.SplitError
instance Agda.Utils.Except.Error Agda.TypeChecking.Monad.Base.UnquoteError
instance Agda.Utils.Except.Error Agda.TypeChecking.Monad.Base.TCErr
instance GHC.Show.Show Agda.TypeChecking.Monad.Base.TCErr
instance Agda.Syntax.Position.HasRange Agda.TypeChecking.Monad.Base.TCErr
instance GHC.Exception.Exception Agda.TypeChecking.Monad.Base.TCErr
instance GHC.Base.Functor Agda.TypeChecking.Monad.Base.ReduceM
instance GHC.Base.Applicative Agda.TypeChecking.Monad.Base.ReduceM
instance GHC.Base.Monad Agda.TypeChecking.Monad.Base.ReduceM
instance Agda.TypeChecking.Monad.Base.ReadTCState Agda.TypeChecking.Monad.Base.ReduceM
instance Control.Monad.Reader.Class.MonadReader Agda.TypeChecking.Monad.Base.TCEnv Agda.TypeChecking.Monad.Base.ReduceM
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.Reader.Class.MonadReader Agda.TypeChecking.Monad.Base.TCEnv (Agda.TypeChecking.Monad.Base.TCMT m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.State.Class.MonadState Agda.TypeChecking.Monad.Base.TCState (Agda.TypeChecking.Monad.Base.TCMT m)
instance Control.Monad.IO.Class.MonadIO m => Agda.TypeChecking.Monad.Base.ReadTCState (Agda.TypeChecking.Monad.Base.TCMT m)
instance Control.Monad.Error.Class.MonadError Agda.TypeChecking.Monad.Base.TCErr (Agda.TypeChecking.Monad.Base.TCMT GHC.Types.IO)
instance Control.Monad.Error.Class.MonadError Agda.TypeChecking.Monad.Base.TCErr Agda.TypeChecking.Monad.Base.IM
instance Control.Monad.IO.Class.MonadIO m => Agda.TypeChecking.Monad.Base.MonadTCM (Agda.TypeChecking.Monad.Base.TCMT m)
instance Agda.TypeChecking.Monad.Base.MonadTCM tcm => Agda.TypeChecking.Monad.Base.MonadTCM (Control.Monad.Trans.Maybe.MaybeT tcm)
instance Agda.TypeChecking.Monad.Base.MonadTCM tcm => Agda.TypeChecking.Monad.Base.MonadTCM (Agda.Utils.ListT.ListT tcm)
instance Agda.TypeChecking.Monad.Base.MonadTCM tcm => Agda.TypeChecking.Monad.Base.MonadTCM (Control.Monad.Trans.Except.ExceptT err tcm)
instance (GHC.Base.Monoid w, Agda.TypeChecking.Monad.Base.MonadTCM tcm) => Agda.TypeChecking.Monad.Base.MonadTCM (Control.Monad.Trans.Writer.Lazy.WriterT w tcm)
instance Control.Monad.Trans.Class.MonadTrans Agda.TypeChecking.Monad.Base.TCMT
instance Control.Monad.IO.Class.MonadIO m => GHC.Base.Monad (Agda.TypeChecking.Monad.Base.TCMT m)
instance Control.Monad.IO.Class.MonadIO m => GHC.Base.Functor (Agda.TypeChecking.Monad.Base.TCMT m)
instance Control.Monad.IO.Class.MonadIO m => GHC.Base.Applicative (Agda.TypeChecking.Monad.Base.TCMT m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Agda.TypeChecking.Monad.Base.TCMT m)
instance Agda.Utils.Benchmark.MonadBench Agda.Benchmarking.Phase Agda.TypeChecking.Monad.Base.TCM
instance Agda.Utils.Null.Null (Agda.TypeChecking.Monad.Base.TCM Text.PrettyPrint.HughesPJ.Doc)
instance Data.Semigroup.Semigroup (Agda.TypeChecking.Monad.Base.TCM Data.Monoid.Any)
instance GHC.Base.Monoid (Agda.TypeChecking.Monad.Base.TCM Data.Monoid.Any)
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.Signature
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.Sections
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.Definitions
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.RewriteRuleMap
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.Section
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.Definition
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.CtxId
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.NLPat
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.NLPType
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.RewriteRule
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.CompiledRepresentation
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.EtaEquality
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.ExtLamInfo
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.FunctionFlag
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.Defn
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.MutualId
instance Agda.Syntax.Position.KillRange c => Agda.Syntax.Position.KillRange (Agda.TypeChecking.Monad.Base.FunctionInverse' c)
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.TermHead
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.Projection
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.ProjLams
instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.TypeChecking.Monad.Base.Open a)
instance Agda.Syntax.Position.KillRange a => Agda.Syntax.Position.KillRange (Agda.TypeChecking.Monad.Base.Local a)
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.DisplayForm
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.Polarity
instance Agda.Syntax.Position.KillRange Agda.TypeChecking.Monad.Base.DisplayTerm


-- | Extract all names from things.
module Agda.Syntax.Internal.Names
class NamesIn a
namesIn :: NamesIn a => a -> Set QName
namesInFoldable :: (Foldable f, NamesIn a) => f a -> Set QName
newtype PSyn
PSyn :: PatternSynDefn -> PSyn
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn (GHC.Base.Maybe a)
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn [a]
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn (Agda.Syntax.Common.Arg a)
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn (Agda.Syntax.Common.Dom a)
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn (Agda.Syntax.Common.Named n a)
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn (Agda.Syntax.Internal.Abs a)
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn (Agda.TypeChecking.CompiledClause.WithArity a)
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn (Agda.Syntax.Internal.Tele a)
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn (Agda.Syntax.Concrete.FieldAssignment' a)
instance (Agda.Syntax.Internal.Names.NamesIn a, Agda.Syntax.Internal.Names.NamesIn b) => Agda.Syntax.Internal.Names.NamesIn (a, b)
instance (Agda.Syntax.Internal.Names.NamesIn a, Agda.Syntax.Internal.Names.NamesIn b, Agda.Syntax.Internal.Names.NamesIn c) => Agda.Syntax.Internal.Names.NamesIn (a, b, c)
instance Agda.Syntax.Internal.Names.NamesIn Agda.TypeChecking.Monad.Base.Definition
instance Agda.Syntax.Internal.Names.NamesIn Agda.TypeChecking.Monad.Base.Defn
instance Agda.Syntax.Internal.Names.NamesIn Agda.Syntax.Internal.Clause
instance Agda.Syntax.Internal.Names.NamesIn Agda.TypeChecking.CompiledClause.CompiledClauses
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn (Agda.TypeChecking.CompiledClause.Case a)
instance Agda.Syntax.Internal.Names.NamesIn (Agda.Syntax.Internal.Pattern' a)
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn (Agda.Syntax.Internal.Type' a)
instance Agda.Syntax.Internal.Names.NamesIn Agda.Syntax.Internal.Sort
instance Agda.Syntax.Internal.Names.NamesIn Agda.Syntax.Internal.Term
instance Agda.Syntax.Internal.Names.NamesIn Agda.Syntax.Internal.Level
instance Agda.Syntax.Internal.Names.NamesIn Agda.Syntax.Internal.PlusLevel
instance Agda.Syntax.Internal.Names.NamesIn Agda.Syntax.Internal.LevelAtom
instance Agda.Syntax.Internal.Names.NamesIn Agda.Syntax.Literal.Literal
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn (Agda.Syntax.Internal.Elim' a)
instance Agda.Syntax.Internal.Names.NamesIn Agda.Syntax.Abstract.Name.QName
instance Agda.Syntax.Internal.Names.NamesIn Agda.Syntax.Internal.ConHead
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn (Agda.TypeChecking.Monad.Base.Open a)
instance Agda.Syntax.Internal.Names.NamesIn a => Agda.Syntax.Internal.Names.NamesIn (Agda.TypeChecking.Monad.Base.Local a)
instance Agda.Syntax.Internal.Names.NamesIn Agda.TypeChecking.Monad.Base.DisplayForm
instance Agda.Syntax.Internal.Names.NamesIn Agda.TypeChecking.Monad.Base.DisplayTerm
instance Agda.Syntax.Internal.Names.NamesIn Agda.Syntax.Internal.Names.PSyn
instance Agda.Syntax.Internal.Names.NamesIn (Agda.Syntax.Abstract.Pattern' a)
instance Agda.Syntax.Internal.Names.NamesIn Agda.Syntax.Abstract.Name.AmbiguousQName

module Agda.TypeChecking.Monad.Env

-- | Get the name of the current module, if any.
currentModule :: MonadReader TCEnv m => m ModuleName

-- | Set the name of the current module.
withCurrentModule :: ModuleName -> TCM a -> TCM a

-- | Get the number of variables bound by anonymous modules.
getAnonymousVariables :: MonadReader TCEnv m => ModuleName -> m Nat

-- | Add variables bound by an anonymous module.
withAnonymousModule :: ModuleName -> Nat -> TCM a -> TCM a

-- | Set the current environment to the given
withEnv :: TCEnv -> TCM a -> TCM a

-- | Get the current environment
getEnv :: TCM TCEnv

-- | Increases the module nesting level by one in the given computation.
withIncreasedModuleNestingLevel :: TCM a -> TCM a

-- | Set highlighting level
withHighlightingLevel :: HighlightingLevel -> TCM a -> TCM a

-- | Restore setting for <a>ExpandLast</a> to default.
doExpandLast :: TCM a -> TCM a
dontExpandLast :: TCM a -> TCM a

-- | If the reduced did a proper match (constructor or literal pattern),
--   then record this as simplification step.
performedSimplification :: MonadReader TCEnv m => m a -> m a
performedSimplification' :: MonadReader TCEnv m => Simplification -> m a -> m a
getSimplification :: MonadReader TCEnv m => m Simplification

-- | Lens for <a>AllowedReductions</a>.
updateAllowedReductions :: (AllowedReductions -> AllowedReductions) -> TCEnv -> TCEnv
modifyAllowedReductions :: (AllowedReductions -> AllowedReductions) -> TCM a -> TCM a
putAllowedReductions :: AllowedReductions -> TCM a -> TCM a

-- | Reduce <tt>Def f vs</tt> only if <tt>f</tt> is a projection.
onlyReduceProjections :: TCM a -> TCM a

-- | Allow all reductions except for non-terminating functions (default).
allowAllReductions :: TCM a -> TCM a

-- | Allow all reductions including non-terminating functions.
allowNonTerminatingReductions :: TCM a -> TCM a
insideDotPattern :: TCM a -> TCM a
isInsideDotPattern :: TCM Bool


-- | Basically a copy of the ErrorT monad transformer. It's handy to slap
--   onto TCM and still be a MonadTCM (which isn't possible with ErrorT).
module Agda.TypeChecking.Monad.Exception
newtype ExceptionT err m a
ExceptionT :: m (Either err a) -> ExceptionT err m a
[runExceptionT] :: ExceptionT err m a -> m (Either err a)
class Error err => MonadException err m | m -> err
throwException :: MonadException err m => err -> m a
catchException :: MonadException err m => m a -> (err -> m a) -> m a
instance (GHC.Base.Monad m, Agda.Utils.Except.Error err) => GHC.Base.Monad (Agda.TypeChecking.Monad.Exception.ExceptionT err m)
instance (GHC.Base.Monad m, Agda.Utils.Except.Error err) => Agda.TypeChecking.Monad.Exception.MonadException err (Agda.TypeChecking.Monad.Exception.ExceptionT err m)
instance (GHC.Base.Monad m, Agda.TypeChecking.Monad.Exception.MonadException err m) => Agda.TypeChecking.Monad.Exception.MonadException err (Control.Monad.Trans.Reader.ReaderT r m)
instance (GHC.Base.Monad m, Agda.TypeChecking.Monad.Exception.MonadException err m, GHC.Base.Monoid w) => Agda.TypeChecking.Monad.Exception.MonadException err (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (GHC.Base.Monad m, Agda.TypeChecking.Monad.Exception.MonadException err m) => Agda.TypeChecking.Monad.Exception.MonadException err (Control.Monad.Trans.State.Lazy.StateT s m)
instance Control.Monad.Trans.Class.MonadTrans (Agda.TypeChecking.Monad.Exception.ExceptionT err)
instance GHC.Base.Functor f => GHC.Base.Functor (Agda.TypeChecking.Monad.Exception.ExceptionT err f)
instance (Agda.Utils.Except.Error err, GHC.Base.Applicative m, GHC.Base.Monad m) => GHC.Base.Applicative (Agda.TypeChecking.Monad.Exception.ExceptionT err m)
instance (Agda.Utils.Except.Error err, Control.Monad.State.Class.MonadState s m) => Control.Monad.State.Class.MonadState s (Agda.TypeChecking.Monad.Exception.ExceptionT err m)
instance (Agda.Utils.Except.Error err, Control.Monad.Reader.Class.MonadReader r m) => Control.Monad.Reader.Class.MonadReader r (Agda.TypeChecking.Monad.Exception.ExceptionT err m)
instance (Agda.Utils.Except.Error err, Control.Monad.Error.Class.MonadError err' m) => Control.Monad.Error.Class.MonadError err' (Agda.TypeChecking.Monad.Exception.ExceptionT err m)
instance (Agda.Utils.Except.Error err, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Agda.TypeChecking.Monad.Exception.ExceptionT err m)
instance (Agda.Utils.Except.Error err, Agda.TypeChecking.Monad.Base.MonadTCM tcm) => Agda.TypeChecking.Monad.Base.MonadTCM (Agda.TypeChecking.Monad.Exception.ExceptionT err tcm)

module Agda.TypeChecking.Monad.Imports
addImport :: ModuleName -> TCM ()
addImportCycleCheck :: TopLevelModuleName -> TCM a -> TCM a
getImports :: TCM (Set ModuleName)
isImported :: ModuleName -> TCM Bool
getImportPath :: TCM [TopLevelModuleName]
visitModule :: ModuleInfo -> TCM ()
setVisitedModules :: VisitedModules -> TCM ()
getVisitedModules :: TCM VisitedModules
isVisited :: TopLevelModuleName -> TCM Bool
getVisitedModule :: TopLevelModuleName -> TCM (Maybe ModuleInfo)
getDecodedModules :: TCM DecodedModules
setDecodedModules :: DecodedModules -> TCM ()
getDecodedModule :: TopLevelModuleName -> TCM (Maybe Interface)
storeDecodedModule :: Interface -> TCM ()
dropDecodedModule :: TopLevelModuleName -> TCM ()
withImportPath :: [TopLevelModuleName] -> TCM a -> TCM a

-- | Assumes that the first module in the import path is the module we are
--   worried about.
checkForImportCycle :: TCM ()

module Agda.TypeChecking.Serialise.Base

-- | Constructor tag (maybe omitted) and argument indices.
type Node = [Int32]

-- | The type of hashtables used in this module.
--   
--   A very limited amount of testing indicates that <a>CuckooHashTable</a>
--   is somewhat slower than <a>BasicHashTable</a>, and that
--   <a>LinearHashTable</a> and the hashtables from <a>Data.Hashtable</a>
--   are much slower.
type HashTable k v = BasicHashTable k v

-- | Structure providing fresh identifiers for hash map and counting hash
--   map hits (i.e. when no fresh identifier required).
data FreshAndReuse
FreshAndReuse :: !Int32 -> !Int32 -> FreshAndReuse

-- | Number of hash map misses.
[farFresh] :: FreshAndReuse -> !Int32

-- | Number of hash map hits.
[farReuse] :: FreshAndReuse -> !Int32
farEmpty :: FreshAndReuse
lensFresh :: Lens' Int32 FreshAndReuse
lensReuse :: Lens' Int32 FreshAndReuse

-- | Two <a>QName</a>s are equal if their <tt>QNameId</tt> is equal.
type QNameId = [NameId]

-- | Computing a qualified names composed ID.
qnameId :: QName -> QNameId

-- | State of the the encoder.
data Dict
Dict :: !(HashTable Node Int32) -> !(HashTable String Int32) -> !(HashTable ByteString Int32) -> !(HashTable Integer Int32) -> !(HashTable Double Int32) -> !(HashTable (Ptr Term) Int32) -> !(HashTable NameId Int32) -> !(HashTable QNameId Int32) -> !(IORef FreshAndReuse) -> !(IORef FreshAndReuse) -> !(IORef FreshAndReuse) -> !(IORef FreshAndReuse) -> !(IORef FreshAndReuse) -> !(IORef FreshAndReuse) -> !(IORef FreshAndReuse) -> !(IORef FreshAndReuse) -> !(HashTable String Int) -> Bool -> !(HashTable AbsolutePath Int32) -> Dict

-- | Written to interface file.
[nodeD] :: Dict -> !(HashTable Node Int32)

-- | Written to interface file.
[stringD] :: Dict -> !(HashTable String Int32)

-- | Written to interface file.
[bstringD] :: Dict -> !(HashTable ByteString Int32)

-- | Written to interface file.
[integerD] :: Dict -> !(HashTable Integer Int32)

-- | Written to interface file. Dicitionaries which are not serialized, but
--   provide short cuts to speed up serialization:
[doubleD] :: Dict -> !(HashTable Double Int32)

-- | Not written to interface file. Andreas, Makoto, AIM XXI Memoizing
--   A.Name does not buy us much if we already memoize A.QName.
[termD] :: Dict -> !(HashTable (Ptr Term) Int32)

-- | Not written to interface file.
[nameD] :: Dict -> !(HashTable NameId Int32)

-- | Not written to interface file. Fresh UIDs and reuse statistics:
[qnameD] :: Dict -> !(HashTable QNameId Int32)
[nodeC] :: Dict -> !(IORef FreshAndReuse)
[stringC] :: Dict -> !(IORef FreshAndReuse)
[bstringC] :: Dict -> !(IORef FreshAndReuse)
[integerC] :: Dict -> !(IORef FreshAndReuse)
[doubleC] :: Dict -> !(IORef FreshAndReuse)
[termC] :: Dict -> !(IORef FreshAndReuse)
[nameC] :: Dict -> !(IORef FreshAndReuse)
[qnameC] :: Dict -> !(IORef FreshAndReuse)
[stats] :: Dict -> !(HashTable String Int)

-- | If <tt>True</tt> collect in <tt>stats</tt> the quantities of calls to
--   <tt>icode</tt> for each <tt>Typeable a</tt>.
[collectStats] :: Dict -> Bool

-- | Not written to interface file.
[absPathD] :: Dict -> !(HashTable AbsolutePath Int32)

-- | Creates an empty dictionary.
emptyDict :: Bool -> IO Dict

-- | Universal type, wraps everything.
data U
U :: !a -> U

-- | Univeral memo structure, to introduce sharing during decoding
type Memo = HashTable (Int32, TypeRep) U

-- | State of the decoder.
data St
St :: !(Array Int32 Node) -> !(Array Int32 String) -> !(Array Int32 ByteString) -> !(Array Int32 Integer) -> !(Array Int32 Double) -> !Memo -> !ModuleToSource -> [AbsolutePath] -> (Term -> Term) -> St

-- | Obtained from interface file.
[nodeE] :: St -> !(Array Int32 Node)

-- | Obtained from interface file.
[stringE] :: St -> !(Array Int32 String)

-- | Obtained from interface file.
[bstringE] :: St -> !(Array Int32 ByteString)

-- | Obtained from interface file.
[integerE] :: St -> !(Array Int32 Integer)

-- | Obtained from interface file.
[doubleE] :: St -> !(Array Int32 Double)

-- | Created and modified by decoder. Used to introduce sharing while
--   deserializing objects.
[nodeMemo] :: St -> !Memo

-- | Maps module names to file names. Constructed by the decoder.
[modFile] :: St -> !ModuleToSource

-- | The include directories.
[includes] :: St -> [AbsolutePath]
[mkShared] :: St -> Term -> Term

-- | Monad used by the encoder.
type S a = ReaderT Dict IO a

-- | Monad used by the decoder.
--   
--   <tt>TCM</tt> is not used because the associated overheads would make
--   decoding slower.
type R a = ExceptT TypeError (StateT St IO) a

-- | Throws an error which is suitable when the data stream is malformed.
malformed :: R a
class Typeable a => EmbPrj a where icode a = do { tickICode a; icod_ a }
icode :: EmbPrj a => a -> S Int32
icod_ :: EmbPrj a => a -> S Int32
value :: EmbPrj a => Int32 -> R a

-- | Increase entry for <tt>a</tt> in <a>stats</a>.
tickICode :: forall a. Typeable a => a -> S ()

-- | Data.Binary.runGetState is deprecated in favour of runGetIncremental.
--   Reimplementing it in terms of the new function. The new Decoder type
--   contains strict byte strings so we need to be careful not to feed the
--   entire lazy byte string to the decoder at once.
runGetState :: Get a -> ByteString -> ByteOffset -> (a, ByteString, ByteOffset)
icodeX :: (Eq k, Hashable k) => (Dict -> HashTable k Int32) -> (Dict -> IORef FreshAndReuse) -> k -> S Int32
icodeInteger :: Integer -> S Int32
icodeDouble :: Double -> S Int32
icodeString :: String -> S Int32
icodeN :: Node -> S Int32

-- | <tt>icode</tt> only if thing has not seen before.
icodeMemo :: (Ord a, Hashable a) => (Dict -> HashTable a Int32) -> (Dict -> IORef FreshAndReuse) -> a -> S Int32 -> S Int32

-- | <tt>vcase value ix</tt> decodes thing represented by <tt>ix ::
--   Int32</tt> via the <tt>valu</tt> function and stores it in
--   <a>nodeMemo</a>. If <tt>ix</tt> is present in <a>nodeMemo</a>,
--   <tt>valu</tt> is not used, but the thing is read from <a>nodeMemo</a>
--   instead.
vcase :: forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
icode0 :: Int32 -> S Int32
icode1 :: EmbPrj a => Int32 -> a -> S Int32
icode2 :: (EmbPrj a, EmbPrj b) => Int32 -> a -> b -> S Int32
icode3 :: (EmbPrj a, EmbPrj b, EmbPrj c) => Int32 -> a -> b -> c -> S Int32
icode4 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d) => Int32 -> a -> b -> c -> d -> S Int32
icode5 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e) => Int32 -> a -> b -> c -> d -> e -> S Int32
icode6 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f) => Int32 -> a -> b -> c -> d -> e -> f -> S Int32
icode7 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g) => Int32 -> a -> b -> c -> d -> e -> f -> g -> S Int32
icode8 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h) => Int32 -> a -> b -> c -> d -> e -> f -> g -> h -> S Int32
icode9 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i) => Int32 -> a -> b -> c -> d -> e -> f -> g -> h -> i -> S Int32
icode10 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j) => Int32 -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> S Int32
icode11 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k) => Int32 -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> S Int32
icode12 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k, EmbPrj l) => Int32 -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> S Int32
icode13 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k, EmbPrj l, EmbPrj m) => Int32 -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> S Int32
icode14 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k, EmbPrj l, EmbPrj m, EmbPrj n) => Int32 -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> S Int32
icode15 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k, EmbPrj l, EmbPrj m, EmbPrj n, EmbPrj o) => Int32 -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> S Int32
icode0' :: S Int32
icode1' :: EmbPrj a => a -> S Int32
icode2' :: (EmbPrj a, EmbPrj b) => a -> b -> S Int32
icode3' :: (EmbPrj a, EmbPrj b, EmbPrj c) => a -> b -> c -> S Int32
icode4' :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d) => a -> b -> c -> d -> S Int32
icode5' :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e) => a -> b -> c -> d -> e -> S Int32
icode6' :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f) => a -> b -> c -> d -> e -> f -> S Int32
icode7' :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g) => a -> b -> c -> d -> e -> f -> g -> S Int32
icode8' :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h) => a -> b -> c -> d -> e -> f -> g -> h -> S Int32
icode9' :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i) => a -> b -> c -> d -> e -> f -> g -> h -> i -> S Int32
icode10' :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j) => a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> S Int32
icode11' :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k) => a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> S Int32
icode12' :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k, EmbPrj l) => a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> S Int32
icode13' :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k, EmbPrj l, EmbPrj m) => a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> S Int32
icode14' :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k, EmbPrj l, EmbPrj m, EmbPrj n) => a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> S Int32
valu0 :: a -> R a
valu1 :: EmbPrj a => (a -> b) -> Int32 -> R b
valu2 :: (EmbPrj a, EmbPrj b) => (a -> b -> c) -> Int32 -> Int32 -> R c
valu3 :: (EmbPrj a, EmbPrj b, EmbPrj c) => (a -> b -> c -> d) -> Int32 -> Int32 -> Int32 -> R d
valu4 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d) => (a -> b -> c -> d -> e) -> Int32 -> Int32 -> Int32 -> Int32 -> R e
valu5 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e) => (a -> b -> c -> d -> e -> f) -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> R f
valu6 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f) => (a -> b -> c -> d -> e -> f -> g) -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> R g
valu7 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g) => (a -> b -> c -> d -> e -> f -> g -> h) -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> R h
valu8 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h) => (a -> b -> c -> d -> e -> f -> g -> h -> i) -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> R i
valu9 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> R j
valu10 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> R k
valu11 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l) -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> R l
valu12 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k, EmbPrj l) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m) -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> R m
valu13 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k, EmbPrj l, EmbPrj m) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n) -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> R n
valu14 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k, EmbPrj l, EmbPrj m, EmbPrj n) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o) -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> R o
valu15 :: (EmbPrj a, EmbPrj b, EmbPrj c, EmbPrj d, EmbPrj e, EmbPrj f, EmbPrj g, EmbPrj h, EmbPrj i, EmbPrj j, EmbPrj k, EmbPrj l, EmbPrj m, EmbPrj n, EmbPrj o) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o -> p) -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> R p

module Agda.TypeChecking.Substitute

-- | If $v$ is a record value, <tt>canProject f v</tt> returns its field
--   <tt>f</tt>.
canProject :: QName -> Term -> Maybe (Arg Term)

-- | Eliminate a constructed term.
conApp :: ConHead -> ConInfo -> Args -> Elims -> Term

-- | <tt>defApp f us vs</tt> applies <tt>Def f us</tt> to further arguments
--   <tt>vs</tt>, eliminating top projection redexes. If <tt>us</tt> is not
--   empty, we cannot have a projection redex, since the record argument is
--   the first one.
defApp :: QName -> Elims -> Elims -> Term
argToDontCare :: Arg Term -> Term

-- | Make sure we only drop variable patterns.

-- | <pre>
--   (x:A)-&gt;B(x) <a>piApply</a> [u] = B(u)
--   </pre>
--   
--   Precondition: The type must contain the right number of pis without
--   having to perform any reduction.
--   
--   <tt>piApply</tt> is potentially unsafe, the monadic <tt>piApplyM</tt>
--   is preferable.
piApply :: Type -> Args -> Type

-- | <tt>tel ⊢ (Γ ⊢ lhs ↦ rhs : t)</tt> becomes <tt>tel, Γ ⊢ lhs ↦ rhs :
--   t)</tt> 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

-- | If <tt>permute π : [a]Γ -&gt; [a]Δ</tt>, then <tt>applySubst (renaming
--   _ π) : Term Γ -&gt; Term Δ</tt>
renaming :: forall a. DeBruijn a => Empty -> Permutation -> Substitution' a

-- | If <tt>permute π : [a]Γ -&gt; [a]Δ</tt>, then <tt>applySubst
--   (renamingR π) : Term Δ -&gt; Term Γ</tt>
renamingR :: DeBruijn a => Permutation -> Substitution' a

-- | The permutation should permute the corresponding context.
--   (right-to-left list)
renameP :: Subst t a => Empty -> Permutation -> a -> a
fromPatternSubstitution :: PatternSubstitution -> Substitution
applyPatSubst :: (Subst Term a) => PatternSubstitution -> a -> a

-- | <pre>
--   projDropParsApply proj o args = <a>projDropPars</a> proj o `<tt>apply'</tt> args
--   </pre>
--   
--   This function is an optimization, saving us from construction lambdas
--   we immediately remove through application.
projDropParsApply :: Projection -> ProjOrigin -> Args -> Term
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 <tt>(x1 .. xn : A)</tt> into a telescope.
bindsToTel' :: (Name -> a) -> [Name] -> Dom Type -> ListTel' a
bindsToTel :: [Name] -> Dom Type -> ListTel

-- | Turn a typed binding <tt>(x1 .. xn : A)</tt> 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 <tt>Pi</tt>-types.
telView' :: Type -> TelView

-- | <tt>telView'UpTo n t</tt> takes off the first <tt>n</tt> exposed
--   function types of <tt>t</tt>. Takes off all (exposed ones) if <tt>n
--   &lt; 0</tt>.
telView'UpTo :: Int -> Type -> TelView

-- | <pre>
--   mkPi dom t = telePi (telFromList [dom]) t
--   </pre>
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 <tt>noAbs</tt> bindings.
telePi :: Telescope -> Type -> Type

-- | Everything will be a <a>Abs</a>.
telePi_ :: Telescope -> Type -> Type
teleLam :: Telescope -> Term -> Term

-- | Performs void (<tt>noAbs</tt>) abstraction over telescope.
class TeleNoAbs a
teleNoAbs :: TeleNoAbs a => a -> Term -> Term

-- | In compiled clauses, the variables in the clause body are relative to
--   the pattern variables (including dot patterns) instead of the clause
--   telescope.
compiledClauseBody :: Clause -> Maybe Term

-- | Syntactic <a>Type</a> equality, ignores sort annotations.

-- | Syntactic <a>Term</a> equality, ignores stuff below <tt>DontCare</tt>
--   and sharing.

-- | The `<tt>rule'</tt>, 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 <a>SizeUniv</a>,
--   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

-- | Dependent least upper bound, to assign a level to expressions like
--   <tt>forall i -&gt; Set i</tt>.
--   
--   <tt>dLub s1 i.s2 = omega</tt> if <tt>i</tt> appears in the rigid
--   variables of <tt>s2</tt>.
dLub :: Sort -> Abs 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. <tt>Γ ⊢ IdS : Γ</tt>
IdS :: Substitution' a

-- | Empty substitution, lifts from the empty context. Apply this to closed
--   terms you want to use in a non-empty context. <tt>Γ ⊢ EmptyS : ()</tt>
EmptyS :: Substitution' a

-- | Substitution extension, `<tt>cons'</tt>. <tt> Γ ⊢ u : Aρ Γ ⊢ ρ : Δ
--   ---------------------- Γ ⊢ u :# ρ : Δ, A </tt>
(:#) :: a -> Substitution' a -> Substitution' a

-- | Strengthening substitution. First argument is
--   <tt><b>IMPOSSIBLE</b></tt>. Apply this to a term which does not
--   contain variable 0 to lower all de Bruijn indices by one. <tt> Γ ⊢ ρ :
--   Δ --------------------------- Γ ⊢ Strengthen ρ : Δ, A </tt>
Strengthen :: Empty -> (Substitution' a) -> Substitution' a

-- | Weakning substitution, lifts to an extended context. <tt> Γ ⊢ ρ : Δ
--   ------------------- Γ, Ψ ⊢ Wk |Ψ| ρ : Δ </tt>
Wk :: !Int -> (Substitution' a) -> Substitution' a

-- | Lifting substitution. Use this to go under a binder. <tt>Lift 1 ρ ==
--   var 0 :# Wk 1 ρ</tt>. <tt> Γ ⊢ ρ : Δ ------------------------- Γ, Ψρ ⊢
--   Lift |Ψ| ρ : Δ, Ψ </tt>
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.Class.Subst t a, GHC.Classes.Eq a) => GHC.Classes.Eq (Agda.TypeChecking.Substitute.TelV a)
instance (Agda.TypeChecking.Substitute.Class.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.Class.Subst t a, GHC.Classes.Eq a) => GHC.Classes.Eq (Agda.Syntax.Internal.Tele a)
instance (Agda.TypeChecking.Substitute.Class.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.Class.Apply Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Substitute.Class.Apply Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.Substitute.Class.Apply a => Agda.TypeChecking.Substitute.Class.Apply (Agda.Utils.Pointer.Ptr a)
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term a => Agda.TypeChecking.Substitute.Class.Apply (Agda.Syntax.Internal.Tele a)
instance Agda.TypeChecking.Substitute.Class.Apply Agda.TypeChecking.Monad.Base.Definition
instance Agda.TypeChecking.Substitute.Class.Apply Agda.TypeChecking.Monad.Base.RewriteRule
instance Agda.TypeChecking.Substitute.Class.Apply [Agda.TypeChecking.Positivity.Occurrence.Occurrence]
instance Agda.TypeChecking.Substitute.Class.Apply [Agda.TypeChecking.Monad.Base.Polarity]
instance Agda.TypeChecking.Substitute.Class.Apply [Agda.Syntax.Common.NamedArg (Agda.Syntax.Internal.Pattern' a)]
instance Agda.TypeChecking.Substitute.Class.Apply Agda.TypeChecking.Monad.Base.Projection
instance Agda.TypeChecking.Substitute.Class.Apply Agda.TypeChecking.Monad.Base.ProjLams
instance Agda.TypeChecking.Substitute.Class.Apply Agda.TypeChecking.Monad.Base.Defn
instance Agda.TypeChecking.Substitute.Class.Apply Agda.TypeChecking.Monad.Base.PrimFun
instance Agda.TypeChecking.Substitute.Class.Apply Agda.Syntax.Internal.Clause
instance Agda.TypeChecking.Substitute.Class.Apply Agda.TypeChecking.CompiledClause.CompiledClauses
instance Agda.TypeChecking.Substitute.Class.Apply a => Agda.TypeChecking.Substitute.Class.Apply (Agda.TypeChecking.CompiledClause.WithArity a)
instance Agda.TypeChecking.Substitute.Class.Apply a => Agda.TypeChecking.Substitute.Class.Apply (Agda.TypeChecking.CompiledClause.Case a)
instance Agda.TypeChecking.Substitute.Class.Apply Agda.TypeChecking.Monad.Base.FunctionInverse
instance Agda.TypeChecking.Substitute.Class.Apply Agda.TypeChecking.Monad.Base.DisplayTerm
instance Agda.TypeChecking.Substitute.Class.Apply t => Agda.TypeChecking.Substitute.Class.Apply [t]
instance Agda.TypeChecking.Substitute.Class.Apply t => Agda.TypeChecking.Substitute.Class.Apply (Agda.Syntax.Internal.Blocked t)
instance Agda.TypeChecking.Substitute.Class.Apply t => Agda.TypeChecking.Substitute.Class.Apply (GHC.Base.Maybe t)
instance Agda.TypeChecking.Substitute.Class.Apply v => Agda.TypeChecking.Substitute.Class.Apply (Data.Map.Base.Map k v)
instance Agda.TypeChecking.Substitute.Class.Apply v => Agda.TypeChecking.Substitute.Class.Apply (Data.HashMap.Base.HashMap k v)
instance (Agda.TypeChecking.Substitute.Class.Apply a, Agda.TypeChecking.Substitute.Class.Apply b) => Agda.TypeChecking.Substitute.Class.Apply (a, b)
instance (Agda.TypeChecking.Substitute.Class.Apply a, Agda.TypeChecking.Substitute.Class.Apply b, Agda.TypeChecking.Substitute.Class.Apply c) => Agda.TypeChecking.Substitute.Class.Apply (a, b, c)
instance Agda.Utils.Permutation.DoDrop a => Agda.TypeChecking.Substitute.Class.Apply (Agda.Utils.Permutation.Drop a)
instance Agda.Utils.Permutation.DoDrop a => Agda.TypeChecking.Substitute.Class.Abstract (Agda.Utils.Permutation.Drop a)
instance Agda.TypeChecking.Substitute.Class.Apply Agda.Utils.Permutation.Permutation
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.Utils.Permutation.Permutation
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.Syntax.Internal.Type
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.Syntax.Internal.Telescope
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.TypeChecking.Monad.Base.Definition
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.TypeChecking.Monad.Base.RewriteRule
instance Agda.TypeChecking.Substitute.Class.Abstract [Agda.TypeChecking.Positivity.Occurrence.Occurrence]
instance Agda.TypeChecking.Substitute.Class.Abstract [Agda.TypeChecking.Monad.Base.Polarity]
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.TypeChecking.Monad.Base.Projection
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.TypeChecking.Monad.Base.ProjLams
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.TypeChecking.Monad.Base.Defn
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.TypeChecking.Monad.Base.PrimFun
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.Syntax.Internal.Clause
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.TypeChecking.CompiledClause.CompiledClauses
instance Agda.TypeChecking.Substitute.Class.Abstract a => Agda.TypeChecking.Substitute.Class.Abstract (Agda.TypeChecking.CompiledClause.WithArity a)
instance Agda.TypeChecking.Substitute.Class.Abstract a => Agda.TypeChecking.Substitute.Class.Abstract (Agda.TypeChecking.CompiledClause.Case a)
instance Agda.TypeChecking.Substitute.Class.Abstract Agda.TypeChecking.Monad.Base.FunctionInverse
instance Agda.TypeChecking.Substitute.Class.Abstract t => Agda.TypeChecking.Substitute.Class.Abstract [t]
instance Agda.TypeChecking.Substitute.Class.Abstract t => Agda.TypeChecking.Substitute.Class.Abstract (GHC.Base.Maybe t)
instance Agda.TypeChecking.Substitute.Class.Abstract v => Agda.TypeChecking.Substitute.Class.Abstract (Data.Map.Base.Map k v)
instance Agda.TypeChecking.Substitute.Class.Abstract v => Agda.TypeChecking.Substitute.Class.Abstract (Data.HashMap.Base.HashMap k v)
instance Agda.TypeChecking.Substitute.Class.Subst a a => Agda.TypeChecking.Substitute.Class.Subst a (Agda.Syntax.Internal.Substitution' a)
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Substitute.Class.Subst t a => Agda.TypeChecking.Substitute.Class.Subst t (Agda.Utils.Pointer.Ptr a)
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term a => Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term (Agda.Syntax.Internal.Type' a)
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.Level
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.LevelAtom
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.Syntax.Abstract.Name.Name
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term GHC.Base.String
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.ConPatternInfo
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.Pattern
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.NLPat
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.NLPType
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.RewriteRule
instance Agda.TypeChecking.Substitute.Class.Subst t a => Agda.TypeChecking.Substitute.Class.Subst t (Agda.Syntax.Internal.Blocked a)
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.DisplayForm
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.DisplayTerm
instance Agda.TypeChecking.Substitute.Class.Subst t a => Agda.TypeChecking.Substitute.Class.Subst t (Agda.Syntax.Internal.Tele a)
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.Constraint
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.ModuleParameters
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.Syntax.Abstract.NamedDotPattern
instance Agda.TypeChecking.Substitute.Class.Subst t a => Agda.TypeChecking.Substitute.Class.Subst t (Agda.Syntax.Internal.Elim' a)
instance Agda.TypeChecking.Substitute.Class.Subst t a => Agda.TypeChecking.Substitute.Class.Subst t (Agda.Syntax.Internal.Abs a)
instance Agda.TypeChecking.Substitute.Class.Subst t a => Agda.TypeChecking.Substitute.Class.Subst t (Agda.Syntax.Common.Arg a)
instance Agda.TypeChecking.Substitute.Class.Subst t a => Agda.TypeChecking.Substitute.Class.Subst t (Agda.Syntax.Common.Named name a)
instance Agda.TypeChecking.Substitute.Class.Subst t a => Agda.TypeChecking.Substitute.Class.Subst t (Agda.Syntax.Common.Dom a)
instance Agda.TypeChecking.Substitute.Class.Subst t a => Agda.TypeChecking.Substitute.Class.Subst t (GHC.Base.Maybe a)
instance Agda.TypeChecking.Substitute.Class.Subst t a => Agda.TypeChecking.Substitute.Class.Subst t [a]
instance (GHC.Classes.Ord k, Agda.TypeChecking.Substitute.Class.Subst t a) => Agda.TypeChecking.Substitute.Class.Subst t (Data.Map.Base.Map k a)
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term ()
instance (Agda.TypeChecking.Substitute.Class.Subst t a, Agda.TypeChecking.Substitute.Class.Subst t b) => Agda.TypeChecking.Substitute.Class.Subst t (a, b)
instance (Agda.TypeChecking.Substitute.Class.Subst t a, Agda.TypeChecking.Substitute.Class.Subst t b, Agda.TypeChecking.Substitute.Class.Subst t c) => Agda.TypeChecking.Substitute.Class.Subst t (a, b, c)
instance (Agda.TypeChecking.Substitute.Class.Subst t a, Agda.TypeChecking.Substitute.Class.Subst t b, Agda.TypeChecking.Substitute.Class.Subst t c, Agda.TypeChecking.Substitute.Class.Subst t d) => Agda.TypeChecking.Substitute.Class.Subst t (a, b, c, d)
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Monad.Base.Candidate
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.Syntax.Internal.EqualityView
instance Agda.TypeChecking.Substitute.DeBruijn.DeBruijn Agda.Syntax.Internal.DeBruijnPattern
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.DeBruijnPattern Agda.Syntax.Internal.DeBruijnPattern
instance Agda.TypeChecking.Substitute.TeleNoAbs Agda.TypeChecking.Substitute.ListTel
instance Agda.TypeChecking.Substitute.TeleNoAbs Agda.Syntax.Internal.Telescope
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.Class.Subst t a, GHC.Classes.Eq a) => GHC.Classes.Eq (Agda.Syntax.Internal.Abs a)
instance (Agda.TypeChecking.Substitute.Class.Subst t a, GHC.Classes.Ord a) => GHC.Classes.Ord (Agda.Syntax.Internal.Abs a)
instance (Agda.TypeChecking.Substitute.Class.Subst t a, GHC.Classes.Eq a) => GHC.Classes.Eq (Agda.Syntax.Internal.Elim' a)
instance (Agda.TypeChecking.Substitute.Class.Subst t a, GHC.Classes.Ord a) => GHC.Classes.Ord (Agda.Syntax.Internal.Elim' 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 Data.Semigroup.Semigroup 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 Data.Semigroup.Semigroup 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.DeBruijn Agda.Syntax.Treeless.TTerm
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Treeless.TTerm Agda.Syntax.Treeless.TTerm
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Treeless.TTerm Agda.Syntax.Treeless.TAlt
instance Data.Semigroup.Semigroup Agda.Compiler.Treeless.Subst.Occurs
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

module Agda.Compiler.Treeless.AsPatterns

-- | We lose track of @-patterns in the internal syntax. This pass puts
--   them back.
recoverAsPatterns :: Monad m => TTerm -> m TTerm
instance GHC.Show.Show Agda.Compiler.Treeless.AsPatterns.AsPat


-- | 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.Coverage.Match

-- | Given
--   
--   <ol>
--   <li>the function clauses <tt>cs</tt></li>
--   <li>the patterns <tt>ps</tt></li>
--   </ol>
--   
--   we want to compute a variable index of the split clause to split on
--   next.
--   
--   First, we find the set <tt>cs'</tt> of all the clauses that are
--   instances (via substitutions <tt>rhos</tt>) of the split clause.
--   
--   In these substitutions, we look for a column that has only constructor
--   patterns. We try to split on this column first.
--   
--   Match the given patterns against a list of clauses
match :: [Clause] -> [NamedArg DeBruijnPattern] -> Match (Nat, ([DeBruijnPattern], [Literal]))

-- | Convert the root of a term into a pattern constructor, if possible.
buildPattern :: Term -> Maybe DeBruijnPattern

-- | A pattern that matches anything (modulo eta).
isTrivialPattern :: Pattern' a -> Bool

-- | If matching succeeds, we return the instantiation of the clause
--   pattern vector to obtain the split clause pattern vector, plus the
--   literals of the clause patterns matched against split clause
--   variables.
type MatchResult = Match ([DeBruijnPattern], [Literal])

-- | If matching is inconclusive (<tt>Block</tt>) we want to know which
--   variables are blocking the match.
data Match a

-- | Matches unconditionally.
Yes :: a -> Match a

-- | Definitely does not match.
No :: Match a

-- | Could match if non-empty list of blocking variables is instantiated
--   properly. Also <a>Any</a> is <a>True</a> if all clauses have a result
--   split. (Only then can we do result splitting.)
Block :: Any -> BlockingVars -> Match a

-- | Variable blocking a match.
data BlockingVar
BlockingVar :: Nat -> Maybe [ConHead] -> BlockingVar

-- | De Bruijn index of variable blocking the match.
[blockingVarNo] :: BlockingVar -> Nat

-- | <tt>Nothing</tt> means there is an overlapping match for this
--   variable. This happens if one clause has a constructor pattern at this
--   position, and another a variable. It is also used for "just variable".
--   
--   <tt>Just cons</tt> means that it is an non-overlapping match and
--   <tt>cons</tt> are the encountered constructors.
[blockingVarCons] :: BlockingVar -> Maybe [ConHead]
type BlockingVars = [BlockingVar]

-- | Lens for <a>blockingVarCons</a>.
mapBlockingVarCons :: (Maybe [ConHead] -> Maybe [ConHead]) -> BlockingVar -> BlockingVar
clearBlockingVarCons :: BlockingVar -> BlockingVar
overlapping :: BlockingVars -> BlockingVars

-- | Left dominant merge of blocking vars.
zipBlockingVars :: BlockingVars -> BlockingVars -> BlockingVars

-- | <tt>choice m m'</tt> combines the match results <tt>m</tt> of a
--   function clause with the (already combined) match results $m'$ of the
--   later clauses. It is for skipping clauses that definitely do not match
--   (<a>No</a>). It is left-strict, to be used with <tt>foldr</tt>. If one
--   clause unconditionally matches (<a>Yes</a>) we do not look further.
choice :: Match a -> Match a -> Match a

-- | Could the literal cover (an instantiation of) the split clause
--   pattern? Basically, the split clause pattern needs to be a variable.
--   
--   Note: literal patterns do not occur in the split clause since we
--   cannot split into all possible literals (that would be infeasible).
type MatchLit = Literal -> DeBruijnPattern -> MatchResult

-- | Use this function if literal patterns should not cover a split clause
--   pattern.
noMatchLit :: MatchLit

-- | Use this function if a literal pattern should cover a split clause
--   variable pattern.
yesMatchLit :: MatchLit

-- | Check if a clause could match given generously chosen literals
matchLits :: Clause -> [NamedArg DeBruijnPattern] -> Maybe [Literal]

-- | <tt>matchClause mlit qs i c</tt> checks whether clause <tt>c</tt>
--   number <tt>i</tt> covers a split clause with patterns <tt>qs</tt>.
matchClause :: MatchLit -> [NamedArg DeBruijnPattern] -> Nat -> Clause -> MatchResult

-- | <tt>matchPats mlit ps qs</tt> checks whether a function clause with
--   patterns <tt>ps</tt> covers a split clause with patterns <tt>qs</tt>.
--   
--   Issue 1986: This is accepted: <tt> F : Bool -&gt; Set1 F true = Set F
--   = x -&gt; Set </tt> For the second clause, the split clause is <tt>F
--   false</tt>, so there are more patterns in the split clause than in the
--   considered clause. These additional patterns are simply dropped by
--   <tt>zipWith</tt>. This will result in <tt>mconcat []</tt> which is
--   <tt>Yes []</tt>.
matchPats :: MatchLit -> [NamedArg (Pattern' a)] -> [NamedArg DeBruijnPattern] -> MatchResult

-- | Combine results of checking whether function clause patterns covers
--   split clause patterns.
--   
--   <a>No</a> is dominant: if one function clause pattern is disjoint to
--   the corresponding split clause pattern, then the whole clauses are
--   disjoint.
--   
--   <a>Yes</a> is neutral: for a match, all patterns have to match.
--   
--   <a>Block</a> accumulates variables of the split clause that have to be
--   instantiated (an projection names of copattern matches) to make the
--   split clause an instance of the function clause.

-- | <tt>matchPat mlit p q</tt> checks whether a function clause pattern
--   <tt>p</tt> covers a split clause pattern <tt>q</tt>. There are three
--   results: <tt>Yes rs</tt> means it covers, because <tt>p</tt> is a
--   variable pattern. <tt>rs</tt> collects the instantiations of the
--   variables in <tt>p</tt> s.t. <tt>p[rs] = q</tt>. <tt>No</tt> means it
--   does not cover. <tt>Block [x]</tt> means <tt>p</tt> is a proper
--   instance of <tt>q</tt> and could become a cover if <tt>q</tt> was
--   split on variable <tt>x</tt>.
matchPat :: MatchLit -> Pattern' a -> DeBruijnPattern -> MatchResult
instance GHC.Base.Functor Agda.TypeChecking.Coverage.Match.Match
instance GHC.Show.Show Agda.TypeChecking.Coverage.Match.BlockingVar
instance GHC.Base.Monoid a => Data.Semigroup.Semigroup (Agda.TypeChecking.Coverage.Match.Match a)
instance GHC.Base.Monoid a => GHC.Base.Monoid (Agda.TypeChecking.Coverage.Match.Match a)

module Agda.TypeChecking.LevelConstraints

-- | <tt>simplifyLevelConstraint c cs</tt> turns an <tt>c</tt> into an
--   equality constraint if it is an inequality constraint and the reverse
--   inequality is contained in <tt>cs</tt>.
--   
--   The constraints doesn't necessarily have to live in the same context,
--   but they do need to be universally quanitfied over the context. This
--   function takes care of renaming variables when checking for matches.
simplifyLevelConstraint :: Constraint -> [Constraint] -> 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
primAssoc :: TCM Term
primAssocLeft :: TCM Term
primAssocRight :: TCM Term
primAssocNon :: TCM Term
primPrecedence :: TCM Term
primPrecRelated :: TCM Term
primPrecUnrelated :: TCM Term
primFixity :: TCM Term
primFixityFixity :: 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
primAgdaTCMReduce :: 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
primAgdaTCMIsMacro :: TCM Term
primAgdaTCMWithNormalisation :: 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
builtinAssoc :: String
builtinAssocLeft :: String
builtinAssocRight :: String
builtinAssocNon :: String
builtinPrecedence :: String
builtinPrecRelated :: String
builtinPrecUnrelated :: String
builtinFixity :: String
builtinFixityFixity :: 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
builtinAgdaTCMReduce :: 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
builtinAgdaTCMIsMacro :: String
builtinAgdaTCMWithNormalisation :: 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 <tt>Set</tt>.
--   
--   {--}
--   
--   The type of <tt>Type</tt> would be <tt>Type : Level → Setω</tt> 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 <a>CoinductionKit</a>.
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 <a>EqualityView</a>.
--   
--   Postcondition: type is reduced.
equalityUnview :: EqualityView -> Type
instance Agda.TypeChecking.Monad.Builtin.HasBuiltins m => Agda.TypeChecking.Monad.Builtin.HasBuiltins (Control.Monad.Trans.Maybe.MaybeT m)
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 <a>Open</a> 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 <a>Open</a> the current context. Returns <a>Nothing</a>
--   if current context is not an extension of the context in which the
--   <a>Open</a> was created.
tryOpen :: (Subst t a, MonadReader TCEnv m) => Open a -> m (Maybe a)


-- | 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

-- | Bill a CPS function to an account. Can't handle exceptions.
billToCPS :: MonadBench a m => Account a -> ((b -> m c) -> m c) -> (b -> m 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 ()


-- | Lenses for <a>TCState</a> 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 <a>Benchmark</a> information.
resetAllState :: TCM ()

-- | Restore <a>TCState</a> after performing subcomputation.
--   
--   In contrast to <a>localState</a>, the <a>Benchmark</a> info from the
--   subcomputation is saved.
localTCState :: TCM a -> TCM a

-- | Same as <a>localTCState</a> 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 <a>stAccumStatistics</a>.
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 <a>withScope</a>, 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

-- | 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 ()

-- | Run some computation in a different signature, restore original
--   signature.
withSignature :: Signature -> TCM a -> TCM a
addRewriteRulesFor :: QName -> RewriteRules -> [QName] -> 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)
updateCompiledClauses :: (Maybe CompiledClauses -> Maybe CompiledClauses) -> (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 <a>stPatternSyns</a>.
modifyPatternSyns :: (PatternSynDefns -> PatternSynDefns) -> TCM ()
getPatternSynImports :: TCM PatternSynDefns
lookupPatternSyn :: QName -> TCM PatternSynDefn

-- | Lens getter for <a>Benchmark</a> from <a>TCState</a>.
theBenchmark :: TCState -> Benchmark

-- | Lens map for <a>Benchmark</a>.
updateBenchmark :: (Benchmark -> Benchmark) -> TCState -> TCState

-- | Lens getter for <a>Benchmark</a> from <a>TCM</a>.
getBenchmark :: TCM Benchmark

-- | Lens modify for <a>Benchmark</a>.
modifyBenchmark :: (Benchmark -> Benchmark) -> TCM ()

-- | Run a fresh instance of the TCM (with initial state). <a>Benchmark</a>
--   info is preserved.
freshTCM :: TCM a -> TCM (Either TCErr a)

-- | Look through the signature and reconstruct the instance table.
addImportedInstances :: Signature -> TCM ()

-- | Lens for <a>stInstanceDefs</a>.
updateInstanceDefs :: (TempInstanceTable -> TempInstanceTable) -> (TCState -> TCState)
modifyInstanceDefs :: (TempInstanceTable -> TempInstanceTable) -> TCM ()
getAllInstanceDefs :: TCM TempInstanceTable
getAnonInstanceDefs :: TCM (Set 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 `<tt>class'</tt>.
addNamedInstance :: QName -> QName -> TCM ()


-- | Lenses for <a>CommandLineOptions</a> and <a>PragmaOptions</a>.
--   
--   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.Mutual
noMutualBlock :: TCM a -> TCM a

-- | Pass the current mutual block id or create a new mutual block if we
--   are not already inside on.
inMutualBlock :: (MutualId -> TCM a) -> TCM a

-- | Set the mutual block info for a block, possibly overwriting the
--   existing one.
setMutualBlockInfo :: MutualId -> MutualInfo -> TCM ()

-- | Set the mutual block info for a block if non-existing.
insertMutualBlockInfo :: MutualId -> MutualInfo -> TCM ()

-- | Set the mutual block for a definition.
setMutualBlock :: MutualId -> QName -> TCM ()

-- | Get the current mutual block, if any, otherwise a fresh mutual block
--   is returned.
currentOrFreshMutualBlock :: TCM MutualId
lookupMutualBlock :: MutualId -> TCM MutualBlock

-- | Reverse lookup of a mutual block id for a names.
mutualBlockOf :: QName -> TCM MutualId

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 <a>Left</a> now, and were previously <tt><a>Right</a>
--   something</tt>), then the state is reset (completely, see
--   setIncludeDirs) .
--   
--   An empty list of relative include directories (<tt><a>Left</a>
--   []</tt>) is interpreted as <tt>["."]</tt>.
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

-- | Gets the include directories.
--   
--   Precondition: <a>optAbsoluteIncludePaths</a> must be nonempty (i.e.
--   <a>setCommandLineOptions</a> 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
--   <a>stInteractionOutputCallback</a>).
--   
--   An empty list is interpreted as <tt>["."]</tt>.
setIncludeDirs :: [FilePath] -> RelativeTo -> TCM ()
setInputFile :: FilePath -> TCM ()

-- | Should only be run if <a>hasInputFile</a>.
getInputFile :: TCM AbsolutePath

-- | Return the <a>optInputFile</a> as <a>AbsolutePath</a>, 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
withShowAllArguments' :: Bool -> TCM a -> TCM a
ignoreInterfaces :: TCM Bool
positivityCheckEnabled :: TCM Bool
typeInType :: HasOptions m => m Bool
etaEnabled :: TCM Bool
maxInstanceSearchDepth :: TCM Int

-- | 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 <a>Doc</a> 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 <a>Range</a> of the concrete name is saved as the
--   <a>nameBindingSite</a> of the abstract name.
freshAbstractName :: Fixity' -> Name -> ScopeM Name

-- | <pre>
--   freshAbstractName_ = freshAbstractName noFixity'
--   </pre>
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
--   <a>QuotableName</a> in the body, but a <a>DefinedName</a> 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 WSM = StateT ScopeMemo ScopeM
data ScopeMemo
ScopeMemo :: Ren QName -> [(ModuleName, (ModuleName, Bool))] -> ScopeMemo
[memoNames] :: ScopeMemo -> Ren QName

-- | Bool: did we copy recursively? We need to track this because we don't
--   copy recursively when creating new modules for reexported functions
--   (issue1985), but we might need to copy recursively later.
[memoModules] :: ScopeMemo -> [(ModuleName, (ModuleName, Bool))]
memoToScopeInfo :: ScopeMemo -> ScopeCopyInfo

-- | 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, ScopeCopyInfo)

-- | Apply an import directive and check that all the names mentioned
--   actually exist.
applyImportDirectiveM :: QName -> ImportDirective -> Scope -> ScopeM (ImportDirective, Scope)

-- | A finite map for <tt>ImportedName</tt>s.
lookupImportedName :: (Eq a, Eq b) => ImportedName' a b -> [ImportedName' (a, c) (b, d)] -> ImportedName' c d

-- | Translation of <tt>ImportDirective</tt>.
mapImportDir :: (Eq a, Eq b) => [ImportedName' (a, c) (b, d)] -> [ImportedName' (a, c) (b, d)] -> ImportDirective' a b -> ImportDirective' c d

-- | Translation of <tt>Using or Hiding</tt>.
mapUsing :: (Eq a, Eq b) => [ImportedName' (a, c) (b, d)] -> Using' a b -> Using' c d

-- | Translation of <tt>Renaming</tt>.
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.NamedDotPattern
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 <tt>src/prototyping/mixfix/old</tt>.
--   
--   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


-- | 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.Translation.AbstractToConcrete.FreshName Agda.Syntax.Abstract.Name.Name
instance Agda.Syntax.Translation.AbstractToConcrete.ToConcrete Agda.Syntax.Translation.AbstractToConcrete.BindingPattern Agda.Syntax.Abstract.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 <a>TypeCheckAction</a> to the current log, using the current
--   <a>PostScopeState</a>
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 <a>stLoadedFileCache</a> is <a>Just</a>, with a
--   clean current log. Crashes is <a>stLoadedFileCache</a> 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.Context

-- | Modify the <a>ctxEntry</a> field of a <a>ContextEntry</a>.
modifyContextEntry :: (Dom (Name, Type) -> Dom (Name, Type)) -> ContextEntry -> ContextEntry

-- | Modify all <a>ContextEntry</a>s.
modifyContextEntries :: (Dom (Name, Type) -> Dom (Name, Type)) -> Context -> Context

-- | Modify a <a>Context</a> in a computation.
modifyContext :: MonadTCM tcm => (Context -> Context) -> tcm a -> tcm a
mkContextEntry :: MonadTCM tcm => Dom (Name, Type) -> tcm ContextEntry

-- | Change to top (=empty) context.
--   
--   TODO: currently, this makes the <tt>ModuleParamDict</tt> ill-formed!
inTopContext :: MonadTCM tcm => tcm a -> tcm a

-- | Delete the last <tt>n</tt> bindings from the context.
--   
--   TODO: currently, this makes the <tt>ModuleParamDict</tt> ill-formed!
escapeContext :: MonadTCM tcm => Int -> tcm a -> tcm a

-- | Locally set module parameters for a computation.
withModuleParameters :: ModuleParamDict -> TCM a -> TCM a

-- | Apply a substitution to all module parameters.
updateModuleParameters :: MonadTCM tcm => Substitution -> tcm a -> tcm a

-- | Since the <tt>ModuleParamDict</tt> is relative to the current context,
--   this function should be called everytime the context is extended.
weakenModuleParameters :: MonadTCM tcm => Nat -> tcm a -> tcm a

-- | Get substitution <tt>Γ ⊢ ρ : Γm</tt> where <tt>Γ</tt> is the current
--   context and <tt>Γm</tt> is the module parameter telescope of module
--   <tt>m</tt>.
--   
--   In case the current <a>ModuleParamDict</a> does not know <tt>m</tt>,
--   we return the identity substitution. This is ok for instance if we are
--   outside module <tt>m</tt> (in which case we have to supply all module
--   parameters to any symbol defined within <tt>m</tt> we want to refer).
getModuleParameterSub :: MonadTCM tcm => ModuleName -> tcm Substitution

-- | <tt>addCtx x arg cont</tt> add a variable to the context.
--   
--   Chooses an unused <a>Name</a>.
--   
--   Warning: Does not update module parameter substitution!
addCtx :: MonadTCM tcm => Name -> Dom Type -> tcm a -> tcm a

-- | Pick a concrete name that doesn't shadow anything in the context.
unshadowName :: MonadTCM tcm => Name -> tcm Name

-- | Various specializations of <tt>addCtx</tt>.
class AddContext b
addContext :: (AddContext b, MonadTCM tcm) => b -> tcm a -> tcm a
contextSize :: AddContext b => b -> Nat

-- | Since the module parameter substitution is relative to the current
--   context, we need to weaken it when we extend the context. This
--   function takes care of that.
addContext' :: (MonadTCM tcm, AddContext b) => b -> 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 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 <tt>[var (n - 1), ..., var 0]</tt> for all declarations in
--   the context.
getContextArgs :: (Applicative m, MonadReader TCEnv m) => m Args

-- | Generate <tt>[var (n - 1), ..., var 0]</tt> for all declarations in
--   the context.
getContextTerms :: (Applicative m, MonadReader TCEnv m) => m [Term]

-- | Get the current context as a <a>Telescope</a>.
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

module Agda.TypeChecking.Monad.Closure
enterClosure :: Closure a -> (a -> TCM b) -> TCM b
withClosure :: Closure a -> (a -> TCM b) -> TCM (Closure b)
mapClosure :: (a -> TCM b) -> Closure a -> TCM (Closure b)

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 ()
dropConstraints :: (ProblemConstraint -> Bool) -> TCM ()
putConstraintsToSleep :: (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
buildProblemConstraint_ :: 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.Local

-- | Precondition: must not be called if the module parameter of the
--   current module have been refined or (touched at all).
makeLocal :: Free' a All => a -> TCM (Local a)
makeGlobal :: Free' a All => a -> TCM (Local a)
getLocal :: Subst Term a => Local a -> TCM (Maybe a)

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 <tt>1</tt>.
tick :: String -> TCM ()

-- | Increase specified counter by <tt>n</tt>.
tickN :: String -> Integer -> TCM ()

-- | Set the specified counter to the maximum of its current value and
--   <tt>n</tt>.
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
--   <a>noRange</a>).
setCurrentRange :: HasRange x => x -> TCM a -> TCM a


-- | Functions which map between module names and file names.
--   
--   Note that file name lookups are cached in the <a>TCState</a>. 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 <a>FindError</a> to a <a>TypeError</a>.
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 <a>stModuleToSource</a>.
findFile' :: TopLevelModuleName -> TCM (Either FindError AbsolutePath)

-- | A variant of <a>findFile'</a> which does not require <a>TCM</a>.
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
--   <a>Nothing</a> 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 -> Maybe TopLevelModuleName -> 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!
--   
--   No side effects! Only in <a>TCM</a> to raise errors.
moduleName' :: AbsolutePath -> TCM (Ranged TopLevelModuleName)

-- | A variant of <a>moduleName'</a> 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
rootNameModule :: AbsolutePath -> String
replaceModuleExtension :: String -> AbsolutePath -> AbsolutePath

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.Origin
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Common.ConOrigin
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Common.ProjOrigin
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

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 ()

-- | Run a computation and record which new metas it created.
metasCreatedBy :: TCM a -> TCM (a, Set MetaId)

-- | 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)

-- | Returns every meta-variable occurrence in the given type, except for
--   those in <a>Sort</a>s.
allMetas :: TermLike a => a -> [MetaId]

-- | Create <a>MetaInfo</a> 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 :: Bool -> Range -> Maybe Nat -> TCM InteractionId

-- | Find an interaction point by <a>Range</a> by searching the whole map.
--   
--   O(n): linear in the number of registered interaction points.
findInteractionPoint_ :: Range -> InteractionPoints -> Maybe 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: <tt>O(n)</tt> where <tt>n</tt> is the number of interaction
--   metas.
isInteractionMeta :: MetaId -> TCM (Maybe InteractionId)

-- | Get the information associated to an interaction point.
lookupInteractionPoint :: InteractionId -> TCM InteractionPoint

-- | Get <a>MetaId</a> for an interaction point. Precondition: interaction
--   point is connected.
lookupInteractionId :: InteractionId -> TCM MetaId

-- | Check whether an interaction id is already associated with a meta
--   variable.
lookupInteractionMeta :: InteractionId -> TCM (Maybe MetaId)
lookupInteractionMeta_ :: InteractionId -> InteractionPoints -> Maybe 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
--   <a>PostponedTypeCheckingProblem</a>.
newMeta' :: MetaInstantiation -> MetaInfo -> MetaPriority -> Permutation -> Judgement a -> TCM MetaId

-- | Get the <a>Range</a> for an interaction point.
getInteractionRange :: InteractionId -> TCM Range

-- | Get the <a>Range</a> 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]
isOpenMeta :: MetaInstantiation -> Bool

-- | <tt>listenToMeta l m</tt>: register <tt>l</tt> as a listener to
--   <tt>m</tt>. This is done when the type of l is blocked by <tt>m</tt>.
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]

-- | Freeze some meta variables and return the list of metas that got
--   frozen.
freezeMetas' :: (MetaId -> Bool) -> 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 ()
setFunctionFlag :: FunctionFlag -> Bool -> 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 ()
setDefaultModuleParameters :: ModuleName -> TCM ()

-- | Get a section.
--   
--   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 :: (Functor m, ReadTCState m) => ModuleName -> m (Maybe Section)

-- | Lookup a section telescope.
--   
--   If it doesn't exist, like in hierarchical top-level modules, the
--   section telescope is empty.
lookupSection :: (Functor m, ReadTCState m) => ModuleName -> m Telescope
addDisplayForms :: QName -> TCM ()

-- | Module application (followed by module parameter abstraction).
applySection :: ModuleName -> Telescope -> ModuleName -> Args -> ScopeCopyInfo -> TCM ()
applySection' :: ModuleName -> Telescope -> ModuleName -> Args -> ScopeCopyInfo -> TCM ()

-- | Add a display form to a definition (could be in this or imported
--   signature).
addDisplayForm :: QName -> DisplayForm -> TCM ()
isLocal :: QName -> TCM Bool
getDisplayForms :: QName -> TCM [LocalDisplayForm]

-- | 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

-- | Get the original name of the projection (the current one could be from
--   a module application).
getOriginalProjection :: HasConstInfo m => QName -> m QName
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 <a>Comparison</a>.
getPolarity' :: Comparison -> QName -> TCM [Polarity]

-- | Set the polarity of a definition.
setPolarity :: QName -> [Polarity] -> TCM ()

-- | Get argument occurrence info for argument <tt>i</tt> of definition
--   <tt>d</tt> (never fails).
getArgOccurrence :: QName -> Nat -> TCM Occurrence

-- | Sets the <a>defArgOccurrences</a> for the given identifier (which
--   should already exist in the signature).
setArgOccurrences :: QName -> [Occurrence] -> TCM ()
modifyArgOccurrences :: QName -> ([Occurrence] -> [Occurrence]) -> TCM ()
setTreeless :: QName -> TTerm -> TCM ()
setCompiledArgUse :: QName -> [Bool] -> TCM ()
getCompiled :: QName -> TCM (Maybe Compiled)
getErasedConArgs :: QName -> TCM [Bool]
setErasedConArgs :: QName -> [Bool] -> TCM ()
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

-- | 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
freeVarsToApply :: QName -> TCM Args
getModuleFreeVars :: (Functor m, Applicative m, ReadTCState m, MonadReader TCEnv m) => ModuleName -> 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: <tt> module M₁ Γ where module M₁ Δ where f = ... module M₃ Θ
--   where ... M₁.M₂.f [insert Γ raised by Θ] </tt>
moduleParamsToApply :: ModuleName -> 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 :: MonadReader TCEnv m => m a -> m a

-- | Not in abstract mode. All abstract definitions are opaque.
inConcreteMode :: MonadReader TCEnv m => m a -> m 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 :: (MonadReader TCEnv m, HasConstInfo m) => QName -> (Definition -> m a) -> m a

-- | Check whether a name might have to be treated abstractly (either if
--   we're <a>inAbstractMode</a> or it's not a local name). Returns true
--   for things not declared abstract as well, but for those
--   <a>makeAbstract</a> will have no effect.
treatAbstractly :: MonadReader TCEnv m => QName -> m Bool

-- | Andreas, 2015-07-01: If the <tt>current</tt> module is a weak suffix
--   of the identifier module, we can see through its abstract definition
--   if we are abstract. (Then <tt>treatAbstractly'</tt> returns
--   <tt>False</tt>).
--   
--   If I am not mistaken, then we cannot see definitions in the
--   <tt>where</tt> 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 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 <tt>True</tt> 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 <tt>f</tt> to its first argument, producing the
--   proper postfix projection if <tt>f</tt> is a projection.
applyDef :: ProjOrigin -> 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.TypeChecking.Monad.Signature.HasConstInfo (Control.Monad.Trans.Maybe.MaybeT m)
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
--   <a>Agda.TypeChecking.Reduce</a> or
--   <a>Agda.TypeChecking.Constraints</a> (which import
--   <a>Agda.TypeChecking.Monad</a>).
module Agda.TypeChecking.Monad.SizedTypes

-- | Result of querying whether size variable <tt>i</tt> is bounded by
--   another size.
data BoundedSize

-- | yes <tt>i : Size&lt; t</tt>
BoundedLt :: Term -> BoundedSize
BoundedNo :: BoundedSize

-- | Check if a type is the <a>primSize</a> type. The argument should be
--   <tt>reduce</tt>d.
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 <tt>SIZE</tt> and <tt>SIZELT</tt>.
sizeSort :: Sort

-- | The type of built-in types <tt>SIZE</tt> and <tt>SIZELT</tt>.
sizeUniv :: Type

-- | The built-in type <tt>SIZE</tt> with user-given name.
sizeType_ :: QName -> Type

-- | The built-in type <tt>SIZE</tt>.
sizeType :: TCM Type

-- | The name of <tt>SIZESUC</tt>.
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

-- | <tt>sizeViewComparable v w</tt> checks whether <tt>v &gt;= w</tt>
--   (then <tt>Left</tt>) or <tt>v &lt;= w</tt> (then <tt>Right</tt>). If
--   uncomparable, it returns <tt>NotComparable</tt>.
sizeViewComparable :: DeepSizeView -> DeepSizeView -> SizeViewComparable ()
sizeViewSuc_ :: QName -> DeepSizeView -> DeepSizeView

-- | <tt>sizeViewPred k v</tt> decrements <tt>v</tt> by <tt>k</tt> (must be
--   possible!).
sizeViewPred :: Nat -> DeepSizeView -> DeepSizeView

-- | <tt>sizeViewOffset v</tt> 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

-- | <tt>maxViewCons v ws = max v ws</tt>. It only adds <tt>v</tt> to
--   <tt>ws</tt> if it is not subsumed by an element of <tt>ws</tt>.
maxViewCons :: DeepSizeView -> SizeMaxView -> SizeMaxView

-- | <tt>sizeViewComparableWithMax v ws</tt> tries to find <tt>w</tt> in
--   <tt>ws</tt> that compares with <tt>v</tt> and singles this out.
--   Precondition: <tt>v /= DSizeInv</tt>.
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:
--   
--   <ul>
--   <li>Checks the exit code to see if the compiler exits successfully. If
--   not, then an exception is raised, containing the text the compiler
--   printed to stderr (if any).</li>
--   <li>Uses the debug printout machinery to relay any progress
--   information the compiler prints to stdout.</li>
--   </ul>
callCompiler :: Bool -> FilePath -> [String] -> TCM ()

-- | Generalisation of <tt>callCompiler</tt> where the raised exception is
--   returned.
callCompiler' :: FilePath -> [String] -> TCM (Maybe String)


-- | Translates the Agda builtin nat datatype to arbitrary-precision
--   integers.
--   
--   Philipp, 20150921: At the moment, this optimization is the reason that
--   there is a TAPlus alternative. For Haskell, this can easily be
--   translated to guards. However, in the long term it would be easier for
--   the backends if these things were translated directly to a less-than
--   primitive and if-then-else expressions or similar. This would require
--   us to add some internal Bool-datatype as compiler-internal type and a
--   primitive less-than function, which will be much easier once Treeless
--   is used for whole modules.
--   
--   Ulf, 2015-09-21: No, actually we need the n+k patterns, or at least
--   guards. Representing them with if-then-else would make it a lot harder
--   to do optimisations that analyse case tree, like impossible case
--   elimination.
--   
--   Ulf, 2015-10-30: Guards are actually a better primitive. Fixed that.
module Agda.Compiler.Treeless.Builtin
translateBuiltins :: TTerm -> TCM TTerm

module Agda.Compiler.Treeless.Identity
detectIdentityFunctions :: QName -> TTerm -> TCM TTerm
instance Data.Semigroup.Semigroup Agda.Compiler.Treeless.Identity.IdentityIn


-- | Ensures that all occurences of an abstract name share the same
--   concrete name.
--   
--   Apply this transformation if your backend uses concrete names for
--   identification purposes!
--   
--   The identity of an abstract name is only the nameId, the concrete name
--   is only a naming suggestion. If renaming imports are used, the
--   concrete name may change. This transformation makes sure that all
--   occurences of an abstract name share the same concrete name.
--   
--   This transfomation should be run as the last transformation.
module Agda.Compiler.Treeless.NormalizeNames
normalizeNames :: TTerm -> TCM TTerm

module Agda.Compiler.Treeless.Unused
usedArguments :: QName -> TTerm -> TCM [Bool]
stripUnusedArguments :: [Bool] -> TTerm -> TTerm


-- | Defines UHC Core functions used in other parts of Agda. E.g. parsing
--   Core pragmas uses the <tt>parseCoreCode</tt> function.
module Agda.Compiler.UHC.Pragmas.Parse

-- | Parse a COMPILED_UHC expression.
parseCoreExpr :: String -> Either String CoreExpr
coreExprToCExpr :: CoreExpr -> Either String CExpr

-- | Parse a COMPILED_DATA_UHC specification.
parseCoreData :: MonadTCM m => String -> m CoreType
parseCoreConstrs :: MonadTCM m => CoreType -> [String] -> m [CoreConstr]


-- | Generate an import dependency graph for a given module.
module Agda.Interaction.Highlighting.Dot

-- | Internal module identifiers for construction of dependency graph.
type ModuleId = String
data DotState
DotState :: Map ModuleName ModuleId -> [ModuleId] -> Set (ModuleId, ModuleId) -> DotState

-- | Records already processed modules and maps them to an internal
--   identifier.
[dsModules] :: DotState -> Map ModuleName ModuleId

-- | Supply of internal identifiers.
[dsNameSupply] :: DotState -> [ModuleId]

-- | Edges of dependency graph.
[dsConnection] :: DotState -> Set (ModuleId, ModuleId)
initialDotState :: DotState
type DotM = StateT DotState TCM

-- | Translate a <a>ModuleName</a> to an internal <a>ModuleId</a>. Returns
--   <tt>True</tt> if the <a>ModuleName</a> is new, i.e., has not been
--   encountered before and is thus added to the map of processed modules.
addModule :: ModuleName -> DotM (ModuleId, Bool)

-- | Add an arc from importer to imported.
addConnection :: ModuleId -> ModuleId -> DotM ()

-- | Recursively build import graph, starting from given <a>Interface</a>.
--   Modifies the state in <a>DotM</a> and returns the <a>ModuleId</a> of
--   the <a>Interface</a>.
dottify :: Interface -> DotM ModuleId

-- | Generate a .dot file for the import graph starting with the given
--   <a>Interface</a> and write it to the file specified by the command
--   line option.
generateDot :: Interface -> TCM ()


-- | Functions which give precise syntax highlighting info to Emacs.
module Agda.Interaction.Highlighting.Emacs

-- | Turns syntax highlighting information into a list of S-expressions.
lispifyHighlightingInfo :: HighlightingInfo -> ModuleToSource -> TCM (Lisp String)


-- | Function for generating highlighted, hyperlinked HTML from Agda
--   sources.
module Agda.Interaction.Highlighting.HTML

-- | Generates HTML files from all the sources which have been visited
--   during the type checking phase.
--   
--   This function should only be called after type checking has completed
--   successfully.
generateHTML :: TCM ()

-- | The name of the default CSS file.
defaultCSSFile :: FilePath

-- | Prepare information for HTML page generation.
--   
--   The page generator receives the file path of the module, the top level
--   module name of the module and the highlighting information of the
--   module.
generateHTMLWithPageGen :: (FilePath -> TopLevelModuleName -> CompressedFile -> TCM ()) -> TCM ()

-- | Generates a highlighted, hyperlinked version of the given module.
generatePage :: (FilePath -> FilePath -> String -> String) -> FilePath -> TopLevelModuleName -> TCM ()

-- | Constructs the web page, including headers.
page :: FilePath -> TopLevelModuleName -> Html -> String

-- | Constructs token stream ready to print.
tokenStream :: String -> CompressedFile -> [(Int, String, Aspects)]

-- | Constructs the HTML displaying the code.
code :: [(Int, String, Aspects)] -> Html


-- | Function for generating highlighted and aligned LaTeX from literate
--   Agda source.
module Agda.Interaction.Highlighting.LaTeX

-- | The only exported function.
generateLaTeX :: Interface -> TCM ()
instance GHC.Show.Show Agda.Interaction.Highlighting.LaTeX.Debug
instance GHC.Classes.Eq Agda.Interaction.Highlighting.LaTeX.Debug
instance GHC.Show.Show Agda.Interaction.Highlighting.LaTeX.Token

module Agda.Interaction.Highlighting.Vim
vimFile :: FilePath -> FilePath
escape :: String -> String
wordBounded :: String -> String
keyword :: String -> [String] -> String
match :: String -> [String] -> String
matches :: [String] -> [String] -> [String] -> [String] -> [String] -> [String] -> [String]
toVim :: NamesInScope -> String
generateVimFile :: FilePath -> TCM ()

module Agda.Interaction.Monad

-- | Interaction monad.
type IM = TCMT (InputT IO)
runIM :: IM a -> TCM a

-- | Line reader. The line reader history is not stored between sessions.
readline :: String -> IM (Maybe String)

module Agda.Syntax.Abstract.Pretty
showA :: (Show c, ToConcrete a c) => a -> TCM String
prettyA :: (Pretty c, ToConcrete a c) => a -> TCM Doc
prettyAs :: (Pretty c, ToConcrete a [c]) => a -> TCM Doc

-- | Variant of <a>showA</a> which does not insert outermost parentheses.
showATop :: (Show c, ToConcrete a c) => a -> TCM String

-- | Variant of <a>prettyA</a> which does not insert outermost parentheses.
prettyATop :: (Pretty c, ToConcrete a c) => a -> TCM Doc

module Agda.Syntax.IdiomBrackets
parseIdiomBrackets :: Range -> Expr -> ScopeM Expr


-- | Sanity checking for internal syntax. Mostly checking variable scoping.
module Agda.Syntax.Internal.SanityCheck
sanityCheckVars :: (Pretty a, FreeVS a) => Telescope -> a -> TCM ()

-- | Check that <tt>Γ ⊢ ρ : Δ</tt>.
sanityCheckSubst :: (Pretty a, FreeVS a) => Telescope -> Substitution' a -> Telescope -> TCM ()

module Agda.Syntax.Translation.ReflectedToAbstract
type Names = [Name]
type WithNames a = ReaderT Names TCM a

-- | Adds a new unique name to the current context.
withName :: String -> (Name -> WithNames a) -> WithNames a

-- | Returns the name of the variable with the given de Bruijn index.
askName :: Int -> WithNames (Maybe Name)
class ToAbstract r a | r -> a
toAbstract :: ToAbstract r a => r -> WithNames a

-- | Translate reflected syntax to abstract, using the names from the
--   current typechecking context.
toAbstract_ :: ToAbstract r a => r -> TCM a

-- | Drop implicit arguments unless --show-implicit is on.
toAbstractWithoutImplicit :: ToAbstract r a => r -> TCM a
mkDef :: QName -> TCM Expr
mkSet :: Expr -> Expr
toAbstractPats :: [Arg Pattern] -> WithNames (Names, [NamedArg Pattern])
instance Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract r a => Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract (Agda.Syntax.Common.Named name r) (Agda.Syntax.Common.Named name a)
instance Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract r a => Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract (Agda.Syntax.Common.Arg r) (Agda.Syntax.Common.NamedArg a)
instance Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract [Agda.Syntax.Common.Arg Agda.Syntax.Reflected.Term] [Agda.Syntax.Common.NamedArg Agda.Syntax.Abstract.Expr]
instance Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract r Agda.Syntax.Abstract.Expr => Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract (Agda.Syntax.Common.Dom r, Agda.Syntax.Abstract.Name.Name) Agda.Syntax.Abstract.TypedBindings
instance Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract (Agda.Syntax.Abstract.Expr, Agda.Syntax.Reflected.Elim) Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract (Agda.Syntax.Abstract.Expr, Agda.Syntax.Reflected.Elims) Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract r a => Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract (Agda.Syntax.Reflected.Abs r) (a, Agda.Syntax.Abstract.Name.Name)
instance Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract Agda.Syntax.Literal.Literal Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract Agda.Syntax.Reflected.Term Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract Agda.Syntax.Reflected.Sort Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract Agda.Syntax.Reflected.Pattern (Agda.Syntax.Translation.ReflectedToAbstract.Names, Agda.Syntax.Abstract.Pattern)
instance Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract (Agda.Syntax.Abstract.Name.QNamed Agda.Syntax.Reflected.Clause) Agda.Syntax.Abstract.Clause
instance Agda.Syntax.Translation.ReflectedToAbstract.ToAbstract [Agda.Syntax.Abstract.Name.QNamed Agda.Syntax.Reflected.Clause] [Agda.Syntax.Abstract.Clause]

module Agda.Termination.RecCheck
recursive :: [QName] -> TCM Bool

-- | <tt>anysDef names a</tt> returns all definitions from <tt>names</tt>
--   that are used in <tt>a</tt>.
anyDefs :: GetDefs a => [QName] -> a -> TCM [QName]

module Agda.TypeChecking.DropArgs

-- | When making a function projection-like, we drop the first <tt>n</tt>
--   arguments.
class DropArgs a
dropArgs :: DropArgs a => Int -> a -> a

-- | NOTE: This creates telescopes with unbound de Bruijn indices.

-- | NOTE: does not work for recursive functions.

-- | To drop the first <tt>n</tt> arguments in a compiled clause, we reduce
--   the split argument indices by <tt>n</tt> and drop <tt>n</tt> arguments
--   from the bodies. NOTE: this only works for non-recursive functions, we
--   are not dropping arguments to recursive calls in bodies.
instance Agda.TypeChecking.DropArgs.DropArgs a => Agda.TypeChecking.DropArgs.DropArgs (GHC.Base.Maybe a)
instance Agda.TypeChecking.DropArgs.DropArgs Agda.Syntax.Internal.Telescope
instance Agda.TypeChecking.DropArgs.DropArgs Agda.Utils.Permutation.Permutation
instance Agda.TypeChecking.DropArgs.DropArgs Agda.Syntax.Internal.Clause
instance Agda.TypeChecking.DropArgs.DropArgs Agda.TypeChecking.Monad.Base.FunctionInverse
instance Agda.TypeChecking.DropArgs.DropArgs Agda.TypeChecking.CompiledClause.CompiledClauses


-- | Irrelevant function types.
module Agda.TypeChecking.Irrelevance

-- | Prepare parts of a parameter telescope for abstraction in constructors
--   and projections.
hideAndRelParams :: Dom a -> Dom a

-- | Used to modify context when going into a <tt>rel</tt> argument.
inverseApplyRelevance :: Relevance -> Dom a -> Dom a

-- | Compose two relevance flags. This function is used to update the
--   relevance information on pattern variables <tt>a</tt> after a match
--   against something <tt>rel</tt>.
applyRelevance :: Relevance -> Dom a -> Dom a

-- | Modify the context whenever going from the l.h.s. (term side) of the
--   typing judgement to the r.h.s. (type side).
workOnTypes :: TCM a -> TCM a

-- | Internal workhorse, expects value of --experimental-irrelevance flag
--   as argument.
workOnTypes' :: Bool -> TCM a -> TCM a

-- | (Conditionally) wake up irrelevant variables and make them relevant.
--   For instance, in an irrelevant function argument otherwise irrelevant
--   variables may be used, so they are awoken before type checking the
--   argument.
applyRelevanceToContext :: Relevance -> TCM a -> TCM a

-- | Wake up irrelevant variables and make them relevant. For instance, in
--   an irrelevant function argument otherwise irrelevant variables may be
--   used, so they are awoken before type checking the argument.
wakeIrrelevantVars :: TCM a -> TCM a

module Agda.TypeChecking.MetaVars.Mention
class MentionsMeta t
mentionsMeta :: MentionsMeta t => MetaId -> t -> Bool
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta Agda.Syntax.Internal.Term
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta Agda.Syntax.Internal.Level
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta Agda.Syntax.Internal.LevelAtom
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta Agda.Syntax.Internal.Type
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta t => Agda.TypeChecking.MetaVars.Mention.MentionsMeta (Agda.Syntax.Internal.Abs t)
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta t => Agda.TypeChecking.MetaVars.Mention.MentionsMeta (Agda.Syntax.Common.Arg t)
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta t => Agda.TypeChecking.MetaVars.Mention.MentionsMeta (Agda.Syntax.Common.Dom t)
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta t => Agda.TypeChecking.MetaVars.Mention.MentionsMeta [t]
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta t => Agda.TypeChecking.MetaVars.Mention.MentionsMeta (GHC.Base.Maybe t)
instance (Agda.TypeChecking.MetaVars.Mention.MentionsMeta a, Agda.TypeChecking.MetaVars.Mention.MentionsMeta b) => Agda.TypeChecking.MetaVars.Mention.MentionsMeta (a, b)
instance (Agda.TypeChecking.MetaVars.Mention.MentionsMeta a, Agda.TypeChecking.MetaVars.Mention.MentionsMeta b, Agda.TypeChecking.MetaVars.Mention.MentionsMeta c) => Agda.TypeChecking.MetaVars.Mention.MentionsMeta (a, b, c)
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta a => Agda.TypeChecking.MetaVars.Mention.MentionsMeta (Agda.TypeChecking.Monad.Base.Closure a)
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta Agda.Syntax.Internal.Elim
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta a => Agda.TypeChecking.MetaVars.Mention.MentionsMeta (Agda.Syntax.Internal.Tele a)
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta Agda.TypeChecking.Monad.Base.ProblemConstraint
instance Agda.TypeChecking.MetaVars.Mention.MentionsMeta Agda.TypeChecking.Monad.Base.Constraint


-- | Tools to manipulate patterns in abstract syntax in the TCM (type
--   checking monad).
module Agda.TypeChecking.Patterns.Abstract

-- | Expand literal integer pattern into suc/zero constructor patterns.
expandLitPattern :: NamedArg Pattern -> TCM (NamedArg Pattern)

-- | Expand away (deeply) all pattern synonyms in a pattern.
class ExpandPatternSynonyms a
expandPatternSynonyms :: ExpandPatternSynonyms a => a -> TCM a
instance Agda.TypeChecking.Patterns.Abstract.ExpandPatternSynonyms a => Agda.TypeChecking.Patterns.Abstract.ExpandPatternSynonyms (GHC.Base.Maybe a)
instance Agda.TypeChecking.Patterns.Abstract.ExpandPatternSynonyms a => Agda.TypeChecking.Patterns.Abstract.ExpandPatternSynonyms [a]
instance Agda.TypeChecking.Patterns.Abstract.ExpandPatternSynonyms a => Agda.TypeChecking.Patterns.Abstract.ExpandPatternSynonyms (Agda.Syntax.Common.Arg a)
instance Agda.TypeChecking.Patterns.Abstract.ExpandPatternSynonyms a => Agda.TypeChecking.Patterns.Abstract.ExpandPatternSynonyms (Agda.Syntax.Common.Named n a)
instance Agda.TypeChecking.Patterns.Abstract.ExpandPatternSynonyms a => Agda.TypeChecking.Patterns.Abstract.ExpandPatternSynonyms (Agda.Syntax.Concrete.FieldAssignment' a)
instance Agda.TypeChecking.Patterns.Abstract.ExpandPatternSynonyms Agda.Syntax.Abstract.Pattern

module Agda.TypeChecking.Reduce.Monad
constructorForm :: Term -> ReduceM Term
enterClosure :: Closure a -> (a -> ReduceM b) -> ReduceM b
underAbstraction_ :: Subst t a => Abs a -> (a -> ReduceM b) -> ReduceM b

-- | 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
isInstantiatedMeta :: MetaId -> ReduceM Bool
lookupMeta :: MetaId -> ReduceM MetaVariable
traceSLn :: HasOptions m => VerboseKey -> Int -> String -> m a -> m a
traceSDoc :: VerboseKey -> Int -> TCM Doc -> ReduceM a -> ReduceM a
askR :: ReduceM ReduceEnv

-- | Apply a function if a certain verbosity level is activated.
--   
--   Precondition: The level must be non-negative.
applyWhenVerboseS :: HasOptions m => VerboseKey -> Int -> (m a -> m a) -> m a -> m a
instance Agda.TypeChecking.Monad.Options.HasOptions Agda.TypeChecking.Monad.Base.ReduceM
instance Agda.TypeChecking.Monad.Builtin.HasBuiltins Agda.TypeChecking.Monad.Base.ReduceM
instance Agda.TypeChecking.Monad.Signature.HasConstInfo Agda.TypeChecking.Monad.Base.ReduceM


-- | Compute eta short normal forms.
module Agda.TypeChecking.EtaContract
data BinAppView
App :: Term -> (Arg Term) -> BinAppView
NoApp :: Term -> BinAppView
binAppView :: Term -> BinAppView

-- | Contracts all eta-redexes it sees without reducing.
etaContract :: (MonadReader TCEnv m, HasConstInfo m, HasOptions m, TermLike a) => a -> m a
etaOnce :: (MonadReader TCEnv m, HasConstInfo m, HasOptions m) => Term -> m Term

module Agda.TypeChecking.Reduce
instantiate :: Instantiate a => a -> TCM a
instantiateFull :: InstantiateFull a => a -> TCM a
reduce :: Reduce a => a -> TCM a
reduceB :: Reduce a => a -> TCM (Blocked a)
normalise :: Normalise a => a -> TCM a
simplify :: Simplify a => a -> TCM a

-- | Meaning no metas left in the instantiation.
isFullyInstantiatedMeta :: MetaId -> TCM Bool

-- | Instantiate something. Results in an open meta variable or a non meta.
--   Doesn't do any reduction, and preserves blocking tags (when blocking
--   meta is uninstantiated).
class Instantiate t
instantiate' :: Instantiate t => t -> ReduceM t

-- | Case on whether a term is blocked on a meta (or is a meta). That means
--   it can change its shape when the meta is instantiated.
ifBlocked :: MonadTCM tcm => Term -> (MetaId -> Term -> tcm a) -> (Term -> tcm a) -> tcm a

-- | Case on whether a type is blocked on a meta (or is a meta).
ifBlockedType :: MonadTCM tcm => Type -> (MetaId -> Type -> tcm a) -> (Type -> tcm a) -> tcm a
class Reduce t where reduce' t = ignoreBlocking <$> reduceB' t reduceB' t = notBlocked <$> reduce' t
reduce' :: Reduce t => t -> ReduceM t
reduceB' :: Reduce t => t -> ReduceM (Blocked t)
maybeFastReduceTerm :: Term -> ReduceM (Blocked Term)
slowReduceTerm :: Term -> ReduceM (Blocked Term)
unfoldCorecursionE :: Elim -> ReduceM (Blocked Elim)
unfoldCorecursion :: Term -> ReduceM (Blocked Term)

-- | If the first argument is <a>True</a>, then a single delayed clause may
--   be unfolded.
unfoldDefinition :: Bool -> (Term -> ReduceM (Blocked Term)) -> Term -> QName -> Args -> ReduceM (Blocked Term)
unfoldDefinitionE :: Bool -> (Term -> ReduceM (Blocked Term)) -> Term -> QName -> Elims -> ReduceM (Blocked Term)
unfoldDefinition' :: Bool -> (Simplification -> Term -> ReduceM (Simplification, Blocked Term)) -> Term -> QName -> Elims -> ReduceM (Simplification, Blocked Term)
unfoldDefinitionStep :: Bool -> Term -> QName -> Elims -> ReduceM (Reduced (Blocked Term) Term)

-- | Reduce a non-primitive definition if it is a copy linking to another
--   def.
reduceDefCopy :: QName -> Elims -> TCM (Reduced () Term)

-- | Reduce simple (single clause) definitions.
reduceHead :: Term -> TCM (Blocked Term)
reduceHead' :: Term -> ReduceM (Blocked Term)

-- | Apply a definition using the compiled clauses, or fall back to
--   ordinary clauses if no compiled clauses exist.
appDef_ :: QName -> Term -> [Clause] -> Maybe CompiledClauses -> RewriteRules -> MaybeReducedArgs -> ReduceM (Reduced (Blocked Term) Term)
appDefE_ :: QName -> Term -> [Clause] -> Maybe CompiledClauses -> RewriteRules -> MaybeReducedElims -> ReduceM (Reduced (Blocked Term) Term)

-- | Apply a defined function to it's arguments, using the compiled
--   clauses. The original term is the first argument applied to the third.
appDef :: Term -> CompiledClauses -> RewriteRules -> MaybeReducedArgs -> ReduceM (Reduced (Blocked Term) Term)
appDefE :: Term -> CompiledClauses -> RewriteRules -> MaybeReducedElims -> ReduceM (Reduced (Blocked Term) Term)

-- | Apply a defined function to it's arguments, using the original
--   clauses.
appDef' :: Term -> [Clause] -> RewriteRules -> MaybeReducedArgs -> ReduceM (Reduced (Blocked Term) Term)
appDefE' :: Term -> [Clause] -> RewriteRules -> MaybeReducedElims -> ReduceM (Reduced (Blocked Term) Term)

-- | Only unfold definitions if this leads to simplification which means
--   that a constructor/literal pattern is matched.
class Simplify t
simplify' :: Simplify t => t -> ReduceM t
simplifyBlocked' :: Simplify t => Blocked t -> ReduceM t
class Normalise t
normalise' :: Normalise t => t -> ReduceM t

-- | <tt>instantiateFull'</tt> <a>instantiate</a>s metas everywhere (and
--   recursively) but does not <a>reduce</a>.
class InstantiateFull t
instantiateFull' :: InstantiateFull t => t -> ReduceM t
instance Agda.TypeChecking.Reduce.Instantiate Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Reduce.Instantiate Agda.Syntax.Internal.Level
instance Agda.TypeChecking.Reduce.Instantiate Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.Reduce.Instantiate Agda.Syntax.Internal.LevelAtom
instance Agda.TypeChecking.Reduce.Instantiate a => Agda.TypeChecking.Reduce.Instantiate (Agda.Syntax.Internal.Blocked a)
instance Agda.TypeChecking.Reduce.Instantiate Agda.Syntax.Internal.Type
instance Agda.TypeChecking.Reduce.Instantiate Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.Reduce.Instantiate Agda.Syntax.Internal.Elim
instance Agda.TypeChecking.Reduce.Instantiate t => Agda.TypeChecking.Reduce.Instantiate (Agda.Syntax.Internal.Abs t)
instance Agda.TypeChecking.Reduce.Instantiate t => Agda.TypeChecking.Reduce.Instantiate (Agda.Syntax.Common.Arg t)
instance Agda.TypeChecking.Reduce.Instantiate t => Agda.TypeChecking.Reduce.Instantiate (Agda.Syntax.Common.Dom t)
instance Agda.TypeChecking.Reduce.Instantiate t => Agda.TypeChecking.Reduce.Instantiate [t]
instance (Agda.TypeChecking.Reduce.Instantiate a, Agda.TypeChecking.Reduce.Instantiate b) => Agda.TypeChecking.Reduce.Instantiate (a, b)
instance (Agda.TypeChecking.Reduce.Instantiate a, Agda.TypeChecking.Reduce.Instantiate b, Agda.TypeChecking.Reduce.Instantiate c) => Agda.TypeChecking.Reduce.Instantiate (a, b, c)
instance Agda.TypeChecking.Reduce.Instantiate a => Agda.TypeChecking.Reduce.Instantiate (Agda.TypeChecking.Monad.Base.Closure a)
instance Agda.TypeChecking.Reduce.Instantiate Agda.Syntax.Internal.Telescope
instance Agda.TypeChecking.Reduce.Instantiate Agda.TypeChecking.Monad.Base.Constraint
instance Agda.TypeChecking.Reduce.Instantiate e => Agda.TypeChecking.Reduce.Instantiate (Data.Map.Base.Map k e)
instance Agda.TypeChecking.Reduce.Instantiate Agda.TypeChecking.Monad.Base.Candidate
instance Agda.TypeChecking.Reduce.Instantiate Agda.Syntax.Internal.EqualityView
instance Agda.TypeChecking.Reduce.Reduce Agda.Syntax.Internal.Type
instance Agda.TypeChecking.Reduce.Reduce Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.Reduce.Reduce Agda.Syntax.Internal.Elim
instance Agda.TypeChecking.Reduce.Reduce Agda.Syntax.Internal.Level
instance Agda.TypeChecking.Reduce.Reduce Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.Reduce.Reduce Agda.Syntax.Internal.LevelAtom
instance (Agda.TypeChecking.Substitute.Class.Subst t a, Agda.TypeChecking.Reduce.Reduce a) => Agda.TypeChecking.Reduce.Reduce (Agda.Syntax.Internal.Abs a)
instance Agda.TypeChecking.Reduce.Reduce t => Agda.TypeChecking.Reduce.Reduce [t]
instance Agda.TypeChecking.Reduce.Reduce t => Agda.TypeChecking.Reduce.Reduce (Agda.Syntax.Common.Arg t)
instance Agda.TypeChecking.Reduce.Reduce t => Agda.TypeChecking.Reduce.Reduce (Agda.Syntax.Common.Dom t)
instance (Agda.TypeChecking.Reduce.Reduce a, Agda.TypeChecking.Reduce.Reduce b) => Agda.TypeChecking.Reduce.Reduce (a, b)
instance (Agda.TypeChecking.Reduce.Reduce a, Agda.TypeChecking.Reduce.Reduce b, Agda.TypeChecking.Reduce.Reduce c) => Agda.TypeChecking.Reduce.Reduce (a, b, c)
instance Agda.TypeChecking.Reduce.Reduce Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Reduce.Reduce a => Agda.TypeChecking.Reduce.Reduce (Agda.TypeChecking.Monad.Base.Closure a)
instance Agda.TypeChecking.Reduce.Reduce Agda.Syntax.Internal.Telescope
instance Agda.TypeChecking.Reduce.Reduce Agda.TypeChecking.Monad.Base.Constraint
instance Agda.TypeChecking.Reduce.Reduce e => Agda.TypeChecking.Reduce.Reduce (Data.Map.Base.Map k e)
instance Agda.TypeChecking.Reduce.Reduce Agda.TypeChecking.Monad.Base.Candidate
instance Agda.TypeChecking.Reduce.Reduce Agda.Syntax.Internal.EqualityView
instance Agda.TypeChecking.Reduce.Simplify Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Reduce.Simplify Agda.Syntax.Internal.Type
instance Agda.TypeChecking.Reduce.Simplify Agda.Syntax.Internal.Elim
instance Agda.TypeChecking.Reduce.Simplify Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.Reduce.Simplify Agda.Syntax.Internal.Level
instance Agda.TypeChecking.Reduce.Simplify Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.Reduce.Simplify Agda.Syntax.Internal.LevelAtom
instance (Agda.TypeChecking.Substitute.Class.Subst t a, Agda.TypeChecking.Reduce.Simplify a) => Agda.TypeChecking.Reduce.Simplify (Agda.Syntax.Internal.Abs a)
instance Agda.TypeChecking.Reduce.Simplify t => Agda.TypeChecking.Reduce.Simplify (Agda.Syntax.Common.Arg t)
instance Agda.TypeChecking.Reduce.Simplify t => Agda.TypeChecking.Reduce.Simplify (Agda.Syntax.Common.Named name t)
instance Agda.TypeChecking.Reduce.Simplify t => Agda.TypeChecking.Reduce.Simplify (Agda.Syntax.Common.Dom t)
instance Agda.TypeChecking.Reduce.Simplify t => Agda.TypeChecking.Reduce.Simplify [t]
instance Agda.TypeChecking.Reduce.Simplify e => Agda.TypeChecking.Reduce.Simplify (Data.Map.Base.Map k e)
instance Agda.TypeChecking.Reduce.Simplify a => Agda.TypeChecking.Reduce.Simplify (GHC.Base.Maybe a)
instance (Agda.TypeChecking.Reduce.Simplify a, Agda.TypeChecking.Reduce.Simplify b) => Agda.TypeChecking.Reduce.Simplify (a, b)
instance (Agda.TypeChecking.Reduce.Simplify a, Agda.TypeChecking.Reduce.Simplify b, Agda.TypeChecking.Reduce.Simplify c) => Agda.TypeChecking.Reduce.Simplify (a, b, c)
instance Agda.TypeChecking.Reduce.Simplify a => Agda.TypeChecking.Reduce.Simplify (Agda.TypeChecking.Monad.Base.Closure a)
instance (Agda.TypeChecking.Substitute.Class.Subst t a, Agda.TypeChecking.Reduce.Simplify a) => Agda.TypeChecking.Reduce.Simplify (Agda.Syntax.Internal.Tele a)
instance Agda.TypeChecking.Reduce.Simplify Agda.TypeChecking.Monad.Base.ProblemConstraint
instance Agda.TypeChecking.Reduce.Simplify Agda.TypeChecking.Monad.Base.Constraint
instance Agda.TypeChecking.Reduce.Simplify GHC.Types.Bool
instance Agda.TypeChecking.Reduce.Simplify Agda.TypeChecking.Monad.Base.DisplayForm
instance Agda.TypeChecking.Reduce.Simplify Agda.TypeChecking.Monad.Base.Candidate
instance Agda.TypeChecking.Reduce.Simplify Agda.Syntax.Internal.EqualityView
instance Agda.TypeChecking.Reduce.Normalise Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.Reduce.Normalise Agda.Syntax.Internal.Type
instance Agda.TypeChecking.Reduce.Normalise Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Reduce.Normalise Agda.Syntax.Internal.Elim
instance Agda.TypeChecking.Reduce.Normalise Agda.Syntax.Internal.Level
instance Agda.TypeChecking.Reduce.Normalise Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.Reduce.Normalise Agda.Syntax.Internal.LevelAtom
instance (Agda.TypeChecking.Substitute.Class.Subst t a, Agda.TypeChecking.Reduce.Normalise a) => Agda.TypeChecking.Reduce.Normalise (Agda.Syntax.Internal.Abs a)
instance Agda.TypeChecking.Reduce.Normalise t => Agda.TypeChecking.Reduce.Normalise (Agda.Syntax.Common.Arg t)
instance Agda.TypeChecking.Reduce.Normalise t => Agda.TypeChecking.Reduce.Normalise (Agda.Syntax.Common.Named name t)
instance Agda.TypeChecking.Reduce.Normalise t => Agda.TypeChecking.Reduce.Normalise (Agda.Syntax.Common.Dom t)
instance Agda.TypeChecking.Reduce.Normalise t => Agda.TypeChecking.Reduce.Normalise [t]
instance (Agda.TypeChecking.Reduce.Normalise a, Agda.TypeChecking.Reduce.Normalise b) => Agda.TypeChecking.Reduce.Normalise (a, b)
instance (Agda.TypeChecking.Reduce.Normalise a, Agda.TypeChecking.Reduce.Normalise b, Agda.TypeChecking.Reduce.Normalise c) => Agda.TypeChecking.Reduce.Normalise (a, b, c)
instance Agda.TypeChecking.Reduce.Normalise a => Agda.TypeChecking.Reduce.Normalise (Agda.TypeChecking.Monad.Base.Closure a)
instance (Agda.TypeChecking.Substitute.Class.Subst t a, Agda.TypeChecking.Reduce.Normalise a) => Agda.TypeChecking.Reduce.Normalise (Agda.Syntax.Internal.Tele a)
instance Agda.TypeChecking.Reduce.Normalise Agda.TypeChecking.Monad.Base.ProblemConstraint
instance Agda.TypeChecking.Reduce.Normalise Agda.TypeChecking.Monad.Base.Constraint
instance Agda.TypeChecking.Reduce.Normalise GHC.Types.Bool
instance Agda.TypeChecking.Reduce.Normalise GHC.Types.Int
instance Agda.TypeChecking.Reduce.Normalise GHC.Types.Char
instance Agda.TypeChecking.Reduce.Normalise Agda.Syntax.Internal.ConPatternInfo
instance Agda.TypeChecking.Reduce.Normalise Agda.Syntax.Internal.DBPatVar
instance Agda.TypeChecking.Reduce.Normalise a => Agda.TypeChecking.Reduce.Normalise (Agda.Syntax.Internal.Pattern' a)
instance Agda.TypeChecking.Reduce.Normalise Agda.TypeChecking.Monad.Base.DisplayForm
instance Agda.TypeChecking.Reduce.Normalise e => Agda.TypeChecking.Reduce.Normalise (Data.Map.Base.Map k e)
instance Agda.TypeChecking.Reduce.Normalise a => Agda.TypeChecking.Reduce.Normalise (GHC.Base.Maybe a)
instance Agda.TypeChecking.Reduce.Normalise Agda.TypeChecking.Monad.Base.Candidate
instance Agda.TypeChecking.Reduce.Normalise Agda.Syntax.Internal.EqualityView
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Abstract.Name.Name
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.Reduce.InstantiateFull a => Agda.TypeChecking.Reduce.InstantiateFull (Agda.Syntax.Internal.Type' a)
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Internal.Level
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Internal.LevelAtom
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Internal.Substitution
instance Agda.TypeChecking.Reduce.InstantiateFull GHC.Types.Bool
instance Agda.TypeChecking.Reduce.InstantiateFull GHC.Types.Int
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Internal.ConPatternInfo
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Internal.DBPatVar
instance Agda.TypeChecking.Reduce.InstantiateFull a => Agda.TypeChecking.Reduce.InstantiateFull (Agda.Syntax.Internal.Pattern' a)
instance (Agda.TypeChecking.Substitute.Class.Subst t a, Agda.TypeChecking.Reduce.InstantiateFull a) => Agda.TypeChecking.Reduce.InstantiateFull (Agda.Syntax.Internal.Abs a)
instance Agda.TypeChecking.Reduce.InstantiateFull t => Agda.TypeChecking.Reduce.InstantiateFull (Agda.Syntax.Common.Arg t)
instance Agda.TypeChecking.Reduce.InstantiateFull t => Agda.TypeChecking.Reduce.InstantiateFull (Agda.Syntax.Common.Named name t)
instance Agda.TypeChecking.Reduce.InstantiateFull t => Agda.TypeChecking.Reduce.InstantiateFull (Agda.Syntax.Common.Dom t)
instance Agda.TypeChecking.Reduce.InstantiateFull t => Agda.TypeChecking.Reduce.InstantiateFull [t]
instance (Agda.TypeChecking.Reduce.InstantiateFull a, Agda.TypeChecking.Reduce.InstantiateFull b) => Agda.TypeChecking.Reduce.InstantiateFull (a, b)
instance (Agda.TypeChecking.Reduce.InstantiateFull a, Agda.TypeChecking.Reduce.InstantiateFull b, Agda.TypeChecking.Reduce.InstantiateFull c) => Agda.TypeChecking.Reduce.InstantiateFull (a, b, c)
instance Agda.TypeChecking.Reduce.InstantiateFull a => Agda.TypeChecking.Reduce.InstantiateFull (Agda.TypeChecking.Monad.Base.Closure a)
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.ProblemConstraint
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.Constraint
instance Agda.TypeChecking.Reduce.InstantiateFull a => Agda.TypeChecking.Reduce.InstantiateFull (Agda.Syntax.Internal.Elim' a)
instance Agda.TypeChecking.Reduce.InstantiateFull e => Agda.TypeChecking.Reduce.InstantiateFull (Data.Map.Base.Map k e)
instance Agda.TypeChecking.Reduce.InstantiateFull e => Agda.TypeChecking.Reduce.InstantiateFull (Data.HashMap.Base.HashMap k e)
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Abstract.Name.ModuleName
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Scope.Base.Scope
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.Signature
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.Section
instance (Agda.TypeChecking.Substitute.Class.Subst t a, Agda.TypeChecking.Reduce.InstantiateFull a) => Agda.TypeChecking.Reduce.InstantiateFull (Agda.Syntax.Internal.Tele a)
instance Agda.TypeChecking.Reduce.InstantiateFull GHC.Types.Char
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.Definition
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.NLPat
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.NLPType
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.RewriteRule
instance Agda.TypeChecking.Reduce.InstantiateFull a => Agda.TypeChecking.Reduce.InstantiateFull (Agda.TypeChecking.Monad.Base.Open a)
instance Agda.TypeChecking.Reduce.InstantiateFull a => Agda.TypeChecking.Reduce.InstantiateFull (Agda.TypeChecking.Monad.Base.Local a)
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.DisplayForm
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.DisplayTerm
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.Defn
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.FunctionInverse
instance Agda.TypeChecking.Reduce.InstantiateFull a => Agda.TypeChecking.Reduce.InstantiateFull (Agda.TypeChecking.CompiledClause.WithArity a)
instance Agda.TypeChecking.Reduce.InstantiateFull a => Agda.TypeChecking.Reduce.InstantiateFull (Agda.TypeChecking.CompiledClause.Case a)
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.CompiledClause.CompiledClauses
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Internal.Clause
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.Interface
instance Agda.TypeChecking.Reduce.InstantiateFull a => Agda.TypeChecking.Reduce.InstantiateFull (Agda.TypeChecking.Monad.Base.Builtin a)
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Abstract.Name.QName
instance Agda.TypeChecking.Reduce.InstantiateFull a => Agda.TypeChecking.Reduce.InstantiateFull (GHC.Base.Maybe a)
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.TypeChecking.Monad.Base.Candidate
instance Agda.TypeChecking.Reduce.InstantiateFull Agda.Syntax.Internal.EqualityView


-- | Contains the state monad that the compiler works in and some functions
--   for tampering with the state.
module Agda.Compiler.Epic.CompileState

-- | Stuff we need in our compiler
data CompileState
CompileState :: [Var] -> Map TopLevelModuleName (EInterface, Set FilePath) -> EInterface -> EInterface -> String -> CompileState
[nameSupply] :: CompileState -> [Var]
[compiledModules] :: CompileState -> Map TopLevelModuleName (EInterface, Set FilePath)
[curModule] :: CompileState -> EInterface
[importedModules] :: CompileState -> EInterface
[curFun] :: CompileState -> String

-- | The initial (empty) state
initCompileState :: CompileState

-- | Compiler monad
type Compile = StateT CompileState

-- | When normal errors are not enough
epicError :: String -> Compile TCM a

-- | Modify the state of the current module's Epic Interface
modifyEI :: (EInterface -> EInterface) -> Compile TCM ()

-- | Get the state of the current module's Epic Interface
getsEI :: (EInterface -> a) -> Compile TCM a

-- | Returns the type of a definition given its name
getType :: QName -> Compile TCM Type

-- | Create a name which can be used in Epic code from a QName.
unqname :: QName -> Var
resetNameSupply :: Compile TCM ()
getDelayed :: QName -> Compile TCM Bool
putDelayed :: QName -> Bool -> Compile TCM ()
newName :: Compile TCM Var
putConstrTag :: QName -> Tag -> Compile TCM ()
assignConstrTag :: QName -> Compile TCM Tag
assignConstrTag' :: QName -> [QName] -> Compile TCM Tag
getConData :: QName -> Compile TCM QName
getDataCon :: QName -> Compile TCM [QName]
getConstrTag :: QName -> Compile TCM Tag
getConstrTag' :: QName -> Compile TCM (Maybe Tag)
addDefName :: QName -> Compile TCM ()
topBindings :: Compile TCM (Set Var)
getConArity :: QName -> Compile TCM Int
putConArity :: QName -> Int -> Compile TCM ()
putMain :: QName -> Compile TCM ()
getMain :: Compile TCM Var
lookInterface :: (EInterface -> Maybe a) -> Compile TCM a -> Compile TCM a
constrInScope :: QName -> Compile TCM Bool
getForcedArgs :: QName -> Compile TCM ForcedArgs
putForcedArgs :: QName -> ForcedArgs -> Compile TCM ()
replaceAt :: Int -> [a] -> [a] -> [a]

-- | Copy pasted from MAlonzo, HAHA!!! Move somewhere else!
constructorArity :: Num a => QName -> TCM a

-- | Bind an expression to a fresh variable name
bindExpr :: Expr -> (Var -> Compile TCM Expr) -> Compile TCM Expr
instance GHC.Show.Show Agda.Compiler.Epic.CompileState.CompileState


-- | Perform simple optimisations based on case-laws
module Agda.Compiler.Epic.CaseOpts
caseOpts :: [Fun] -> Compile TCM [Fun]

-- | Run the case-opts on an expression
caseOptsExpr :: Expr -> Compile TCM Expr


-- | Pretty-print the AuxAST to valid Epic code.
module Agda.Compiler.Epic.Epic

-- | Print a function to an Epic string
prettyEpicFun :: MonadTCM m => Fun -> Compile m String

-- | Print expression to Epic expression
prettyEpic :: Expr -> String


-- | Remove forced arguments from constructors.
module Agda.Compiler.Epic.ForceConstrs

-- | Check which arguments are forced
makeForcedArgs :: Type -> ForcedArgs

-- | Remove forced arguments from constructors and branches
forceConstrs :: [Fun] -> Compile TCM [Fun]
forceFun :: Fun -> Compile TCM Fun


-- | Detect if a datatype could be represented as a primitive integer. If
--   it has one constructor with no arguments and one with a recursive
--   argument this is true. This is done using IrrFilters which filter out
--   forced arguments, so for example Fin becomes primitive.
module Agda.Compiler.Epic.NatDetection

-- | Get a list of all the datatypes that look like nats. The [QName] is on
--   the form [zeroConstr, sucConstr]
getNatish :: Compile TCM [(ForcedArgs, [QName])]
isNatish :: QName -> Defn -> Compile TCM (Maybe (ForcedArgs, [QName]))

-- | Count the number of relevant arguments
nrRel :: ForcedArgs -> Integer

-- | Check if argument n is recursive
isRec :: Int -> Type -> QName -> Bool
argIsDef :: Type -> QName -> Bool


-- | Change constructors and cases on builtins and natish datatypes to use
--   primitive data
module Agda.Compiler.Epic.Primitive
data PrimTransform
PrimTF :: Map QName Var -> (Expr -> [Branch] -> Expr) -> PrimTransform
[mapCon] :: PrimTransform -> Map QName Var
[translateCase] :: PrimTransform -> Expr -> [Branch] -> Expr
prZero :: Var
prSuc :: Var
prTrue :: Var
prFalse :: Var
prPred :: Var
prNatEquality :: Var

-- | Change constructors and cases on builtins and natish datatypes to use
--   primitive data
primitivise :: [Fun] -> Compile TCM [Fun]

-- | Map primitive constructors to primitive tags
initialPrims :: Compile TCM ()

-- | Build transforms using the names of builtins
getBuiltins :: Compile TCM [PrimTransform]
defName :: Term -> QName

-- | Translation to primitive integer functions
natPrimTF :: ForcedArgs -> [QName] -> PrimTransform

-- | Corresponds to a case for natural numbers
primNatCaseZS :: Expr -> Expr -> Var -> Expr -> Expr

-- | Corresponds to a case with a zero and default branch
primNatCaseZD :: Expr -> Expr -> Expr -> Expr

-- | Translation to primitive bool functions
boolPrimTF :: [QName] -> PrimTransform

-- | Change all the primitives in the function using the PrimTransform
primFun :: [PrimTransform] -> Fun -> Compile TCM Fun

-- | Change all the primitives in an expression using PrimTransform
primExpr :: [PrimTransform] -> Expr -> Compile TCM Expr

module Agda.TypeChecking.DeadCode

-- | Run before serialisation to remove any definitions that are not
--   reachable from the public interface to the module.
eliminateDeadCode :: DisplayForms -> Signature -> TCM (DisplayForms, Signature)

module Agda.TypeChecking.Level
data LevelKit
LevelKit :: Term -> (Term -> Term) -> (Term -> Term -> Term) -> Term -> QName -> QName -> QName -> QName -> LevelKit
[lvlType] :: LevelKit -> Term
[lvlSuc] :: LevelKit -> Term -> Term
[lvlMax] :: LevelKit -> Term -> Term -> Term
[lvlZero] :: LevelKit -> Term
[typeName] :: LevelKit -> QName
[sucName] :: LevelKit -> QName
[maxName] :: LevelKit -> QName
[zeroName] :: LevelKit -> QName

-- | Get the <a>primLevel</a> as a <a>Type</a>.
levelType :: TCM Type
levelSucFunction :: TCM (Term -> Term)
builtinLevelKit :: (HasBuiltins m) => m LevelKit

-- | Raises an error if no level kit is available.
requireLevels :: TCM LevelKit
unLevel :: (HasBuiltins m) => Term -> m Term
reallyUnLevelView :: (HasBuiltins m) => Level -> m Term
unlevelWithKit :: LevelKit -> Level -> Term
unPlusV :: Term -> (Term -> Term) -> PlusLevel -> Term
maybePrimCon :: TCM Term -> TCM (Maybe ConHead)
maybePrimDef :: TCM Term -> TCM (Maybe QName)
levelView :: Term -> TCM Level
levelView' :: Term -> ReduceM Level
levelLub :: Level -> Level -> Level
subLevel :: Integer -> Level -> Maybe Level


-- | Tools for <a>DisplayTerm</a> and <a>DisplayForm</a>.
module Agda.TypeChecking.DisplayForm

-- | Convert a <a>DisplayTerm</a> into a <a>Term</a>.
dtermToTerm :: DisplayTerm -> Term

-- | Get the arities of all display forms for a name.
displayFormArities :: QName -> TCM [Int]

-- | Find a matching display form for <tt>q es</tt>. In essence this tries
--   to rewrite <tt>q es</tt> with any display form <tt>q ps --&gt; dt</tt>
--   and returns the instantiated <tt>dt</tt> if successful. First match
--   wins.
displayForm :: QName -> Elims -> TCM (Maybe DisplayTerm)

-- | Match a <a>DisplayForm</a> <tt>q ps = v</tt> against <tt>q es</tt>.
--   Return the <a>DisplayTerm</a> <tt>v[us]</tt> if the match was
--   successful, i.e., <tt>es / ps = Just us</tt>.
matchDisplayForm :: DisplayForm -> Elims -> MaybeT TCM (DisplayForm, DisplayTerm)

-- | Class <tt>Match</tt> for matching a term <tt>p</tt> in the role of a
--   pattern against a term <tt>v</tt>.
--   
--   The 0th variable in <tt>p</tt> plays the role of a place holder
--   (pattern variable). Each occurrence of <tt>var 0</tt> in <tt>p</tt>
--   stands for a different pattern variable.
--   
--   The result of matching, if successful, is a list of solutions for the
--   pattern variables, in left-to-right order.
--   
--   The 0th variable is in scope in the input <tt>v</tt>, but should not
--   actually occur! In the output solution, the <tt>0th</tt> variable is
--   no longer in scope. (It has been substituted by <b>IMPOSSIBLE</b>
--   which corresponds to a raise by -1).
class Match a
match :: Match a => a -> a -> MaybeT TCM [Term]
instance Agda.TypeChecking.DisplayForm.Match a => Agda.TypeChecking.DisplayForm.Match [a]
instance Agda.TypeChecking.DisplayForm.Match a => Agda.TypeChecking.DisplayForm.Match (Agda.Syntax.Common.Arg a)
instance Agda.TypeChecking.DisplayForm.Match a => Agda.TypeChecking.DisplayForm.Match (Agda.Syntax.Internal.Elim' a)
instance Agda.TypeChecking.DisplayForm.Match Agda.Syntax.Internal.Term
instance Agda.TypeChecking.DisplayForm.Match Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.DisplayForm.Match Agda.Syntax.Internal.Level

module Agda.TypeChecking.Serialise.Instances.Abstract
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Scope.Base.Scope
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Scope.Base.NameSpaceId
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Common.Access
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Scope.Base.NameSpace
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Scope.Base.WhyInScope
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Scope.Base.AbstractName
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Scope.Base.AbstractModule
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Scope.Base.KindOfName
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Scope.Base.LocalVar
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Info.ConPatInfo
instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Abstract.Pattern' a)
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Fixity.Precedence
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Scope.Base.ScopeInfo

module Agda.TypeChecking.Serialise.Instances.Compilers
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.HaskellExport
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.HaskellRepresentation
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.CompiledRepresentation
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Compiler.JS.Syntax.Exp
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Compiler.JS.Syntax.LocalId
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Compiler.JS.Syntax.GlobalId
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Compiler.JS.Syntax.MemberId
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.CoreRepresentation
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Compiler.UHC.Pragmas.Base.CoreType
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Compiler.UHC.Pragmas.Base.CoreConstr
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Compiler.UHC.Bridge.HsName
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Compiler.Epic.Interface.EInterface
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Compiler.Epic.Interface.InjectiveFun
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Compiler.Epic.Interface.Relevance
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Compiler.Epic.Interface.Forced
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Compiler.Epic.Interface.Tag

module Agda.TypeChecking.Serialise.Instances.Internal
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.Signature
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.Section
instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Internal.Tele a)
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Utils.Permutation.Permutation
instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Utils.Permutation.Drop a)
instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Internal.Elim' a)
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Internal.ConHead
instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Internal.Type' a)
instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Internal.Abs a)
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Internal.Level
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Internal.LevelAtom
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.DisplayForm
instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.TypeChecking.Monad.Base.Open a)
instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.TypeChecking.Monad.Base.Local a)
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.CtxId
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.DisplayTerm
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.MutualId
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.Definition
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.NLPat
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.NLPType
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.RewriteRule
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.Projection
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.ProjLams
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.ExtLamInfo
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.Polarity
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Positivity.Occurrence.Occurrence
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.EtaEquality
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.Defn
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.FunctionFlag
instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.TypeChecking.CompiledClause.WithArity a)
instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.TypeChecking.CompiledClause.Case a)
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.CompiledClause.CompiledClauses
instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.TypeChecking.Monad.Base.FunctionInverse' a)
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.TermHead
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Internal.Clause
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Internal.ConPatternInfo
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.Syntax.Internal.DBPatVar
instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.Syntax.Internal.Pattern' a)
instance Agda.TypeChecking.Serialise.Base.EmbPrj a => Agda.TypeChecking.Serialise.Base.EmbPrj (Agda.TypeChecking.Monad.Base.Builtin a)

module Agda.TypeChecking.Serialise.Instances
instance Agda.TypeChecking.Serialise.Base.EmbPrj Agda.TypeChecking.Monad.Base.Interface


-- | Structure-sharing serialisation of Agda interface files.
module Agda.TypeChecking.Serialise

-- | Encodes something. To ensure relocatability file paths in positions
--   are replaced with module names.
encode :: EmbPrj a => a -> TCM ByteString

-- | Encodes something. To ensure relocatability file paths in positions
--   are replaced with module names.
encodeFile :: FilePath -> Interface -> TCM ()
encodeInterface :: Interface -> TCM ByteString

-- | Decodes something. The result depends on the include path.
--   
--   Returns <a>Nothing</a> if the input does not start with the right
--   magic number or some other decoding error is encountered.
decode :: EmbPrj a => ByteString -> TCM (Maybe a)
decodeFile :: FilePath -> TCM (Maybe Interface)

-- | Decodes something. The result depends on the include path.
--   
--   Returns <a>Nothing</a> if the file does not start with the right magic
--   number or some other decoding error is encountered.
decodeInterface :: ByteString -> TCM (Maybe Interface)
decodeHashes :: ByteString -> Maybe (Hash, Hash)
class Typeable a => EmbPrj a where icode a = do { tickICode a; icod_ a }


-- | A syntactic equality check that takes meta instantiations into
--   account, but does not reduce. It replaces <tt> (v, v') &lt;-
--   instantiateFull (v, v') v == v' </tt> by a more efficient routine
--   which only traverses and instantiates the terms as long as they are
--   equal.
module Agda.TypeChecking.SyntacticEquality

-- | Instantiate full as long as things are equal
class SynEq a where synEq' a a' = ifEqual (uncurry synEq) (a, a')

-- | Syntactic equality check for terms. <tt> checkSyntacticEquality v v' =
--   do (v,v') &lt;- instantiateFull (v,v') return ((v,v'), v==v') </tt>
--   only that <tt>v,v'</tt> are only fully instantiated to the depth where
--   they are equal.
checkSyntacticEquality :: (SynEq a) => a -> a -> ReduceM ((a, a), Bool)
instance Agda.TypeChecking.SyntacticEquality.SynEq Agda.Syntax.Internal.Term
instance Agda.TypeChecking.SyntacticEquality.SynEq Agda.Syntax.Internal.Level
instance Agda.TypeChecking.SyntacticEquality.SynEq Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.SyntacticEquality.SynEq Agda.Syntax.Internal.LevelAtom
instance Agda.TypeChecking.SyntacticEquality.SynEq Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.SyntacticEquality.SynEq Agda.Syntax.Internal.Type
instance Agda.TypeChecking.SyntacticEquality.SynEq a => Agda.TypeChecking.SyntacticEquality.SynEq [a]
instance Agda.TypeChecking.SyntacticEquality.SynEq a => Agda.TypeChecking.SyntacticEquality.SynEq (Agda.Syntax.Internal.Elim' a)
instance (Agda.TypeChecking.Substitute.Class.Subst t a, Agda.TypeChecking.SyntacticEquality.SynEq a) => Agda.TypeChecking.SyntacticEquality.SynEq (Agda.Syntax.Internal.Abs a)
instance Agda.TypeChecking.SyntacticEquality.SynEq a => Agda.TypeChecking.SyntacticEquality.SynEq (Agda.Syntax.Common.Arg a)
instance Agda.TypeChecking.SyntacticEquality.SynEq a => Agda.TypeChecking.SyntacticEquality.SynEq (Agda.Syntax.Common.Dom a)
instance Agda.TypeChecking.SyntacticEquality.SynEq Agda.Syntax.Common.ArgInfo

module Agda.TypeChecking.Telescope
data OutputTypeName
OutputTypeName :: QName -> OutputTypeName
OutputTypeVar :: OutputTypeName
OutputTypeNameNotYetKnown :: OutputTypeName
NoOutputTypeName :: OutputTypeName

-- | Strips all Pi's and return the head definition name, if possible.
getOutputTypeName :: Type -> TCM OutputTypeName

-- | Flatten telescope: (Γ : Tel) -&gt; [Type Γ]
flattenTel :: Telescope -> [Dom Type]

-- | Order a flattened telescope in the correct dependeny order: Γ -&gt;
--   Permutation (Γ -&gt; Γ~)
--   
--   Since <tt>reorderTel tel</tt> uses free variable analysis of type in
--   <tt>tel</tt>, the telescope should be <a>normalise</a>d.
reorderTel :: [Dom Type] -> Maybe Permutation
reorderTel_ :: [Dom Type] -> Permutation

-- | Unflatten: turns a flattened telescope into a proper telescope. Must
--   be properly ordered.
unflattenTel :: [ArgName] -> [Dom Type] -> Telescope

-- | Get the suggested names from a telescope
teleNames :: Telescope -> [ArgName]
teleArgNames :: Telescope -> [Arg ArgName]
teleArgs :: (DeBruijn a) => Telescope -> [Arg a]
teleNamedArgs :: (DeBruijn a) => Telescope -> [NamedArg a]

-- | A variant of <a>teleNamedArgs</a> which takes the argument names (and
--   the argument info) from the first telescope and the variable names
--   from the second telescope.
--   
--   Precondition: the two telescopes have the same length.
tele2NamedArgs :: (DeBruijn a) => Telescope -> Telescope -> [NamedArg a]

-- | Permute telescope: permutes or drops the types in the telescope
--   according to the given permutation. Assumes that the permutation
--   preserves the dependencies in the telescope.
--   
--   For example (Andreas, 2016-12-18, issue #2344): <tt> tel = (A : Set)
--   (X : _18 A) (i : Fin (_m_23 A X)) tel (de Bruijn) = 2:Set, 1:_18
--   </tt>0, 0:Fin(_m_23 <tt>1 </tt>0) flattenTel tel = 2:Set, 1:_18 <tt>0,
--   0:Fin(_m_23 </tt>1 <tt>0) |- [ Set, _18 </tt>2, Fin (_m_23 <tt>2
--   </tt>1) ] perm = 0,1,2 -&gt; 0,1 (picks the first two) renaming _ perm
--   = [var 0, var 1, error] -- THE WRONG RENAMING! renaming _ (flipP perm)
--   = [error, var 1, var 0] -- The correct renaming! apply to flattened
--   tel = ... |- [ Set, _18 <tt>1, Fin (_m_23 </tt>1 <tt>0) ] permute perm
--   it = ... |- [ Set, _18 </tt>1 ] unflatten (de Bruijn) = 1:Set, 0: _18
--   <tt>0 unflatten = (A : Set) (X : _18 A) </tt>
permuteTel :: Permutation -> Telescope -> Telescope

-- | Recursively computes dependencies of a set of variables in a given
--   telescope. Any dependencies outside of the telescope are ignored.
varDependencies :: Telescope -> IntSet -> IntSet

-- | A telescope split in two.
data SplitTel
SplitTel :: Telescope -> Telescope -> Permutation -> SplitTel
[firstPart] :: SplitTel -> Telescope
[secondPart] :: SplitTel -> Telescope

-- | The permutation takes us from the original telescope to <tt>firstPart
--   ++ secondPart</tt>.
[splitPerm] :: SplitTel -> Permutation

-- | Split a telescope into the part that defines the given variables and
--   the part that doesn't.
--   
--   See <a>prop_splitTelescope</a>.
splitTelescope :: VarSet -> Telescope -> SplitTel

-- | As splitTelescope, but fails if any additional variables or reordering
--   would be needed to make the first part well-typed.
splitTelescopeExact :: [Int] -> Telescope -> Maybe SplitTel

-- | Try to instantiate one variable in the telescope (given by its de
--   Bruijn level) with the given value, returning the new telescope and a
--   substitution to the old one. Returns Nothing if the given value
--   depends (directly or indirectly) on the variable.
instantiateTelescope :: Telescope -> Int -> Term -> Maybe (Telescope, PatternSubstitution, Permutation)

-- | Try to eta-expand one variable in the telescope (given by its de
--   Bruijn level)
expandTelescopeVar :: Telescope -> Int -> Telescope -> ConHead -> (Telescope, PatternSubstitution)
telView :: Type -> TCM TelView

-- | <tt>telViewUpTo n t</tt> takes off the first <tt>n</tt> function types
--   of <tt>t</tt>. Takes off all if <tt>n &lt; 0</tt>.
telViewUpTo :: Int -> Type -> TCM TelView

-- | <tt>telViewUpTo' n p t</tt> takes off $t$ the first <tt>n</tt> (or
--   arbitrary many if <tt>n &lt; 0</tt>) function domains as long as they
--   satify <tt>p</tt>.
telViewUpTo' :: Int -> (Dom Type -> Bool) -> Type -> TCM TelView

-- | Decomposing a function type.
mustBePi :: MonadTCM tcm => Type -> tcm (Dom Type, Abs Type)

-- | If the given type is a <tt>Pi</tt>, pass its parts to the first
--   continuation. If not (or blocked), pass the reduced type to the second
--   continuation.
ifPi :: MonadTCM tcm => Term -> (Dom Type -> Abs Type -> tcm a) -> (Term -> tcm a) -> tcm a

-- | If the given type is a <tt>Pi</tt>, pass its parts to the first
--   continuation. If not (or blocked), pass the reduced type to the second
--   continuation.
ifPiType :: MonadTCM tcm => Type -> (Dom Type -> Abs Type -> tcm a) -> (Type -> tcm a) -> tcm a

-- | If the given type is blocked or not a <tt>Pi</tt>, pass it reduced to
--   the first continuation. If it is a <tt>Pi</tt>, pass its parts to the
--   second continuation.
ifNotPi :: MonadTCM tcm => Term -> (Term -> tcm a) -> (Dom Type -> Abs Type -> tcm a) -> tcm a

-- | If the given type is blocked or not a <tt>Pi</tt>, pass it reduced to
--   the first continuation. If it is a <tt>Pi</tt>, pass its parts to the
--   second continuation.
ifNotPiType :: MonadTCM tcm => Type -> (Type -> tcm a) -> (Dom Type -> Abs Type -> tcm a) -> tcm a

-- | A safe variant of piApply.
piApplyM :: Type -> Args -> TCM Type
piApply1 :: MonadTCM tcm => Type -> Term -> tcm Type

-- | Given a function type, introduce its domain into the context and
--   continue with its codomain.
intro1 :: (MonadTCM tcm) => Type -> (Type -> tcm a) -> tcm a
addTypedInstance :: QName -> Type -> TCM ()
resolveUnknownInstanceDefs :: TCM ()

-- | Try to solve the instance definitions whose type is not yet known,
--   report an error if it doesn't work and return the instance table
--   otherwise.
getInstanceDefs :: TCM InstanceTable


-- | Translating from internal syntax to abstract syntax. Enables nice
--   pretty printing of internal syntax.
--   
--   TODO
--   
--   <ul>
--   <li>numbers on metas</li>
--   <li>fake dependent functions to independent functions</li>
--   <li>meta parameters</li>
--   <li>shadowing</li>
--   </ul>
module Agda.Syntax.Translation.InternalToAbstract
class Reify i a | i -> a where reifyWhen _ = reify
reify :: Reify i a => i -> TCM a
reifyWhen :: Reify i a => Bool -> i -> TCM a
data NamedClause

-- | Also tracks whether module parameters should be dropped from the
--   patterns.
NamedClause :: QName -> Bool -> Clause -> NamedClause

-- | Assumes that pattern variables have been added to the context already.
--   Picks pattern variable names from context.
reifyPatterns :: MonadTCM tcm => [NamedArg DeBruijnPattern] -> tcm [NamedArg Pattern]
instance Agda.Syntax.Translation.InternalToAbstract.Reify Agda.Syntax.Abstract.Name.Name Agda.Syntax.Abstract.Name.Name
instance Agda.Syntax.Translation.InternalToAbstract.Reify Agda.Syntax.Abstract.Expr Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Translation.InternalToAbstract.Reify Agda.Syntax.Common.MetaId Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Translation.InternalToAbstract.Reify Agda.TypeChecking.Monad.Base.DisplayTerm Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Translation.InternalToAbstract.Reify Agda.Syntax.Literal.Literal Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Translation.InternalToAbstract.Reify Agda.Syntax.Internal.Term Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Translation.InternalToAbstract.Reify i a => Agda.Syntax.Translation.InternalToAbstract.Reify (Agda.Syntax.Common.Named n i) (Agda.Syntax.Common.Named n a)
instance Agda.Syntax.Translation.InternalToAbstract.Reify i a => Agda.Syntax.Translation.InternalToAbstract.Reify (Agda.Syntax.Common.Arg i) (Agda.Syntax.Common.Arg a)
instance (GHC.Classes.Ord k, GHC.Base.Monoid v) => Data.Semigroup.Semigroup (Agda.Syntax.Translation.InternalToAbstract.MonoidMap k v)
instance (GHC.Classes.Ord k, GHC.Base.Monoid v) => GHC.Base.Monoid (Agda.Syntax.Translation.InternalToAbstract.MonoidMap k v)
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars a => Agda.Syntax.Translation.InternalToAbstract.BlankVars (Agda.Syntax.Common.Arg a)
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars a => Agda.Syntax.Translation.InternalToAbstract.BlankVars (Agda.Syntax.Common.Named s a)
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars a => Agda.Syntax.Translation.InternalToAbstract.BlankVars [a]
instance (Agda.Syntax.Translation.InternalToAbstract.BlankVars a, Agda.Syntax.Translation.InternalToAbstract.BlankVars b) => Agda.Syntax.Translation.InternalToAbstract.BlankVars (a, b)
instance (Agda.Syntax.Translation.InternalToAbstract.BlankVars a, Agda.Syntax.Translation.InternalToAbstract.BlankVars b) => Agda.Syntax.Translation.InternalToAbstract.BlankVars (Data.Either.Either a b)
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars Agda.Syntax.Abstract.NamedDotPattern
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars Agda.Syntax.Abstract.Clause
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars Agda.Syntax.Abstract.LHS
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars Agda.Syntax.Abstract.LHSCore
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars Agda.Syntax.Abstract.Pattern
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars a => Agda.Syntax.Translation.InternalToAbstract.BlankVars (Agda.Syntax.Concrete.FieldAssignment' a)
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars Agda.Syntax.Abstract.Name.ModuleName
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars Agda.Syntax.Abstract.RHS
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars Agda.Syntax.Abstract.LamBinding
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars Agda.Syntax.Abstract.TypedBindings
instance Agda.Syntax.Translation.InternalToAbstract.BlankVars Agda.Syntax.Abstract.TypedBinding
instance Agda.Syntax.Translation.InternalToAbstract.Binder Agda.Syntax.Abstract.LHS
instance Agda.Syntax.Translation.InternalToAbstract.Binder Agda.Syntax.Abstract.LHSCore
instance Agda.Syntax.Translation.InternalToAbstract.Binder Agda.Syntax.Abstract.Pattern
instance Agda.Syntax.Translation.InternalToAbstract.Binder Agda.Syntax.Abstract.LamBinding
instance Agda.Syntax.Translation.InternalToAbstract.Binder Agda.Syntax.Abstract.TypedBindings
instance Agda.Syntax.Translation.InternalToAbstract.Binder Agda.Syntax.Abstract.TypedBinding
instance Agda.Syntax.Translation.InternalToAbstract.Binder Agda.Syntax.Abstract.LetBinding
instance Agda.Syntax.Translation.InternalToAbstract.Binder a => Agda.Syntax.Translation.InternalToAbstract.Binder (Agda.Syntax.Concrete.FieldAssignment' a)
instance Agda.Syntax.Translation.InternalToAbstract.Binder a => Agda.Syntax.Translation.InternalToAbstract.Binder (Agda.Syntax.Common.Arg a)
instance Agda.Syntax.Translation.InternalToAbstract.Binder a => Agda.Syntax.Translation.InternalToAbstract.Binder (Agda.Syntax.Common.Named x a)
instance Agda.Syntax.Translation.InternalToAbstract.Binder (Agda.Syntax.Common.WithHiding Agda.Syntax.Abstract.Name.Name)
instance Agda.Syntax.Translation.InternalToAbstract.Binder a => Agda.Syntax.Translation.InternalToAbstract.Binder [a]
instance (Agda.Syntax.Translation.InternalToAbstract.Binder a, Agda.Syntax.Translation.InternalToAbstract.Binder b) => Agda.Syntax.Translation.InternalToAbstract.Binder (a, b)
instance Agda.Syntax.Translation.InternalToAbstract.Reify (Agda.Syntax.Abstract.Name.QNamed Agda.Syntax.Internal.Clause) Agda.Syntax.Abstract.Clause
instance Agda.Syntax.Translation.InternalToAbstract.Reify Agda.Syntax.Translation.InternalToAbstract.NamedClause Agda.Syntax.Abstract.Clause
instance Agda.Syntax.Translation.InternalToAbstract.Reify Agda.Syntax.Internal.Type Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Translation.InternalToAbstract.Reify Agda.Syntax.Internal.Sort Agda.Syntax.Abstract.Expr
instance Agda.Syntax.Translation.InternalToAbstract.Reify Agda.Syntax.Internal.Level Agda.Syntax.Abstract.Expr
instance (Agda.TypeChecking.Free.Free i, Agda.Syntax.Translation.InternalToAbstract.Reify i a) => Agda.Syntax.Translation.InternalToAbstract.Reify (Agda.Syntax.Internal.Abs i) (Agda.Syntax.Abstract.Name.Name, a)
instance Agda.Syntax.Translation.InternalToAbstract.Reify Agda.Syntax.Internal.Telescope Agda.Syntax.Abstract.Telescope
instance Agda.Syntax.Translation.InternalToAbstract.Reify i a => Agda.Syntax.Translation.InternalToAbstract.Reify (Agda.Syntax.Common.Dom i) (Agda.Syntax.Common.Arg a)
instance Agda.Syntax.Translation.InternalToAbstract.Reify i a => Agda.Syntax.Translation.InternalToAbstract.Reify (Agda.Syntax.Internal.Elim' i) (Agda.Syntax.Internal.Elim' a)
instance Agda.Syntax.Translation.InternalToAbstract.Reify i a => Agda.Syntax.Translation.InternalToAbstract.Reify [i] [a]
instance (Agda.Syntax.Translation.InternalToAbstract.Reify i1 a1, Agda.Syntax.Translation.InternalToAbstract.Reify i2 a2) => Agda.Syntax.Translation.InternalToAbstract.Reify (i1, i2) (a1, a2)
instance (Agda.Syntax.Translation.InternalToAbstract.Reify i1 a1, Agda.Syntax.Translation.InternalToAbstract.Reify i2 a2, Agda.Syntax.Translation.InternalToAbstract.Reify i3 a3) => Agda.Syntax.Translation.InternalToAbstract.Reify (i1, i2, i3) (a1, a2, a3)
instance (Agda.Syntax.Translation.InternalToAbstract.Reify i1 a1, Agda.Syntax.Translation.InternalToAbstract.Reify i2 a2, Agda.Syntax.Translation.InternalToAbstract.Reify i3 a3, Agda.Syntax.Translation.InternalToAbstract.Reify i4 a4) => Agda.Syntax.Translation.InternalToAbstract.Reify (i1, i2, i3, i4) (a1, a2, a3, a4)

module Agda.TypeChecking.Pretty
type Doc = Doc
comma :: TCM Doc
colon :: TCM Doc
equals :: TCM Doc
pretty :: Pretty a => a -> TCM Doc
prettyA :: (Pretty c, ToConcrete a c) => a -> TCM Doc
prettyAs :: (Pretty c, ToConcrete a [c]) => a -> TCM Doc
text :: String -> TCM Doc
multiLineText :: String -> TCM Doc
pwords :: String -> [TCM Doc]
fwords :: String -> TCM Doc
sep :: [TCM Doc] -> TCM Doc
fsep :: [TCM Doc] -> TCM Doc
hsep :: [TCM Doc] -> TCM Doc
hcat :: [TCM Doc] -> TCM Doc
vcat :: [TCM Doc] -> TCM Doc
hang :: TCM Doc -> Int -> TCM Doc -> TCM Doc
($$) :: TCM Doc -> TCM Doc -> TCM Doc
($+$) :: TCM Doc -> TCM Doc -> TCM Doc
(<>) :: TCM Doc -> TCM Doc -> TCM Doc
(<+>) :: TCM Doc -> TCM Doc -> TCM Doc
nest :: Int -> TCM Doc -> TCM Doc
braces :: TCM Doc -> TCM Doc
dbraces :: TCM Doc -> TCM Doc
brackets :: TCM Doc -> TCM Doc
parens :: TCM Doc -> TCM Doc

-- | Comma-separated list in brackets.
prettyList :: [TCM Doc] -> TCM Doc

-- | <a>prettyList</a> without the brackets.
prettyList_ :: [TCM Doc] -> TCM Doc
punctuate :: TCM Doc -> [TCM Doc] -> [TCM Doc]
class PrettyTCM a
prettyTCM :: PrettyTCM a => a -> TCM Doc
newtype PrettyContext
PrettyContext :: Context -> PrettyContext

-- | Proper pretty printing of patterns:
prettyTCMPatternList :: [NamedArg DeBruijnPattern] -> TCM Doc
raisePatVars :: Int -> NLPat -> NLPat
raisePatVarsInType :: Int -> NLPType -> NLPType

-- | Pairing something with a node (for printing only).
data WithNode n a
WithNode :: n -> a -> WithNode n a
instance Agda.TypeChecking.Pretty.PrettyTCM GHC.Types.Bool
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Concrete.Name.Name
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Concrete.Name.QName
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.Comparison
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Literal.Literal
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Common.Nat
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.ProblemId
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Position.Range
instance Agda.TypeChecking.Pretty.PrettyTCM a => Agda.TypeChecking.Pretty.PrettyTCM (Agda.TypeChecking.Monad.Base.Closure a)
instance Agda.TypeChecking.Pretty.PrettyTCM a => Agda.TypeChecking.Pretty.PrettyTCM [a]
instance (Agda.TypeChecking.Pretty.PrettyTCM a, Agda.TypeChecking.Pretty.PrettyTCM b) => Agda.TypeChecking.Pretty.PrettyTCM (a, b)
instance (Agda.TypeChecking.Pretty.PrettyTCM a, Agda.TypeChecking.Pretty.PrettyTCM b, Agda.TypeChecking.Pretty.PrettyTCM c) => Agda.TypeChecking.Pretty.PrettyTCM (a, b, c)
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Internal.Type
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.DisplayTerm
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Translation.InternalToAbstract.NamedClause
instance Agda.TypeChecking.Pretty.PrettyTCM (Agda.Syntax.Abstract.Name.QNamed Agda.Syntax.Internal.Clause)
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Internal.Level
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Utils.Permutation.Permutation
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.Polarity
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Reflected.Term
instance (GHC.Show.Show a, Agda.TypeChecking.Pretty.PrettyTCM a, Agda.TypeChecking.Substitute.Class.Subst a a) => Agda.TypeChecking.Pretty.PrettyTCM (Agda.Syntax.Internal.Substitution' a)
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.ModuleParameters
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Internal.Clause
instance Agda.TypeChecking.Pretty.PrettyTCM a => Agda.TypeChecking.Pretty.PrettyTCM (Agda.TypeChecking.Monad.Base.Judgement a)
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Common.MetaId
instance Agda.TypeChecking.Pretty.PrettyTCM a => Agda.TypeChecking.Pretty.PrettyTCM (Agda.Syntax.Internal.Blocked a)
instance (Agda.Syntax.Translation.InternalToAbstract.Reify a e, Agda.Syntax.Translation.AbstractToConcrete.ToConcrete e c, Agda.Utils.Pretty.Pretty c) => Agda.TypeChecking.Pretty.PrettyTCM (Agda.Syntax.Common.Named_ a)
instance (Agda.Syntax.Translation.InternalToAbstract.Reify a e, Agda.Syntax.Translation.AbstractToConcrete.ToConcrete e c, Agda.Utils.Pretty.Pretty c) => Agda.TypeChecking.Pretty.PrettyTCM (Agda.Syntax.Common.Arg a)
instance (Agda.Syntax.Translation.InternalToAbstract.Reify a e, Agda.Syntax.Translation.AbstractToConcrete.ToConcrete e c, Agda.Utils.Pretty.Pretty c) => Agda.TypeChecking.Pretty.PrettyTCM (Agda.Syntax.Common.Dom a)
instance (Agda.TypeChecking.Pretty.PrettyTCM k, Agda.TypeChecking.Pretty.PrettyTCM v) => Agda.TypeChecking.Pretty.PrettyTCM (Data.Map.Base.Map k v)
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Internal.ArgName
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Internal.Elim
instance Agda.TypeChecking.Pretty.PrettyTCM a => Agda.TypeChecking.Pretty.PrettyTCM (Agda.TypeChecking.Monad.Base.MaybeReduced a)
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Internal.EqualityView
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Abstract.Expr
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Abstract.TypedBinding
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Common.Relevance
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.ProblemConstraint
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.Constraint
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.TypeCheckingProblem
instance Agda.TypeChecking.Pretty.PrettyTCM a => Agda.TypeChecking.Pretty.PrettyTCM (Agda.Syntax.Common.WithHiding a)
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Abstract.Name.Name
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Abstract.Name.QName
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Abstract.Name.ModuleName
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Internal.ConHead
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Internal.Telescope
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Pretty.PrettyContext
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.Context
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.CtxId
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.Syntax.Internal.DBPatVar
instance Agda.TypeChecking.Pretty.PrettyTCM a => Agda.TypeChecking.Pretty.PrettyTCM (Agda.Syntax.Internal.Pattern' a)
instance Agda.TypeChecking.Pretty.PrettyTCM (Agda.Syntax.Internal.Elim' Agda.TypeChecking.Monad.Base.DisplayTerm)
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.NLPat
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.NLPType
instance Agda.TypeChecking.Pretty.PrettyTCM (Agda.Syntax.Internal.Elim' Agda.TypeChecking.Monad.Base.NLPat)
instance Agda.TypeChecking.Pretty.PrettyTCM (Agda.Syntax.Internal.Type' Agda.TypeChecking.Monad.Base.NLPat)
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.RewriteRule
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Positivity.Occurrence.Occurrence
instance Agda.TypeChecking.Pretty.PrettyTCM n => Agda.TypeChecking.Pretty.PrettyTCM (Agda.TypeChecking.Pretty.WithNode n Agda.TypeChecking.Positivity.Occurrence.Occurrence)
instance (Agda.TypeChecking.Pretty.PrettyTCM n, Agda.TypeChecking.Pretty.PrettyTCM (Agda.TypeChecking.Pretty.WithNode n e)) => Agda.TypeChecking.Pretty.PrettyTCM (Agda.Utils.Graph.AdjacencyMap.Unidirectional.Graph n n e)


-- | Some arguments to functions (types in particular) will not be used in
--   the body. Wouldn't it be useful if these wasn't passed around at all?
--   Fear not, we here perform some analysis and try to remove as many of
--   these occurences as possible.
--   
--   We employ the worker/wrapper transform, so if f x1 .. xn = e and we
--   notice that some is not needed we create: f' xj .. xk = e [xi := unit]
--   and f x1 .. xn = f' xj .. xk. i.e we erase them in f' and replace by
--   unit, and the original f function calls the new f'. The idea is that f
--   should be inlined and then peace on earth.
module Agda.Compiler.Epic.Erasure
isIrr :: Relevance -> Bool
isRel :: Relevance -> Bool

-- | Relevance "or"
(||-) :: Relevance -> Relevance -> Relevance
infixr 2 ||-

-- | Relevance "and"
(&&-) :: Relevance -> Relevance -> Relevance
infixr 3 &&-
data ErasureState
ErasureState :: Map Var [Relevance] -> Map Var Fun -> ErasureState
[relevancies] :: ErasureState -> Map Var [Relevance]
[funs] :: ErasureState -> Map Var Fun
type Erasure = StateT ErasureState

-- | Try to find as many unused variables as possible
erasure :: [Fun] -> Compile TCM [Fun]
removeUnused :: Map Var [Relevance] -> Expr -> Expr

-- | Initiate a function's relevancies
initiate :: Fun -> Erasure (Compile TCM) ()
initialRels :: Type -> Relevance -> [Relevance]
ignoreForced :: Relevance -> Bool

-- | Calculate if a variable is relevant in an expression
relevant :: Monad m => Var -> Expr -> Erasure m Relevance

-- | Try to find a fixpoint for all the functions relevance.
step :: Integer -> Erasure (Compile TCM) (Map Var [Relevance])
diff :: Eq a => Map k a -> Map k a -> [(k, (a, a))]

module Agda.Compiler.Epic.Injection

-- | Find potentially injective functions, solve constraints to fix some
--   constructor tags and make functions whose constraints are fulfilled
--   injections
findInjection :: [(QName, Definition)] -> Compile TCM [(QName, Definition)]
replaceFunCC :: QName -> CompiledClauses -> Compile TCM ()

-- | If the pairs of constructor names have the same tags, the function is
--   injective. If Nothing, the function is not injective.
type InjConstraints = Maybe [(QName, QName)]
isInjective :: QName -> [Clause] -> Compile TCM (Maybe ((QName, InjectiveFun), [(QName, QName)]))
patternToTerm :: Nat -> Pattern -> Term
nrBinds :: Num i => Pattern -> i
substForDot :: [NamedArg (Pattern' a)] -> Substitution
isInjectiveHere :: QName -> Int -> Clause -> Compile TCM InjConstraints

-- | Turn NATURAL literal n into suc^n zero.
litToCon :: Literal -> TCM Term
litInt :: Literal -> Bool
insertAt :: (Nat, Term) -> Term -> Term
solve :: [QName] -> [((QName, InjectiveFun), [(QName, QName)])] -> Compile TCM [(QName, InjectiveFun)]
emptyC :: InjConstraints
addConstraint :: QName -> QName -> InjConstraints -> InjConstraints
unionConstraints :: [InjConstraints] -> InjConstraints

-- | Are two terms injectible? Tries to find a mapping between constructors
--   that equates the terms.
--   
--   Precondition: t1 is normalised, t2 is in WHNF When reducing t2, it may
--   become a literal, which makes this not work in some cases...
class Injectible a
(<:) :: Injectible a => a -> a -> ReaderT (Map QName InjectiveFun) (Compile TCM) InjConstraints
data TagEq
Same :: Int -> TagEq
IsTag :: Tag -> TagEq
data Tags
Tags :: IntMap (Set QName) -> Map QName TagEq -> Tags
[eqGroups] :: Tags -> IntMap (Set QName)
[constrGroup] :: Tags -> Map QName TagEq
initialTags :: Map QName Tag -> [QName] -> Tags
unify :: QName -> QName -> Tags -> Compile TCM (Maybe Tags)
setTag :: Int -> Tag -> Tags -> Compile TCM (Maybe Tags)
mergeGroups :: Int -> Int -> Tags -> Compile TCM (Maybe Tags)
unifiable :: QName -> QName -> Compile TCM Bool
(!!!!) :: Ord k => Map k v -> k -> v
instance GHC.Classes.Eq Agda.Compiler.Epic.Injection.TagEq
instance Agda.Compiler.Epic.Injection.Injectible a => Agda.Compiler.Epic.Injection.Injectible (Agda.Syntax.Common.Arg a)
instance Agda.Compiler.Epic.Injection.Injectible a => Agda.Compiler.Epic.Injection.Injectible [a]
instance Agda.Compiler.Epic.Injection.Injectible a => Agda.Compiler.Epic.Injection.Injectible (Agda.Syntax.Internal.Elim' a)
instance Agda.Compiler.Epic.Injection.Injectible Agda.Syntax.Internal.Term


-- | Smash functions which return something that can be inferred (something
--   of a type with only one element)
module Agda.Compiler.Epic.Smashing
defnPars :: Integral n => Defn -> n

-- | Main function, smash as much as possible
smash'em :: [Fun] -> Compile TCM [Fun]
(+++) :: Telescope -> Telescope -> Telescope

-- | Can a datatype be inferred? If so, return the only possible value.
inferable :: Set QName -> QName -> [Arg Term] -> Compile TCM (Maybe Expr)
inferableTerm :: Set QName -> Term -> Compile TCM (Maybe Expr)

-- | Find the only possible value for a certain type. If we fail return
--   Nothing
smashable :: Int -> Type -> Compile TCM (Maybe Expr)
buildLambda :: (Ord n, Num n) => n -> Expr -> Expr


-- | Find the places where the builtin static is used and do some
--   normalisation there.
module Agda.Compiler.Epic.Static
normaliseStatic :: CompiledClauses -> Compile TCM CompiledClauses
evaluateCC :: CompiledClauses -> Compile TCM CompiledClauses
etaExpand :: Term -> Compile TCM Term
class Evaluate a
evaluate :: Evaluate a => a -> Compile TCM a
instance Agda.Compiler.Epic.Static.Evaluate a => Agda.Compiler.Epic.Static.Evaluate [a]
instance Agda.Compiler.Epic.Static.Evaluate a => Agda.Compiler.Epic.Static.Evaluate (Agda.Syntax.Common.Arg a)
instance Agda.Compiler.Epic.Static.Evaluate a => Agda.Compiler.Epic.Static.Evaluate (Agda.Syntax.Internal.Abs a)
instance Agda.Compiler.Epic.Static.Evaluate a => Agda.Compiler.Epic.Static.Evaluate (Agda.Syntax.Internal.Elim' a)
instance Agda.Compiler.Epic.Static.Evaluate Agda.Syntax.Internal.Term


-- | Convert from Agda's internal representation to our auxiliary AST.
module Agda.Compiler.Epic.FromAgda

-- | Convert from Agda's internal representation to our auxiliary AST.
fromAgda :: Maybe Term -> [(QName, Definition)] -> Compile TCM [Fun]

-- | Translate an Agda definition to an Epic function where applicable
translateDefn :: Maybe Term -> (QName, Definition) -> Compile TCM (Maybe Fun)
reverseCCBody :: Int -> CompiledClauses -> CompiledClauses

-- | Translate from Agda's desugared pattern matching (CompiledClauses) to
--   our AuxAST. This is all done by magic. It uses <a>substTerm</a> to
--   translate the actual terms when the cases have been gone through. The
--   case expressions that we get use de Bruijn indices that change after
--   each case in the following way. Say we have this pattern:
--   
--   <pre>
--   f (X x y) (Y z) = term
--   </pre>
--   
--   Initially, the variables have these indexes:
--   
--   <pre>
--   f 0@(X x y) 1@(Y z) = term
--   </pre>
--   
--   The first case will be on <tt>0</tt>, and the variables bound inside
--   the <tt>X</tt> pattern will replace the outer index, so we get
--   something like this:
--   
--   <pre>
--   f 0 2@(Y z) = case 0 of X 0 1 -&gt; term
--   </pre>
--   
--   Notice how <tt>(Y z)</tt> now has index <tt>2</tt>. Then the second
--   pattern is desugared in the same way:
--   
--   <pre>
--   f 0 2 = case 0 of X 0 1 -&gt; case 2 of Y 2 -&gt; term
--   </pre>
--   
--   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 <tt>Inf a b</tt>, where <tt>Inf</tt> is the INFINITY
--   builtin, is translated to <tt><a>of b</a></tt> (assuming that all
--   coinductive builtins are defined).
--   
--   Note that if <tt>haskellType</tt> supported universe polymorphism then
--   the special treatment of INFINITY might not be needed.
haskellType :: Type -> TCM HaskellType

module Agda.TypeChecking.CompiledClause.Match
matchCompiled :: CompiledClauses -> MaybeReducedArgs -> ReduceM (Reduced (Blocked Args) Term)

-- | <tt>matchCompiledE c es</tt> takes a function given by case tree
--   <tt>c</tt> and and a spine <tt>es</tt> and tries to apply the function
--   to <tt>es</tt>.
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]

-- | <tt>match'</tt> tries to solve the matching problems on the
--   <tt>Stack</tt>. In each iteration, the top problem is removed and
--   handled.
--   
--   If the top problem was a <tt>Done</tt>, we succeed.
--   
--   If the top problem was a <tt>Case n</tt> and the <tt>n</tt>th 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)


-- | Functions for inserting implicit arguments at the right places.
module Agda.TypeChecking.Implicit

-- | <tt>implicitArgs n expand eti t</tt> generates up to <tt>n</tt>
--   implicit arguments metas (unbounded if <tt>n&lt;0</tt>), as long as
--   <tt>t</tt> is a function type and <tt>expand</tt> holds on the hiding
--   info of its domain.
--   
--   If explicit arguments are to be inserted as well, they are inserted as
--   instance arguments (used for recursive instance search).
implicitArgs :: Int -> (Hiding -> Bool) -> Type -> TCM (Args, Type)

-- | <tt>implicitNamedArgs n expand eti t</tt> generates up to <tt>n</tt>
--   named implicit arguments metas (unbounded if <tt>n&lt;0</tt>), as long
--   as <tt>t</tt> is a function type and <tt>expand</tt> holds on the
--   hiding and name info of its domain.
--   
--   If explicit arguments are to be inserted as well, they are inserted as
--   instance arguments (used for recursive instance search).
implicitNamedArgs :: Int -> (Hiding -> ArgName -> Bool) -> Type -> TCM (NamedArgs, Type)

-- | Create a metavariable according to the <a>Hiding</a> info.
newMetaArg :: ArgInfo -> ArgName -> Type -> TCM (MetaId, Term)

-- | Create a questionmark according to the <a>Hiding</a> info.
newInteractionMetaArg :: ArgInfo -> ArgName -> Type -> TCM (MetaId, Term)
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

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 <tt>DotFlex</tt>,
--   then...
data FlexibleVarKind

-- | From a record pattern (<a>ConP</a>). Saves the <a>FlexibleVarKind</a>
--   of its subpatterns.
RecordFlex :: [FlexibleVarKind] -> FlexibleVarKind

-- | From a hidden formal argument or underscore (<tt>WildP</tt>).
ImplicitFlex :: FlexibleVarKind

-- | From a dot pattern (<a>DotP</a>).
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 -> Maybe Int -> a -> FlexibleVar a
[flexHiding] :: FlexibleVar a -> Hiding
[flexKind] :: FlexibleVar a -> FlexibleVarKind
[flexPos] :: FlexibleVar a -> Maybe Int
[flexVar] :: FlexibleVar a -> a
defaultFlexibleVar :: a -> FlexibleVar a
flexibleVarFromHiding :: Hiding -> a -> FlexibleVar a
allFlexVars :: Telescope -> FlexibleVars
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 <tt>split</tt>. [Ulf Norell's
--   PhD, page. 35]
--   
--   In <tt>Problem ps p delta</tt>, <tt>ps</tt> are the user patterns of
--   supposed type <tt>delta</tt>. <tt>p</tt> 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: <tt> f : (b : Bool) -&gt; if b then Nat else Nat -&gt; Nat f
--   true = zero f false zero = zero f false (suc n) = n </tt> In this
--   sitation, for clause 2, we construct an initial problem <tt>
--   problemInPat = [false] problemTel = (b : Bool) problemRest.restPats =
--   [zero] problemRest.restType = if b then Nat else Nat -&gt; Nat </tt>
--   As we instantiate <tt>b</tt> to <tt>false</tt>, the <a>restType</a>
--   reduces to <tt>Nat -&gt; Nat</tt> and we can move pattern
--   <tt>zero</tt> over to <tt>problemInPat</tt>.
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 <a>restPats</a>. Can be <a>Irrelevant</a> 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 -> ConOrigin -> [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 -> ConOrigin
[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 <tt>splitProblem</tt>: Determines position for the next
--   split.
data SplitProblem

-- | Split on constructor pattern.
Split :: ProblemPart -> Arg Focus -> Abs ProblemPart -> SplitProblem

-- | The typed user patterns left of the split position. Invariant:
--   <tt><a>problemRest</a> == empty</tt>.
[splitLPats] :: SplitProblem -> ProblemPart

-- | 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 -> ProjOrigin -> Type -> SplitProblem

-- | The projection could be belonging to an irrelevant record field.
[splitProjection] :: SplitProblem -> Arg QName
[splitProjOrigin] :: SplitProblem -> ProjOrigin
[splitRestType] :: SplitProblem -> Type

-- | Put a typed pattern on the very left of a <tt>SplitProblem</tt>.
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 <a>Nothing</a> if this is an instantiation of
--   an implicit argument or a name.
data DotPatternInst
DPI :: Maybe Name -> Maybe Expr -> Term -> Dom Type -> DotPatternInst
[dotPatternName] :: DotPatternInst -> Maybe Name
[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 -> [DotPatternInst] -> LHSState
[lhsProblem] :: LHSState -> Problem
[lhsDPI] :: LHSState -> [DotPatternInst]
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 Data.Semigroup.Semigroup Agda.TypeChecking.Rules.LHS.Problem.FlexChoice
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 a => Agda.TypeChecking.Rules.LHS.Problem.ChooseFlex (GHC.Base.Maybe 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.Class.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Rules.LHS.Problem.ProblemRest
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term (Agda.TypeChecking.Rules.LHS.Problem.Problem' p)
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.Rules.LHS.Problem.DotPatternInst
instance Agda.TypeChecking.Substitute.Class.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.Pretty.Pretty Agda.TypeChecking.Rules.LHS.Problem.AsBinding
instance Agda.TypeChecking.Reduce.InstantiateFull 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
--   
--   <pre>
--   f ps with as
--   {f ps₁i qsi = bi}
--   </pre>
--   
--   is represented internally as
--   
--   <pre>
--   f ps = f-aux xs as      where xs   = vars(ps)
--   {f-aux ps₂i qsi = bi}   where ps₁i = ps[ps₂i/xs]
--   </pre>
--   
--   The inlining transformation turns this into
--   
--   <pre>
--   {f ps = aj} for aj ∈ as
--   {f ps₁i qsi = bi}
--   </pre>
--   
--   The first set of clauses, called <a>withExprClauses</a>, ensure that
--   we don't forget any recursive calls in <tt>as</tt>. The second set of
--   clauses, henceforth called <a>inlinedClauses</a>, 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 <tt>f</tt> (since there are additional
--   patterns <tt>qsi</tt>) nor with the type of <tt>f-aux</tt> (since
--   there are the surface-level patterns <tt>ps₁i</tt> instead of the
--   actual patterns <tt>ps₂i</tt>).
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 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 <tt>reduce</tt>.
getOrigConHead :: QName -> TCM ConHead

-- | 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

-- | <tt>getConType c t</tt> computes the constructor parameters from type
--   <tt>t</tt> and returns the instantiated type of constructor
--   <tt>c</tt>. <tt>Nothing</tt> if <tt>t</tt> is not a data/record type
--   or does not have a constructor <tt>c</tt>. Precondition: <tt>t</tt> 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 <tt>c</tt>, use <tt>either
--   id size <a>$</a> getConstructorArity c</tt>.
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: <a>Term</a> is <tt>reduce</tt>d.
isDataOrRecord :: Term -> TCM (Maybe QName)
getNumberOfParameters :: QName -> TCM (Maybe Nat)

-- | Precondition: Name is a data or record type.
getConstructors :: QName -> TCM [QName]
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

-- | Takes the name of the data/record type.
computeErasedConstructorArgs :: QName -> TCM ()
instance GHC.Show.Show Agda.Compiler.Treeless.Erase.TypeInfo
instance GHC.Classes.Eq Agda.Compiler.Treeless.Erase.TypeInfo

module Agda.TypeChecking.Polarity

-- | Infimum on the information lattice. <a>Invariant</a> is bottom
--   (dominant for inf), <a>Nonvariant</a> is top (neutral for inf).
(/\) :: Polarity -> Polarity -> Polarity

-- | <a>Polarity</a> 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, <a>Invariant</a> if empty.
nextPolarity :: [Polarity] -> (Polarity, [Polarity])

-- | Replace <a>Nonvariant</a> by <a>Covariant</a>. (Arbitrary bias, but
--   better than <a>Invariant</a>, 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).
--   <tt>enablePhantomTypes</tt> turns <a>Nonvariant</a> parameters to
--   <a>Covariant</a> to enable phantoms.
enablePhantomTypes :: Defn -> [Polarity] -> [Polarity]

-- | Make arguments <a>Invariant</a> if the type of a not-<a>Nonvariant</a>
--   later argument depends on it. Also, enable phantom types by turning
--   <a>Nonvariant</a> 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 <a>Relevance</a>.
mkUnused :: Relevance -> Relevance

-- | Improve <a>Relevance</a> information in a type by polarity
--   information. <a>Nonvariant</a> becomes <a>UnusedArg</a>.
nonvariantToUnusedArg :: [Polarity] -> Type -> TCM Type

-- | Propagate <a>Nonvariant</a> <a>Polarity</a> to <a>Relevance</a>
--   information in <a>Arg</a>s 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
--   test<i>succeed</i>PolaritySizeSucData.agda for a case where this is
--   needed.
sizePolarity :: QName -> [Polarity] -> TCM [Polarity]

-- | <tt>checkSizeIndex d np i a</tt> checks that constructor target type
--   <tt>a</tt> has form <tt>d ps (↑ i) idxs</tt> where <tt>|ps| = np</tt>.
--   
--   Precondition: <tt>a</tt> is reduced and of form <tt>d ps idxs0</tt>.
checkSizeIndex :: QName -> Nat -> Nat -> Type -> TCM Bool

-- | <tt>polarities i a</tt> computes the list of polarities of de Bruijn
--   index <tt>i</tt> in syntactic entity <tt>a</tt>.
class HasPolarity a
polarities :: HasPolarity a => Nat -> a -> TCM [Polarity]

-- | <tt>polarity i a</tt> computes the polarity of de Bruijn index
--   <tt>i</tt> in syntactic entity <tt>a</tt> by taking the infimum of all
--   <a>polarities</a>.
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 <tt>record{xs = es}</tt> might not mention
--   all visible fields. <tt>insertMissingFields</tt> 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]

-- | 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))

-- | Get the original projection info for name.
origProjection :: HasConstInfo m => QName -> m (QName, Definition, Maybe Projection)

-- | <tt>getDefType f t</tt> computes the type of (possibly
--   projection-(like)) function <tt>f</tt> whose first argument has type
--   <tt>t</tt>. The <tt>parameters</tt> for <tt>f</tt> are extracted from
--   <tt>t</tt>. <tt>Nothing</tt> if <tt>f</tt> is projection(like) but
--   <tt>t</tt> is not a data<i>record</i>axiom type.
--   
--   Precondition: <tt>t</tt> is reduced.
--   
--   See also: <a>getConType</a>
getDefType :: QName -> Type -> TCM (Maybe Type)

-- | The analogue of <a>piApply</a>. If <tt>v</tt> is a value of record
--   type <tt>t</tt> with field <tt>f</tt>, then <tt>projectTyped v t
--   f</tt> returns the type of <tt>f v</tt>. And also the record type (as
--   first result).
--   
--   Works also for projection-like definitions <tt>f</tt>. In this case,
--   the first result is not a record type.
--   
--   Precondition: <tt>t</tt> is reduced.
projectTyped :: Term -> Type -> ProjOrigin -> QName -> TCM (Maybe (Dom Type, 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 :: HasConstInfo m => QName -> m (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 ()

-- | Turn on eta for non-recursive record, unless user declared otherwise.
nonRecursiveRecord :: QName -> TCM ()

-- | Check whether record type is marked as recursive.
--   
--   Precondition: record type identifier exists in signature.
isRecursiveRecord :: QName -> TCM Bool

-- | Version of <tt>recRecursive</tt> with proper internal error.
recRecursive_ :: Defn -> Bool

-- | <pre>
--   etaExpandBoundVar i = (Δ, σ, τ)
--   </pre>
--   
--   Precondition: The current context is <tt>Γ = Γ₁, x:R pars, Γ₂</tt>
--   where <tt>|Γ₂| = i</tt> and <tt>R</tt> is a eta-expandable record type
--   with constructor <tt>c</tt> and fields <tt>Γ'</tt>.
--   
--   Postcondition: <tt>Δ = Γ₁, Γ', Γ₂[c Γ']</tt> and <tt>Γ ⊢ σ : Δ</tt>
--   and <tt>Δ ⊢ τ : Γ</tt>.
etaExpandBoundVar :: Int -> TCM (Maybe (Telescope, Substitution, Substitution))

-- | <pre>
--   expandRecordVar i Γ = (Δ, σ, τ, Γ')
--   </pre>
--   
--   Precondition: <tt>Γ = Γ₁, x:R pars, Γ₂</tt> where <tt>|Γ₂| = i</tt>
--   and <tt>R</tt> is a eta-expandable record type with constructor
--   <tt>c</tt> and fields <tt>Γ'</tt>.
--   
--   Postcondition: <tt>Δ = Γ₁, Γ', Γ₂[c Γ']</tt> and <tt>Γ ⊢ σ : Δ</tt>
--   and <tt>Δ ⊢ τ : Γ</tt>.
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)

-- | <pre>
--   curryAt v (Γ (y : R pars) -&gt; B) n =
--        (  v -&gt; λ Γ ys → v Γ (c ys)            {- curry   -}
--        ,  v -&gt; λ Γ y → v Γ (p1 y) ... (pm y)  {- uncurry -}
--        , Γ (ys : As) → B[c ys / y]
--        )
--   </pre>
--   
--   where <tt>n = size Γ</tt>.
curryAt :: Type -> Int -> TCM (Term -> Term, Term -> Term, Type)

-- | <tt>etaExpand r pars u</tt> computes the eta expansion of record value
--   <tt>u</tt> at record type <tt>r pars</tt>.
--   
--   The first argument <tt>r</tt> should be the name of an eta-expandable
--   record type. Given
--   
--   <pre>
--   record R : Set where field x : A; y : B; .z : C
--   </pre>
--   
--   and <tt>r : R</tt>,
--   
--   <pre>
--   etaExpand R [] r = (tel, [R.x r, R.y r, R.z r])
--   </pre>
--   
--   where <tt>tel</tt> is the record telescope instantiated at the
--   parameters <tt>pars</tt>.
etaExpandRecord :: QName -> Args -> Term -> TCM (Telescope, Args)

-- | Eta expand a record regardless of whether it's an eta-record or not.
forceEtaExpandRecord :: QName -> Args -> Term -> TCM (Telescope, Args)
etaExpandRecord' :: Bool -> QName -> Args -> Term -> TCM (Telescope, Args)
etaExpandRecord_ :: QName -> Args -> Defn -> Term -> TCM (Telescope, ConHead, ConInfo, Args)
etaExpandRecord'_ :: Bool -> QName -> Args -> Defn -> Term -> TCM (Telescope, ConHead, ConInfo, Args)
etaExpandAtRecordType :: Type -> Term -> TCM (Telescope, Term)

-- | The fields should be eta contracted already.
--   
--   We can eta contract if all fields <tt>f = ...</tt> are irrelevant or
--   all fields <tt>f</tt> are the projection <tt>f v</tt> of the same
--   value <tt>v</tt>, but we need at least one relevant field to find the
--   value <tt>v</tt>.
--   
--   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 -> ConInfo -> 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)
class NormaliseProjP a
normaliseProjP :: (NormaliseProjP a, HasConstInfo m) => a -> m a
instance Agda.TypeChecking.Records.NormaliseProjP Agda.Syntax.Internal.Clause
instance Agda.TypeChecking.Records.NormaliseProjP a => Agda.TypeChecking.Records.NormaliseProjP [a]
instance Agda.TypeChecking.Records.NormaliseProjP a => Agda.TypeChecking.Records.NormaliseProjP (Agda.Syntax.Common.Arg a)
instance Agda.TypeChecking.Records.NormaliseProjP a => Agda.TypeChecking.Records.NormaliseProjP (Agda.Syntax.Common.Named_ a)
instance Agda.TypeChecking.Records.NormaliseProjP (Agda.Syntax.Internal.Pattern' x)


-- | The monad for the termination checker.
--   
--   The termination monad <tt>TerM</tt> is an extension of the type
--   checking monad <a>TCM</a> 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 <a>Target</a> are considered guarding.
[terTarget] :: TerEnv -> Maybe Target

-- | Are we checking a delayed definition?
[terDelayed] :: TerEnv -> Delayed

-- | Only consider the <a>notMasked</a> <a>False</a> arguments for
--   establishing termination. See issue #1023.
[terMaskArgs] :: TerEnv -> [Bool]

-- | Only consider guardedness if <a>False</a> (not masked).
[terMaskResult] :: TerEnv -> Bool

-- | How many <tt>SIZELT</tt> 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. (See issue #1015).
[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 <tt>IMPOSSIBLE</tt>.
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 <a>_terSizeDepth</a>.
terSizeDepth :: Lens' Int TerEnv

-- | Lens for <a>terUsableVars</a>.
terGetUsableVars :: TerM VarSet
terModifyUsableVars :: (VarSet -> VarSet) -> TerM a -> TerM a
terSetUsableVars :: VarSet -> TerM a -> TerM a

-- | Lens for <a>terUseSizeLt</a>.
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 <a>terUseSizeLt</a> when going under constructor <tt>c</tt>.
conUseSizeLt :: QName -> TerM a -> TerM a

-- | Set <a>terUseSizeLt</a> for arguments following projection <tt>q</tt>.
--   We disregard j&lt;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 :: ProjOrigin -> 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

-- | <tt>raiseDBP n ps</tt> increases each de Bruijn index in <tt>ps</tt>
--   by <tt>n</tt>. Needed when going under a binder during analysis of a
--   term.
raiseDBP :: Int -> DeBruijnPats -> DeBruijnPats

-- | Extract variables from <a>DeBruijnPat</a>s 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 <a>CallInfo</a>. As
--   long as we never look at it, only accumulate it, it does not matter
--   whether we use <tt>Set</tt>, (nub) list, or <tt>Tree</tt>. Internally,
--   due to lazyness, it is anyway a binary tree of <a>mappend</a> nodes
--   and singleton leafs. Since we define no order on <a>CallInfo</a>
--   (expensive), we cannot use a <tt>Set</tt> 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 <a>CallInfo</a>).

-- | A very crude way of estimating the <tt>SIZELT</tt> chains <tt>i &gt; j
--   &gt; k</tt> 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 Data.Semigroup.Semigroup 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.TypeChecking.Monad.Signature.HasConstInfo Agda.Termination.Monad.TerM
instance Agda.Syntax.Abstract.Name.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:
--   
--   <ul>
--   <li>Compute flex/rigid for its arguments.</li>
--   <li>Compare to allowed variables.</li>
--   <li>Mark arguments with rigid occurrences of disallowed variables for
--   deletion.</li>
--   <li>Attempt to delete marked arguments.</li>
--   <li>We don't need to check for success, we can just continue occurs
--   checking.</li>
--   </ul>
module Agda.TypeChecking.MetaVars.Occurs
modifyOccursCheckDefs :: (Set QName -> Set QName) -> TCM ()

-- | Set the names of definitions to be looked at to the defs in the
--   current mutual block.
initOccursCheck :: MetaVariable -> TCM ()

-- | Is a def in the list of stuff to be checked?
defNeedsChecking :: QName -> TCM Bool

-- | Remove a def from the list of defs to be looked at.
tallyDef :: QName -> TCM ()
data OccursCtx

-- | We are in arguments of a meta.
Flex :: OccursCtx

-- | We are not in arguments of a meta but a bound var.
Rigid :: OccursCtx

-- | We are at the start or in the arguments of a constructor.
StronglyRigid :: OccursCtx

-- | We are at the term root (this turns into <tt>StronglyRigid</tt>).
Top :: OccursCtx

-- | We are in an irrelevant argument.
Irrel :: OccursCtx
data UnfoldStrategy
YesUnfold :: UnfoldStrategy
NoUnfold :: UnfoldStrategy
defArgs :: UnfoldStrategy -> OccursCtx -> OccursCtx
unfold :: UnfoldStrategy -> Term -> TCM (Blocked Term)

-- | Leave the top position.
leaveTop :: OccursCtx -> OccursCtx

-- | Leave the strongly rigid position.
weakly :: OccursCtx -> OccursCtx
strongly :: OccursCtx -> OccursCtx
patternViolation' :: Int -> String -> TCM a
abort :: OccursCtx -> TypeError -> TCM a

-- | Distinguish relevant and irrelevant variables in occurs check.
type Vars = ([Nat], [Nat])
goIrrelevant :: Vars -> Vars
allowedVar :: Nat -> Vars -> Bool
takeRelevant :: Vars -> [Nat]
liftUnderAbs :: Vars -> Vars

-- | Extended occurs check.
class Occurs t
occurs :: Occurs t => UnfoldStrategy -> OccursCtx -> MetaId -> Vars -> t -> TCM t
metaOccurs :: Occurs t => MetaId -> t -> TCM ()

-- | When assigning <tt>m xs := v</tt>, check that <tt>m</tt> does not
--   occur in <tt>v</tt> and that the free variables of <tt>v</tt> are
--   contained in <tt>xs</tt>.
occursCheck :: (Occurs a, InstantiateFull a, PrettyTCM a) => MetaId -> Vars -> a -> TCM a

-- | <tt>prune m' vs xs</tt> attempts to remove all arguments from
--   <tt>vs</tt> whose free variables are not contained in <tt>xs</tt>. If
--   successful, <tt>m'</tt> is solved by the new, pruned meta variable and
--   we return <tt>True</tt> else <tt>False</tt>.
--   
--   Issue 1147: If any of the meta args <tt>vs</tt> is matchable, e.g., is
--   a constructor term, we cannot prune, because the offending variables
--   could be removed by reduction for a suitable instantiation of the meta
--   variable.
prune :: MetaId -> Args -> [Nat] -> TCM PruneResult

-- | <tt>hasBadRigid xs v = Just True</tt> iff one of the rigid variables
--   in <tt>v</tt> is not in <tt>xs</tt>. Actually we can only prune if a
--   bad variable is in the head. See issue 458. Or in a non-eliminateable
--   position (see succeed/PruningNonMillerPattern).
--   
--   <tt>hasBadRigid xs v = Nothing</tt> means that we cannot prune at all
--   as one of the meta args is matchable. (See issue 1147.)
hasBadRigid :: [Nat] -> Term -> ExceptT () TCM Bool

-- | Check whether a term <tt>Def f es</tt> is finally stuck. Currently, we
--   give only a crude approximation.
isNeutral :: MonadTCM tcm => Blocked t -> QName -> Elims -> tcm Bool

-- | Check whether any of the variables (given as de Bruijn indices) occurs
--   *definitely* in the term in a rigid position. Reduces the term
--   successively to remove variables in dead subterms. This fixes issue
--   1386.
rigidVarsNotContainedIn :: (MonadTCM tcm, FoldRigid a) => a -> [Nat] -> tcm Bool

-- | Collect the *definitely* rigid variables in a monoid. We need to
--   successively reduce the expression to do this.
class FoldRigid a
foldRigid :: (FoldRigid a, Monoid (TCM m)) => (Nat -> TCM m) -> a -> TCM m
data PruneResult

-- | the kill list is empty or only <tt>False</tt>s
NothingToPrune :: PruneResult

-- | there is no possible kill (because of type dep.)
PrunedNothing :: PruneResult

-- | managed to kill some args in the list
PrunedSomething :: PruneResult

-- | all prescribed kills where performed
PrunedEverything :: PruneResult

-- | <tt>killArgs [k1,...,kn] X</tt> prunes argument <tt>i</tt> from
--   metavar <tt>X</tt> if <tt>ki==True</tt>. Pruning is carried out
--   whenever &gt; 0 arguments can be pruned.
killArgs :: [Bool] -> MetaId -> TCM PruneResult

-- | <tt>killedType [((x1,a1),k1)..((xn,an),kn)] b = ([k'1..k'n],t')</tt>
--   (ignoring <tt>Dom</tt>). Let <tt>t' = (xs:as) -&gt; b</tt>. Invariant:
--   <tt>k'i == True</tt> iff <tt>ki == True</tt> and pruning the
--   <tt>i</tt>th argument from type <tt>b</tt> is possible without
--   creating unbound variables. <tt>t'</tt> is type <tt>t</tt> after
--   pruning all <tt>k'i==True</tt>.
killedType :: [(Dom (ArgName, Type), Bool)] -> Type -> ([Arg Bool], Type)

-- | Instantiate a meta variable with a new one that only takes the
--   arguments which are not pruneable.
performKill :: [Arg Bool] -> MetaId -> Type -> TCM ()
instance GHC.Show.Show Agda.TypeChecking.MetaVars.Occurs.PruneResult
instance GHC.Classes.Eq Agda.TypeChecking.MetaVars.Occurs.PruneResult
instance GHC.Show.Show Agda.TypeChecking.MetaVars.Occurs.UnfoldStrategy
instance GHC.Classes.Eq Agda.TypeChecking.MetaVars.Occurs.UnfoldStrategy
instance GHC.Show.Show Agda.TypeChecking.MetaVars.Occurs.OccursCtx
instance GHC.Classes.Eq Agda.TypeChecking.MetaVars.Occurs.OccursCtx
instance Agda.TypeChecking.MetaVars.Occurs.Occurs Agda.Syntax.Internal.Term
instance Agda.TypeChecking.MetaVars.Occurs.Occurs Agda.Syntax.Abstract.Name.QName
instance Agda.TypeChecking.MetaVars.Occurs.Occurs Agda.TypeChecking.Monad.Base.Defn
instance Agda.TypeChecking.MetaVars.Occurs.Occurs Agda.Syntax.Internal.Clause
instance Agda.TypeChecking.MetaVars.Occurs.Occurs Agda.Syntax.Internal.Level
instance Agda.TypeChecking.MetaVars.Occurs.Occurs Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.MetaVars.Occurs.Occurs Agda.Syntax.Internal.LevelAtom
instance Agda.TypeChecking.MetaVars.Occurs.Occurs Agda.Syntax.Internal.Type
instance Agda.TypeChecking.MetaVars.Occurs.Occurs Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.MetaVars.Occurs.Occurs a => Agda.TypeChecking.MetaVars.Occurs.Occurs (Agda.Syntax.Internal.Elim' a)
instance (Agda.TypeChecking.MetaVars.Occurs.Occurs a, Agda.TypeChecking.Substitute.Class.Subst t a) => Agda.TypeChecking.MetaVars.Occurs.Occurs (Agda.Syntax.Internal.Abs a)
instance Agda.TypeChecking.MetaVars.Occurs.Occurs a => Agda.TypeChecking.MetaVars.Occurs.Occurs (Agda.Syntax.Common.Arg a)
instance Agda.TypeChecking.MetaVars.Occurs.Occurs a => Agda.TypeChecking.MetaVars.Occurs.Occurs (Agda.Syntax.Common.Dom a)
instance (Agda.TypeChecking.MetaVars.Occurs.Occurs a, Agda.TypeChecking.MetaVars.Occurs.Occurs b) => Agda.TypeChecking.MetaVars.Occurs.Occurs (a, b)
instance Agda.TypeChecking.MetaVars.Occurs.Occurs a => Agda.TypeChecking.MetaVars.Occurs.Occurs [a]
instance Agda.TypeChecking.MetaVars.Occurs.Occurs a => Agda.TypeChecking.MetaVars.Occurs.Occurs (GHC.Base.Maybe a)
instance Agda.TypeChecking.MetaVars.Occurs.FoldRigid Agda.Syntax.Internal.Term
instance Agda.TypeChecking.MetaVars.Occurs.FoldRigid Agda.Syntax.Internal.Type
instance Agda.TypeChecking.MetaVars.Occurs.FoldRigid Agda.Syntax.Internal.Sort
instance Agda.TypeChecking.MetaVars.Occurs.FoldRigid Agda.Syntax.Internal.Level
instance Agda.TypeChecking.MetaVars.Occurs.FoldRigid Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.MetaVars.Occurs.FoldRigid Agda.Syntax.Internal.LevelAtom
instance (Agda.TypeChecking.Substitute.Class.Subst t a, Agda.TypeChecking.MetaVars.Occurs.FoldRigid a) => Agda.TypeChecking.MetaVars.Occurs.FoldRigid (Agda.Syntax.Internal.Abs a)
instance Agda.TypeChecking.MetaVars.Occurs.FoldRigid a => Agda.TypeChecking.MetaVars.Occurs.FoldRigid (Agda.Syntax.Common.Arg a)
instance Agda.TypeChecking.MetaVars.Occurs.FoldRigid a => Agda.TypeChecking.MetaVars.Occurs.FoldRigid (Agda.Syntax.Common.Dom a)
instance Agda.TypeChecking.MetaVars.Occurs.FoldRigid a => Agda.TypeChecking.MetaVars.Occurs.FoldRigid (Agda.Syntax.Internal.Elim' a)
instance Agda.TypeChecking.MetaVars.Occurs.FoldRigid a => Agda.TypeChecking.MetaVars.Occurs.FoldRigid [a]
instance (Agda.TypeChecking.MetaVars.Occurs.FoldRigid a, Agda.TypeChecking.MetaVars.Occurs.FoldRigid b) => Agda.TypeChecking.MetaVars.Occurs.FoldRigid (a, b)


-- | 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 (<tt>DontKnow</tt>) we want to know
--   whether it is due to a particular meta variable.
data Match a
Yes :: Simplification -> (IntMap (Arg a)) -> Match a
No :: Match a
DontKnow :: (Blocked ()) -> Match a
matchedArgs :: Empty -> Int -> IntMap (Arg a) -> [Arg a]

-- | Builds a proper substitution from an IntMap produced by
--   match(Co)patterns
buildSubstitution :: (DeBruijn a) => Empty -> Int -> IntMap (Arg a) -> Substitution' a

-- | Instead of <tt>zipWithM</tt>, 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])

-- | <tt>matchCopatterns ps es</tt> matches spine <tt>es</tt> against
--   copattern spine <tt>ps</tt>.
--   
--   Returns <a>Yes</a> and a substitution for the pattern variables (in
--   form of IntMap Term) if matching was successful.
--   
--   Returns <a>No</a> if there was a constructor or projection mismatch.
--   
--   Returns <a>DontKnow</a> if an argument could not be evaluated to
--   constructor form because of a blocking meta variable.
--   
--   In any case, also returns spine <tt>es</tt> in reduced form (with all
--   the weak head reductions performed that were necessary to come to a
--   decision).
matchCopatterns :: [NamedArg DeBruijnPattern] -> [Elim] -> ReduceM (Match Term, [Elim])

-- | Match a single copattern.
matchCopattern :: DeBruijnPattern -> Elim -> ReduceM (Match Term, Elim)
matchPatterns :: [NamedArg DeBruijnPattern] -> [Arg Term] -> ReduceM (Match Term, [Arg Term])

-- | Match a single pattern.
matchPattern :: DeBruijnPattern -> 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)


-- | Check that a datatype is strictly positive.
module Agda.TypeChecking.Positivity
type Graph n e = Graph n n e

-- | Check that the datatypes in the mutual block containing the given
--   declarations are strictly positive.
--   
--   Also add information about positivity and recursivity of records to
--   the signature.
checkStrictlyPositive :: MutualInfo -> Set QName -> TCM ()
getDefArity :: Definition -> TCM Int
(>*<) :: OccursWhere -> OccursWhere -> OccursWhere
data Item
AnArg :: Nat -> Item
ADef :: QName -> Item
type Occurrences = Map Item [OccursWhere]

-- | Used to build <a>Occurrences</a> and occurrence graphs.
data OccurrencesBuilder
Concat :: [OccurrencesBuilder] -> OccurrencesBuilder
OccursAs :: Where -> OccurrencesBuilder -> OccurrencesBuilder
OccursHere :: Item -> OccurrencesBuilder

-- | <tt>OnlyVarsUpTo n occs</tt> discards occurrences of de Bruijn index
--   <tt>&gt;= n</tt>.
OnlyVarsUpTo :: Nat -> OccurrencesBuilder -> OccurrencesBuilder

-- | Used to build <a>Occurrences</a> and occurrence graphs.
data OccurrencesBuilder'
Concat' :: [OccurrencesBuilder'] -> OccurrencesBuilder'
OccursAs' :: Where -> OccurrencesBuilder' -> OccurrencesBuilder'
OccursHere' :: Item -> OccursWhere -> OccurrencesBuilder'
emptyOB :: OccurrencesBuilder
(>+<) :: OccurrencesBuilder -> OccurrencesBuilder -> OccurrencesBuilder

-- | Removes <a>OnlyVarsUpTo</a> entries and adds <a>OccursWhere</a>
--   entries.
--   
--   WARNING: There can be lots of sharing between the generated
--   <a>OccursWhere</a> entries. Traversing all of these entries could be
--   expensive. (See <a>computeEdges</a> for an example.)
preprocess :: OccurrencesBuilder -> OccurrencesBuilder'

-- | A type used locally in <a>flatten</a>.
data OccursWheres
(:++) :: OccursWheres -> OccursWheres -> OccursWheres
Occurs :: OccursWhere -> OccursWheres

-- | An interpreter for <a>OccurrencesBuilder</a>.
--   
--   WARNING: There can be lots of sharing between the generated
--   <a>OccursWhere</a> entries. Traversing all of these entries could be
--   expensive. (See <a>computeEdges</a> for an example.)
flatten :: OccurrencesBuilder -> Occurrences

-- | Context for computing occurrences.
data OccEnv
OccEnv :: [Maybe Item] -> Maybe QName -> OccEnv

-- | Items corresponding to the free variables.
--   
--   Potential invariant: It seems as if the list has the form
--   <tt><a>genericReplicate</a> n <a>Nothing</a> ++ <a>map</a>
--   (<a>Just</a> . <a>AnArg</a>) is</tt>, for some <tt>n</tt> and
--   <tt>is</tt>, where <tt>is</tt> is decreasing (non-strictly).
[vars] :: OccEnv -> [Maybe Item]

-- | Name for ∞ builtin.
[inf] :: OccEnv -> Maybe QName

-- | Monad for computing occurrences.
type OccM = Reader OccEnv
withExtendedOccEnv :: Maybe Item -> OccM a -> OccM a
withExtendedOccEnv' :: [Maybe Item] -> OccM a -> OccM a

-- | Running the monad
getOccurrences :: (Show a, PrettyTCM a, ComputeOccurrences a) => [Maybe Item] -> a -> TCM OccurrencesBuilder
class ComputeOccurrences a
occurrences :: ComputeOccurrences a => a -> OccM OccurrencesBuilder

-- | Computes the occurrences in the given definition.
--   
--   WARNING: There can be lots of sharing between the <a>OccursWhere</a>
--   entries. Traversing all of these entries could be expensive. (See
--   <a>computeEdges</a> for an example.)
computeOccurrences :: QName -> TCM Occurrences

-- | Computes the occurrences in the given definition.
computeOccurrences' :: QName -> TCM OccurrencesBuilder

-- | Eta expand a clause to have the given number of variables. Warning:
--   doesn't put correct types in telescope! This is used instead of
--   special treatment of lambdas (which was unsound: issue 121)
etaExpandClause :: Nat -> Clause -> Clause
data Node
DefNode :: !QName -> Node
ArgNode :: !QName -> !Nat -> Node

-- | Edge labels for the positivity graph.
data Edge
Edge :: !Occurrence -> OccursWhere -> Edge

-- | These operations form a semiring if we quotient by the relation "the
--   <a>Occurrence</a> components are equal".

-- | As <a>OccursWhere</a> does not have an <a>oplus</a> we cannot do
--   something meaningful for the <tt>OccursWhere</tt> here.
--   
--   E.g. <tt>ostar (Edge JustNeg w) = Edge Mixed (w <a>oplus</a> (w
--   &gt;*&lt; w))</tt> would probably more sense, if we could do it.

-- | WARNING: There can be lots of sharing between the <a>OccursWhere</a>
--   entries in the edges. Traversing all of these entries could be
--   expensive. (See <a>computeEdges</a> for an example.)
buildOccurrenceGraph :: Set QName -> TCM (Graph Node Edge)

-- | Computes all non-<a>ozero</a> occurrence graph edges represented by
--   the given <a>OccurrencesBuilder</a>.
--   
--   WARNING: There can be lots of sharing between the <a>OccursWhere</a>
--   entries in the edges. Traversing all of these entries could be
--   expensive. For instance, for the function <tt>F</tt> in
--   <tt>benchmark<i>misc</i>SlowOccurrences.agda</tt> a large number of
--   edges from the argument <tt>X</tt> to the function <tt>F</tt> are
--   computed. These edges have polarity <a>StrictPos</a>, <a>JustNeg</a>
--   or <a>JustPos</a>, and contain the following <a>OccursWhere</a>
--   elements:
--   
--   <ul>
--   <li><tt><a>Known</a> (<a>fromList</a> [<a>InDefOf</a> <a>F</a>,
--   <a>InClause</a> 0])</tt>,</li>
--   <li><tt><a>Known</a> (<a>fromList</a> [<a>InDefOf</a> <a>F</a>,
--   <a>InClause</a> 0, <a>LeftOfArrow</a>])</tt>,</li>
--   <li><tt><a>Known</a> (<a>fromList</a> [<a>InDefOf</a> <a>F</a>,
--   <a>InClause</a> 0, <a>LeftOfArrow</a>, <a>LeftOfArrow</a>])</tt>,</li>
--   <li><tt><a>Known</a> (<a>fromList</a> [<a>InDefOf</a> <a>F</a>,
--   <a>InClause</a> 0, <a>LeftOfArrow</a>, <a>LeftOfArrow</a>,
--   <a>LeftOfArrow</a>])</tt>,</li>
--   <li>and so on.</li>
--   </ul>
computeEdges :: Set QName -> QName -> OccurrencesBuilder -> TCM [Edge Node Node Edge]
instance GHC.Show.Show Agda.TypeChecking.Positivity.Edge
instance GHC.Classes.Ord Agda.TypeChecking.Positivity.Edge
instance GHC.Classes.Eq Agda.TypeChecking.Positivity.Edge
instance GHC.Classes.Ord Agda.TypeChecking.Positivity.Node
instance GHC.Classes.Eq Agda.TypeChecking.Positivity.Node
instance GHC.Show.Show Agda.TypeChecking.Positivity.Item
instance GHC.Classes.Ord Agda.TypeChecking.Positivity.Item
instance GHC.Classes.Eq Agda.TypeChecking.Positivity.Item
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Positivity.Occurrence.OccursWhere
instance Agda.Utils.Size.Sized Agda.TypeChecking.Positivity.Occurrence.OccursWhere
instance Agda.Syntax.Position.HasRange Agda.TypeChecking.Positivity.Item
instance Agda.TypeChecking.Positivity.ComputeOccurrences Agda.Syntax.Internal.Clause
instance Agda.TypeChecking.Positivity.ComputeOccurrences Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Positivity.ComputeOccurrences Agda.Syntax.Internal.Level
instance Agda.TypeChecking.Positivity.ComputeOccurrences Agda.Syntax.Internal.PlusLevel
instance Agda.TypeChecking.Positivity.ComputeOccurrences Agda.Syntax.Internal.LevelAtom
instance Agda.TypeChecking.Positivity.ComputeOccurrences Agda.Syntax.Internal.Type
instance Agda.TypeChecking.Positivity.ComputeOccurrences a => Agda.TypeChecking.Positivity.ComputeOccurrences (Agda.Syntax.Internal.Tele a)
instance Agda.TypeChecking.Positivity.ComputeOccurrences a => Agda.TypeChecking.Positivity.ComputeOccurrences (Agda.Syntax.Internal.Abs a)
instance Agda.TypeChecking.Positivity.ComputeOccurrences a => Agda.TypeChecking.Positivity.ComputeOccurrences (Agda.Syntax.Internal.Elim' a)
instance Agda.TypeChecking.Positivity.ComputeOccurrences a => Agda.TypeChecking.Positivity.ComputeOccurrences (Agda.Syntax.Common.Arg a)
instance Agda.TypeChecking.Positivity.ComputeOccurrences a => Agda.TypeChecking.Positivity.ComputeOccurrences (Agda.Syntax.Common.Dom a)
instance Agda.TypeChecking.Positivity.ComputeOccurrences a => Agda.TypeChecking.Positivity.ComputeOccurrences [a]
instance Agda.TypeChecking.Positivity.ComputeOccurrences a => Agda.TypeChecking.Positivity.ComputeOccurrences (GHC.Base.Maybe a)
instance (Agda.TypeChecking.Positivity.ComputeOccurrences a, Agda.TypeChecking.Positivity.ComputeOccurrences b) => Agda.TypeChecking.Positivity.ComputeOccurrences (a, b)
instance GHC.Show.Show Agda.TypeChecking.Positivity.Node
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Positivity.Node
instance Agda.TypeChecking.Pretty.PrettyTCM n => Agda.TypeChecking.Pretty.PrettyTCM (Agda.TypeChecking.Pretty.WithNode n Agda.TypeChecking.Positivity.Edge)
instance Agda.Utils.Null.Null Agda.TypeChecking.Positivity.Edge
instance Agda.Utils.SemiRing.SemiRing Agda.TypeChecking.Positivity.Edge
instance Agda.Utils.SemiRing.StarSemiRing Agda.TypeChecking.Positivity.Edge

module Agda.TypeChecking.Errors
prettyError :: MonadTCM tcm => TCErr -> tcm String
tcErrString :: TCErr -> String
prettyTCWarnings :: [TCWarning] -> TCM String

-- | Turns all warnings into errors.
tcWarningsToError :: [TCWarning] -> TCM a

-- | Depending which flags are set, one may happily ignore some warnings.
applyFlagsToTCWarnings :: IgnoreFlags -> [TCWarning] -> TCM [TCWarning]
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.TCWarning
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Monad.Base.Warning
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)

module Agda.TypeChecking.InstanceArguments

-- | Compute a list of instance candidates. <a>Nothing</a> if type is a
--   meta, error if type is not eligible for instance search.
initialIFSCandidates :: Type -> TCM (Maybe [Candidate])

-- | <tt>findInScope m (v,a)s</tt> tries to instantiate on of the types
--   <tt>a</tt>s of the candidate terms <tt>v</tt>s to the type <tt>t</tt>
--   of the metavariable <tt>m</tt>. If successful, meta <tt>m</tt> is
--   solved with the instantiation of <tt>v</tt>. If unsuccessful, the
--   constraint is regenerated, with possibly reduced candidate set. The
--   list of candidates is equal to <tt>Nothing</tt> 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 <tt>t</tt> 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
HellNo :: TCErr -> YesNoMaybe
isNo :: YesNoMaybe -> Bool

-- | Given a meta <tt>m</tt> of type <tt>t</tt> and a list of candidates
--   <tt>cands</tt>, <tt>checkCandidates m t cands</tt> 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 <a>conPars</a> arguments. See Issue670a. Andreas, 2013-11-07
--   Also do this for projections, see Issue670b.
applyDroppingParameters :: Term -> Args -> TCM Term
instance GHC.Show.Show Agda.TypeChecking.InstanceArguments.YesNoMaybe


-- | Primitive functions, such as addition on builtin integers.
module Agda.TypeChecking.Primitive
data PrimitiveImpl
PrimImpl :: Type -> PrimFun -> PrimitiveImpl
newtype Nat
Nat :: Integer -> Nat
[unNat] :: Nat -> Integer
newtype Lvl
Lvl :: Integer -> Lvl
[unLvl] :: Lvl -> Integer
class PrimType a
primType :: PrimType a => a -> TCM Type
class PrimTerm a
primTerm :: PrimTerm a => a -> TCM Term
class ToTerm a where toTermR = (pure .) <$> toTerm
toTerm :: ToTerm a => TCM (a -> Term)
toTermR :: ToTerm a => TCM (a -> ReduceM Term)

-- | <tt>buildList A ts</tt> builds a list of type <tt>List A</tt>. Assumes
--   that the terms <tt>ts</tt> all have type <tt>A</tt>.
buildList :: TCM ([Term] -> Term)
type FromTermFunction a = Arg Term -> ReduceM (Reduced (MaybeReduced (Arg Term)) a)
class FromTerm a
fromTerm :: FromTerm a => TCM (FromTermFunction a)

-- | Conceptually: <tt>redBind m f k = either (return . Left . f) k
--   =&lt;&lt; m</tt>
redBind :: ReduceM (Reduced a a') -> (a -> b) -> (a' -> ReduceM (Reduced b b')) -> ReduceM (Reduced b b')
redReturn :: a -> ReduceM (Reduced a' a)
fromReducedTerm :: (Term -> Maybe a) -> TCM (FromTermFunction a)
fromLiteral :: (Literal -> Maybe a) -> TCM (FromTermFunction a)
primTrustMe :: TCM PrimitiveImpl
genPrimForce :: TCM Type -> (Term -> Arg Term -> Term) -> TCM PrimitiveImpl
primForce :: TCM PrimitiveImpl
primForceLemma :: TCM PrimitiveImpl
mkPrimLevelZero :: TCM PrimitiveImpl
mkPrimLevelSuc :: TCM PrimitiveImpl
mkPrimLevelMax :: TCM PrimitiveImpl
mkPrimFun1TCM :: (FromTerm a, ToTerm b, TermLike b) => TCM Type -> (a -> ReduceM b) -> TCM PrimitiveImpl
mkPrimFun1 :: (PrimType a, FromTerm a, PrimType b, ToTerm b) => (a -> b) -> TCM PrimitiveImpl
mkPrimFun2 :: (PrimType a, FromTerm a, ToTerm a, PrimType b, FromTerm b, PrimType c, ToTerm c) => (a -> b -> c) -> TCM PrimitiveImpl
mkPrimFun4 :: (PrimType a, FromTerm a, ToTerm a, PrimType b, FromTerm b, ToTerm b, PrimType c, FromTerm c, ToTerm c, PrimType d, FromTerm d, PrimType e, ToTerm e) => (a -> b -> c -> d -> e) -> TCM PrimitiveImpl
(-->) :: TCM Type -> TCM Type -> TCM Type
infixr 4 -->
(.-->) :: TCM Type -> TCM Type -> TCM Type
infixr 4 .-->
(..-->) :: TCM Type -> TCM Type -> TCM Type
infixr 4 ..-->
garr :: (Relevance -> Relevance) -> TCM Type -> TCM Type -> TCM Type
gpi :: ArgInfo -> String -> TCM Type -> TCM Type -> TCM Type
hPi :: String -> TCM Type -> TCM Type -> TCM Type
nPi :: String -> TCM Type -> TCM Type -> TCM Type
varM :: Int -> TCM Term
gApply :: Hiding -> TCM Term -> TCM Term -> TCM Term
(<@>) :: TCM Term -> TCM Term -> TCM Term
infixl 9 <@>
(<#>) :: TCM Term -> TCM Term -> TCM Term
infixl 9 <#>
list :: TCM Term -> TCM Term
io :: TCM Term -> TCM Term
el :: TCM Term -> TCM Type
tset :: TCM Type
tSetOmega :: TCM Type
sSizeUniv :: Sort
tSizeUniv :: TCM Type

-- | Abbreviation: <tt>argN = <a>Arg</a> <a>defaultArgInfo</a></tt>.
argN :: e -> Arg e
domN :: e -> Dom e

-- | Abbreviation: <tt>argH = <a>hide</a> <a>Arg</a>
--   <a>defaultArgInfo</a></tt>.
argH :: e -> Arg e
domH :: e -> Dom e
type Op a = a -> a -> a
type Fun a = a -> a
type Rel a = a -> a -> Bool
type Pred a = a -> Bool
primitiveFunctions :: Map String (TCM PrimitiveImpl)
floatEq :: Double -> Double -> Bool
floatLt :: Double -> Double -> Bool
lookupPrimitiveFunction :: String -> TCM PrimitiveImpl
lookupPrimitiveFunctionQ :: QName -> TCM (String, PrimitiveImpl)
getBuiltinName :: String -> TCM (Maybe QName)
isBuiltin :: QName -> String -> TCM Bool
instance GHC.Classes.Ord Agda.TypeChecking.Primitive.Lvl
instance GHC.Classes.Eq Agda.TypeChecking.Primitive.Lvl
instance GHC.Real.Real Agda.TypeChecking.Primitive.Nat
instance GHC.Enum.Enum Agda.TypeChecking.Primitive.Nat
instance GHC.Num.Num Agda.TypeChecking.Primitive.Nat
instance GHC.Classes.Ord Agda.TypeChecking.Primitive.Nat
instance GHC.Classes.Eq Agda.TypeChecking.Primitive.Nat
instance GHC.Real.Integral Agda.TypeChecking.Primitive.Nat
instance Agda.Syntax.Internal.Generic.TermLike Agda.TypeChecking.Primitive.Nat
instance GHC.Show.Show Agda.TypeChecking.Primitive.Nat
instance GHC.Show.Show Agda.TypeChecking.Primitive.Lvl
instance (Agda.TypeChecking.Primitive.PrimType a, Agda.TypeChecking.Primitive.PrimType b) => Agda.TypeChecking.Primitive.PrimTerm (a -> b)
instance Agda.TypeChecking.Primitive.PrimTerm a => Agda.TypeChecking.Primitive.PrimType a
instance Agda.TypeChecking.Primitive.PrimTerm GHC.Integer.Type.Integer
instance Agda.TypeChecking.Primitive.PrimTerm GHC.Types.Bool
instance Agda.TypeChecking.Primitive.PrimTerm GHC.Types.Char
instance Agda.TypeChecking.Primitive.PrimTerm GHC.Types.Double
instance Agda.TypeChecking.Primitive.PrimTerm Agda.Utils.String.Str
instance Agda.TypeChecking.Primitive.PrimTerm Agda.TypeChecking.Primitive.Nat
instance Agda.TypeChecking.Primitive.PrimTerm Agda.TypeChecking.Primitive.Lvl
instance Agda.TypeChecking.Primitive.PrimTerm Agda.Syntax.Abstract.Name.QName
instance Agda.TypeChecking.Primitive.PrimTerm Agda.Syntax.Common.MetaId
instance Agda.TypeChecking.Primitive.PrimTerm Agda.Syntax.Internal.Type
instance Agda.TypeChecking.Primitive.PrimTerm Agda.Syntax.Fixity.Fixity'
instance Agda.TypeChecking.Primitive.PrimTerm a => Agda.TypeChecking.Primitive.PrimTerm [a]
instance Agda.TypeChecking.Primitive.PrimTerm a => Agda.TypeChecking.Primitive.PrimTerm (GHC.Types.IO a)
instance Agda.TypeChecking.Primitive.ToTerm Agda.TypeChecking.Primitive.Nat
instance Agda.TypeChecking.Primitive.ToTerm Agda.TypeChecking.Primitive.Lvl
instance Agda.TypeChecking.Primitive.ToTerm GHC.Types.Double
instance Agda.TypeChecking.Primitive.ToTerm GHC.Types.Char
instance Agda.TypeChecking.Primitive.ToTerm Agda.Utils.String.Str
instance Agda.TypeChecking.Primitive.ToTerm Agda.Syntax.Abstract.Name.QName
instance Agda.TypeChecking.Primitive.ToTerm Agda.Syntax.Common.MetaId
instance Agda.TypeChecking.Primitive.ToTerm GHC.Integer.Type.Integer
instance Agda.TypeChecking.Primitive.ToTerm GHC.Types.Bool
instance Agda.TypeChecking.Primitive.ToTerm Agda.Syntax.Internal.Term
instance Agda.TypeChecking.Primitive.ToTerm Agda.Syntax.Internal.Type
instance Agda.TypeChecking.Primitive.ToTerm Agda.Syntax.Common.ArgInfo
instance Agda.TypeChecking.Primitive.ToTerm Agda.Syntax.Fixity.Fixity'
instance Agda.TypeChecking.Primitive.ToTerm Agda.Syntax.Fixity.Fixity
instance Agda.TypeChecking.Primitive.ToTerm Agda.Syntax.Fixity.Associativity
instance Agda.TypeChecking.Primitive.ToTerm Agda.Syntax.Fixity.PrecedenceLevel
instance Agda.TypeChecking.Primitive.ToTerm a => Agda.TypeChecking.Primitive.ToTerm [a]
instance Agda.TypeChecking.Primitive.FromTerm GHC.Integer.Type.Integer
instance Agda.TypeChecking.Primitive.FromTerm Agda.TypeChecking.Primitive.Nat
instance Agda.TypeChecking.Primitive.FromTerm Agda.TypeChecking.Primitive.Lvl
instance Agda.TypeChecking.Primitive.FromTerm GHC.Types.Double
instance Agda.TypeChecking.Primitive.FromTerm GHC.Types.Char
instance Agda.TypeChecking.Primitive.FromTerm Agda.Utils.String.Str
instance Agda.TypeChecking.Primitive.FromTerm Agda.Syntax.Abstract.Name.QName
instance Agda.TypeChecking.Primitive.FromTerm Agda.Syntax.Common.MetaId
instance Agda.TypeChecking.Primitive.FromTerm GHC.Types.Bool
instance (Agda.TypeChecking.Primitive.ToTerm a, Agda.TypeChecking.Primitive.FromTerm a) => Agda.TypeChecking.Primitive.FromTerm [a]


-- | Inserts an additional lambda into all coinductive auxiliary
--   definitions (== target type Inf XX). E.g.:
--   
--   f : A -&gt; B -&gt; C -&gt; Inf A f = a b c -&gt; body is converted to
--   f = a b c _ -&gt; body
--   
--   Assumes that flat/sharp are implemented as follows:
--   
--   flat = x -&gt; x sharp = x -&gt; x ()
module Agda.Compiler.Treeless.DelayCoinduction
delayCoinduction :: TTerm -> Type -> TCM TTerm
transform :: CoinductionKit -> TTerm -> Type -> TCM TTerm
outputIsInf :: Maybe CoinductionKit -> Type -> TCM Bool
underLambdas :: Int -> (TTerm -> TTerm) -> TTerm -> TTerm


-- | Converts case matches on literals to if cascades with equality
--   comparisons.
module Agda.Compiler.Treeless.EliminateLiteralPatterns
eliminateLiteralPatterns :: TTerm -> TCM TTerm
data BuiltinKit
BuiltinKit :: Maybe QName -> Maybe QName -> BuiltinKit
[nat] :: BuiltinKit -> Maybe QName
[int] :: BuiltinKit -> Maybe QName
transform :: BuiltinKit -> TTerm -> TTerm

module Agda.Compiler.Treeless.Simplify
simplifyTTerm :: TTerm -> TCM TTerm
instance GHC.Classes.Ord Agda.Compiler.Treeless.Simplify.Atom
instance GHC.Classes.Eq Agda.Compiler.Treeless.Simplify.Atom
instance GHC.Show.Show Agda.Compiler.Treeless.Simplify.Atom

module Agda.Compiler.ToTreeless

-- | Converts compiled clauses to treeless syntax.
--   
--   Note: Do not use any of the concrete names in the returned term for
--   identification purposes! If you wish to do so, first apply the
--   Agda.Compiler.Treeless.NormalizeNames transformation.
toTreeless :: QName -> TCM (Maybe TTerm)
closedTermToTreeless :: Term -> TCM TTerm

module Agda.TypeChecking.ProjectionLike

-- | View for a <tt>Def f (Apply a : es)</tt> where <tt>isProjection
--   f</tt>. Used for projection-like <tt>f</tt>s.
data ProjectionView

-- | A projection or projection-like function, applied to its principal
--   argument
ProjectionView :: QName -> Arg Term -> Elims -> ProjectionView
[projViewProj] :: ProjectionView -> QName
[projViewSelf] :: ProjectionView -> Arg Term
[projViewSpine] :: ProjectionView -> Elims

-- | Just a lone projection-like function, missing its principal argument
--   (from which we could infer the parameters).
LoneProjectionLike :: QName -> ArgInfo -> ProjectionView

-- | Not a projection or projection-like thing.
NoProjection :: Term -> ProjectionView

-- | Semantics of <a>ProjectionView</a>.
unProjView :: ProjectionView -> Term

-- | Top-level <a>ProjectionView</a> (no reduction).
projView :: HasConstInfo m => Term -> m ProjectionView

-- | Reduce away top-level projection like functions. (Also reduces
--   projections, but they should not be there, since Internal is in
--   lambda- and projection-beta-normal form.)
reduceProjectionLike :: Term -> TCM Term

-- | Turn prefix projection-like function application into postfix ones.
--   This does just one layer, such that the top spine contains the
--   projection-like functions as projections. Used in
--   <tt>compareElims</tt> in <tt>TypeChecking.Conversion</tt> and in
--   <a>Agda.TypeChecking.CheckInternal</a>.
--   
--   If the <a>Bool</a> is <a>True</a>, a lone projection like function
--   will be turned into a lambda-abstraction, expecting the principal
--   argument. If the <a>Bool</a> is <a>False</a>, it will be returned
--   unaltered.
--   
--   No precondition. Preserves constructorForm, since it really does only
--   something on (applications of) projection-like functions.
elimView :: Bool -> Term -> TCM Term

-- | Which <tt>Def</tt>types are eligible for the principle argument of a
--   projection-like function?
eligibleForProjectionLike :: QName -> TCM Bool

-- | Turn a definition into a projection if it looks like a projection.
makeProjection :: QName -> TCM ()


-- | Code which replaces pattern matching on record constructors with uses
--   of projection functions.
module Agda.TypeChecking.RecordPatterns

-- | Replaces pattern matching on record constructors with uses of
--   projection functions. Does not remove record constructor patterns
--   which have sub-patterns containing non-record constructor or literal
--   patterns.
translateRecordPatterns :: Clause -> TCM Clause
translateCompiledClauses :: CompiledClauses -> TCM CompiledClauses

-- | Bottom-up procedure to record-pattern-translate split tree.
translateSplitTree :: SplitTree -> TCM SplitTree

-- | Take a record pattern <tt>p</tt> and yield a list of projections
--   corresponding to the pattern variables, from left to right.
--   
--   E.g. for <tt>(x , (y , z))</tt> we return <tt>[ fst, fst . snd, snd .
--   snd ]</tt>.
--   
--   If it is not a record pattern, error <a>ShouldBeRecordPattern</a> is
--   raised.
recordPatternToProjections :: DeBruijnPattern -> TCM [Term -> Term]
instance GHC.Classes.Eq Agda.TypeChecking.RecordPatterns.Kind
instance Control.Monad.State.Class.MonadState Agda.TypeChecking.Monad.Base.TCState Agda.TypeChecking.RecordPatterns.RecPatM
instance Control.Monad.Reader.Class.MonadReader Agda.TypeChecking.Monad.Base.TCEnv Agda.TypeChecking.RecordPatterns.RecPatM
instance Agda.TypeChecking.Monad.Base.MonadTCM Agda.TypeChecking.RecordPatterns.RecPatM
instance Control.Monad.IO.Class.MonadIO Agda.TypeChecking.RecordPatterns.RecPatM
instance GHC.Base.Monad Agda.TypeChecking.RecordPatterns.RecPatM
instance GHC.Base.Applicative Agda.TypeChecking.RecordPatterns.RecPatM
instance GHC.Base.Functor Agda.TypeChecking.RecordPatterns.RecPatM
instance Agda.TypeChecking.RecordPatterns.DropFrom (Agda.TypeChecking.Coverage.SplitTree.SplitTree' c)
instance Agda.TypeChecking.RecordPatterns.DropFrom (c, Agda.TypeChecking.Coverage.SplitTree.SplitTree' c)
instance Agda.TypeChecking.RecordPatterns.DropFrom a => Agda.TypeChecking.RecordPatterns.DropFrom [a]
instance Agda.Utils.Pretty.Pretty (Agda.TypeChecking.RecordPatterns.Kind -> Agda.Syntax.Common.Nat)
instance Agda.TypeChecking.Pretty.PrettyTCM (Agda.TypeChecking.RecordPatterns.Kind -> Agda.Syntax.Common.Nat)
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.RecordPatterns.Change


-- | 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 indicates the relevance we are
--   working under: if this is Irrelevant, then we construct a pattern that
--   never fails to match. The second argument is the number of bound
--   variables (from pattern lambdas).
class PatternFrom a b
patternFrom :: PatternFrom a b => Relevance -> Int -> a -> TCM b

-- | Monad for non-linear matching.
type NLM = ExceptT Blocked_ (StateT NLMState ReduceM)
data NLMState
NLMState :: Sub -> PostponedEquations -> NLMState
[_nlmSub] :: NLMState -> Sub
[_nlmEqs] :: NLMState -> PostponedEquations
nlmSub :: Lens' Sub NLMState
nlmEqs :: Lens' PostponedEquations NLMState
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 <tt>i |-&gt; v</tt> to result of matching.
tellSub :: Relevance -> Int -> Term -> NLM ()
tellEq :: Telescope -> Telescope -> Term -> Term -> NLM ()
type Sub = IntMap (Relevance, 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 => Relevance -> Telescope -> Telescope -> a -> b -> NLM ()
reallyFree :: (Reduce a, Normalise a, Free' a FreeVars) => (Int -> Bool) -> a -> ReduceM (Either Blocked_ (Maybe a))
makeSubstitution :: Telescope -> Sub -> Substitution
checkPostponedEquations :: Substitution -> PostponedEquations -> ReduceM (Maybe Blocked_)
nonLinMatch :: (Match a b) => Telescope -> a -> b -> ReduceM (Either Blocked_ Substitution)

-- | Untyped βη-equality, does not handle things like empty record types.
--   Returns <a>Nothing</a> if the terms are equal, or `Just b` if the
--   terms are not (where b contains information about possible metas
--   blocking the comparison)
equal :: Term -> Term -> ReduceM (Maybe Blocked_)

-- | Normalise the given term but also preserve blocking tags TODO:
--   implement a more efficient version of this.
normaliseB' :: (Reduce t, Normalise t) => t -> ReduceM (Blocked t)

-- | 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 Agda.TypeChecking.Monad.Base.NLPat => Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom (Agda.Syntax.Internal.Elim' a) (Agda.Syntax.Internal.Elim' Agda.TypeChecking.Monad.Base.NLPat)
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 Agda.Syntax.Internal.Type Agda.TypeChecking.Monad.Base.NLPType
instance Agda.TypeChecking.Rewriting.NonLinMatch.PatternFrom Agda.Syntax.Internal.Sort Agda.TypeChecking.Monad.Base.NLPat
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.Utils.Null.Null Agda.TypeChecking.Rewriting.NonLinMatch.NLMState
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 Agda.TypeChecking.Monad.Base.NLPType Agda.Syntax.Internal.Type
instance Agda.TypeChecking.Rewriting.NonLinMatch.Match Agda.TypeChecking.Monad.Base.NLPat Agda.Syntax.Internal.Sort
instance (Agda.TypeChecking.Rewriting.NonLinMatch.Match a b, Agda.TypeChecking.Rewriting.NonLinMatch.RaiseNLP a, Agda.TypeChecking.Substitute.Class.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.Level
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 (GHC.Base.Maybe 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 Agda.TypeChecking.Monad.Base.NLPType
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.Display
checkDisplayPragma :: QName -> [NamedArg Pattern] -> Expr -> TCM ()

module Agda.TypeChecking.Rules.LHS.Implicit

-- | Insert implicit patterns in a problem.
insertImplicitProblem :: Problem -> TCM Problem

-- | Eta-expand implicit pattern if of record type.
expandImplicitPattern :: Type -> NamedArg Pattern -> TCM (NamedArg Pattern)

-- | Try to eta-expand implicit pattern. Returns <a>Nothing</a> unless
--   dealing with a record type that has eta-expansion and a constructor
--   <tt>c</tt>. In this case, it returns <a>Just</a> <tt>c _ _ ... _</tt>
--   (record constructor applied to as many implicit patterns as there are
--   fields).
expandImplicitPattern' :: Type -> NamedArg Pattern -> TCM (Maybe (NamedArg Pattern))
implicitP :: ArgInfo -> NamedArg Pattern

-- | Insert implicit patterns in a list of patterns. Even if
--   <a>DontExpandLast</a>, trailing SIZELT patterns are inserted.
insertImplicitPatterns :: ExpandHidden -> [NamedArg Pattern] -> Telescope -> TCM [NamedArg Pattern]

-- | Insert trailing SizeLt patterns, if any.
insertImplicitSizeLtPatterns :: Type -> TCM [NamedArg Pattern]

-- | Insert implicit patterns in a list of patterns. Even if
--   <a>DontExpandLast</a>, trailing SIZELT patterns are inserted.
insertImplicitPatternsT :: ExpandHidden -> [NamedArg Pattern] -> Type -> TCM [NamedArg Pattern]

module Agda.TypeChecking.Rules.LHS.AsPatterns
recoverAsPatterns :: Telescope -> Type -> Term -> [NamedArg Pattern] -> [NamedArg DeBruijnPattern] -> TCM [AsBinding]
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Rules.LHS.AsPatterns.ElimType

module Agda.TypeChecking.Rules.LHS.Instantiate

-- | Instantiate a telescope with a substitution. Might reorder the
--   telescope. <tt>instantiateTel (Γ : Tel)(σ : Γ --&gt; Γ) = Γσ~</tt>
--   Monadic only for debugging purposes.
instantiateTel :: Substitution -> Telescope -> TCM (Telescope, Permutation, Substitution, [Dom Type])

-- | Produce a nice error message when splitting failed
nothingToSplitError :: Problem -> TCM a

module Agda.TypeChecking.Rules.LHS.ProblemRest

-- | Rename the variables in a telescope using the names from a given
--   pattern
useNamesFromPattern :: [NamedArg Pattern] -> Telescope -> Telescope
useOriginFrom :: (LensOrigin a, LensOrigin b) => [a] -> [b] -> [a]

-- | Are there any untyped user patterns left?
noProblemRest :: Problem -> Bool

-- | Construct an initial <tt>split</tt> <a>Problem</a> from user patterns.
--   Example: @
--   
--   Case : {A : Set} → Maybe A → Set → Set → Set Case nothing B C = B Case
--   (just _) B C = C
--   
--   sample : {A : Set} (m : Maybe A) → Case m Bool (Maybe A → Bool) sample
--   (just a) (just b) = true sample (just a) nothing = false sample
--   nothing = true <tt> The problem generated for the first clause of
--   </tt>sample<tt> with patterns </tt>just a, just b<tt> would be: </tt>
--   problemInPat = ["_", "just a"] problemOutPat = [<a>A</a>, "m"]
--   problemTel = [A : Set, m : Maybe A] problemRest = restPats = ["just
--   b"] restType = "Case m Bool (Maybe A -&gt; Bool)" @
problemFromPats :: [NamedArg Pattern] -> Type -> TCM Problem

-- | Try to move patterns from the problem rest into the problem. Possible
--   if type of problem rest has been updated to a function type.
updateProblemRest_ :: Problem -> TCM (Nat, Problem)
updateProblemRest :: LHSState -> TCM LHSState

module Agda.TypeChecking.SizedTypes

-- | Check whether a type is either not a SIZELT or a SIZELT that is
--   non-empty.
checkSizeLtSat :: Term -> TCM ()

-- | Precondition: Term is reduced and not blocked. Throws a
--   <a>patternViolation</a> if undecided
checkSizeNeverZero :: Term -> TCM Bool

-- | Checks that a size variable is ensured to be <tt>&gt; 0</tt>. E.g.
--   variable <tt>i</tt> cannot be zero in context <tt>(i : Size) (j :
--   Size&lt; ↑ ↑ i) (k : Size&lt; j) (k' : Size&lt; k)</tt>. Throws a
--   <a>patternViolation</a> if undecided.
checkSizeVarNeverZero :: Int -> TCM Bool

-- | Check whether a variable in the context is bounded by a size
--   expression. If <tt>x : Size&lt; a</tt>, then <tt>a</tt> is returned.
isBounded :: MonadTCM tcm => Nat -> tcm BoundedSize

-- | Whenever we create a bounded size meta, add a constraint expressing
--   the bound. In <tt>boundedSizeMetaHook v tel a</tt>, <tt>tel</tt>
--   includes the current context.
boundedSizeMetaHook :: Term -> Telescope -> Type -> TCM ()

-- | <tt>trySizeUniv cmp t m n x els1 y els2</tt> is called as a last
--   resort when conversion checking <tt>m <tt>cmp</tt> n : t</tt> failed
--   for definitions <tt>m = x els1</tt> and <tt>n = y els2</tt>, where the
--   heads <tt>x</tt> and <tt>y</tt> are not equal.
--   
--   <tt>trySizeUniv</tt> accounts for subtyping between SIZELT and SIZE,
--   like <tt>Size&lt; i =&lt; Size</tt>.
--   
--   If it does not succeed it reports failure of conversion check.
trySizeUniv :: Comparison -> Type -> Term -> Term -> QName -> Elims -> QName -> Elims -> TCM ()

-- | Compute the deep size view of a term. Precondition: sized types are
--   enabled.
deepSizeView :: Term -> TCM DeepSizeView
sizeMaxView :: Term -> TCM SizeMaxView

-- | Compare two sizes.
compareSizes :: Comparison -> Term -> Term -> TCM ()

-- | Compare two sizes in max view.
compareMaxViews :: Comparison -> SizeMaxView -> SizeMaxView -> TCM ()

-- | <tt>compareBelowMax u vs</tt> checks <tt>u &lt;= max vs</tt>.
--   Precondition: <tt>size vs &gt;= 2</tt>
compareBelowMax :: DeepSizeView -> SizeMaxView -> TCM ()
compareSizeViews :: Comparison -> DeepSizeView -> DeepSizeView -> TCM ()

-- | Checked whether a size constraint is trivial (like <tt>X &lt;=
--   X+1</tt>).
trivial :: Term -> Term -> TCM Bool

-- | Test whether a problem consists only of size constraints.
isSizeProblem :: ProblemId -> TCM Bool

-- | Test is a constraint speaks about sizes.
isSizeConstraint :: Closure Constraint -> TCM Bool

-- | Find the size constraints.
getSizeConstraints :: TCM [Closure Constraint]

-- | Return a list of size metas and their context.
getSizeMetas :: Bool -> TCM [(MetaId, Type, Telescope)]

-- | Atomic size expressions.
data OldSizeExpr

-- | A size meta applied to de Bruijn indices.
SizeMeta :: MetaId -> [Int] -> OldSizeExpr

-- | A de Bruijn index.
Rigid :: Int -> OldSizeExpr

-- | Size constraints we can solve.
data OldSizeConstraint

-- | <tt>Leq a +n b</tt> represents <tt>a =&lt; b + n</tt>. <tt>Leq a -n
--   b</tt> represents <tt>a + n =&lt; b</tt>.
Leq :: OldSizeExpr -> Int -> OldSizeExpr -> OldSizeConstraint

-- | Compute a set of size constraints that all live in the same context
--   from constraints over terms of type size that may live in different
--   contexts.
--   
--   cf. <a>simplifyLevelConstraint</a>
oldComputeSizeConstraints :: [Closure Constraint] -> TCM [OldSizeConstraint]

-- | Turn a constraint over de Bruijn indices into a size constraint.
oldComputeSizeConstraint :: Constraint -> TCM (Maybe OldSizeConstraint)

-- | Turn a term with de Bruijn indices into a size expression with offset.
--   
--   Throws a <a>patternViolation</a> if the term isn't a proper size
--   expression.
oldSizeExpr :: Term -> TCM (OldSizeExpr, Int)

-- | Compute list of size metavariables with their arguments appearing in a
--   constraint.
flexibleVariables :: OldSizeConstraint -> [(MetaId, [Int])]

-- | Convert size constraint into form where each meta is applied to
--   indices <tt>0,1,..,n-1</tt> where <tt>n</tt> is the arity of that
--   meta.
--   
--   <tt>X[σ] &lt;= t</tt> becomes <tt>X[id] &lt;= t[σ^-1]</tt>
--   
--   <tt>X[σ] ≤ Y[τ]</tt> becomes <tt>X[id] ≤ Y[τ[σ^-1]]</tt> or
--   <tt>X[σ[τ^1]] ≤ Y[id]</tt> whichever is defined. If none is defined,
--   we give up.
oldCanonicalizeSizeConstraint :: OldSizeConstraint -> Maybe OldSizeConstraint

-- | Main function. Uses the old solver for size constraints using
--   <a>Agda.Utils.Warshall</a>. This solver does not smartly use size
--   hypotheses <tt>j : Size&lt; i</tt>. It only checks that its computed
--   solution is compatible
oldSolveSizeConstraints :: TCM ()

-- | Old solver for size constraints using <a>Agda.Utils.Warshall</a>. This
--   solver does not smartly use size hypotheses <tt>j : Size&lt; i</tt>.
oldSolver :: [(MetaId, Int)] -> [OldSizeConstraint] -> TCM Bool
instance GHC.Classes.Eq Agda.TypeChecking.SizedTypes.OldSizeExpr
instance GHC.Show.Show Agda.TypeChecking.SizedTypes.OldSizeExpr
instance GHC.Show.Show Agda.TypeChecking.SizedTypes.OldSizeConstraint

module Agda.Termination.TermCheck

-- | Entry point: Termination check a single declaration.
--   
--   Precondition: <a>envMutualBlock</a> must be set correctly.
termDecl :: Declaration -> TCM Result

-- | Entry point: Termination check the current mutual block.
termMutual :: [QName] -> TCM Result

-- | The result of termination checking a module. Must be a <a>Monoid</a>
--   and have <a>Singleton</a>.
type Result = [TerminationError]

-- | Patterns with variables as de Bruijn indices.
type DeBruijnPat = DeBruijnPat' Int
instance Agda.Termination.TermCheck.ExtractCalls Agda.Syntax.Internal.Level
instance Agda.Termination.TermCheck.ExtractCalls a => Agda.Termination.TermCheck.ExtractCalls (Agda.Syntax.Internal.Abs a)
instance Agda.Termination.TermCheck.ExtractCalls a => Agda.Termination.TermCheck.ExtractCalls (Agda.Syntax.Common.Arg a)
instance Agda.Termination.TermCheck.ExtractCalls a => Agda.Termination.TermCheck.ExtractCalls (Agda.Syntax.Common.Dom a)
instance Agda.Termination.TermCheck.ExtractCalls a => Agda.Termination.TermCheck.ExtractCalls (Agda.Syntax.Internal.Elim' a)
instance Agda.Termination.TermCheck.ExtractCalls a => Agda.Termination.TermCheck.ExtractCalls [a]
instance (Agda.Termination.TermCheck.ExtractCalls a, Agda.Termination.TermCheck.ExtractCalls b) => Agda.Termination.TermCheck.ExtractCalls (a, b)
instance Agda.Termination.TermCheck.ExtractCalls Agda.Syntax.Internal.Sort
instance Agda.Termination.TermCheck.ExtractCalls Agda.Syntax.Internal.Type
instance Agda.Termination.TermCheck.ExtractCalls Agda.Syntax.Internal.Term
instance Agda.Termination.TermCheck.ExtractCalls Agda.Syntax.Internal.PlusLevel
instance Agda.Termination.TermCheck.ExtractCalls Agda.Syntax.Internal.LevelAtom
instance Agda.Termination.TermCheck.StripAllProjections a => Agda.Termination.TermCheck.StripAllProjections (Agda.Syntax.Common.Arg a)
instance Agda.Termination.TermCheck.StripAllProjections Agda.Syntax.Internal.Elims
instance Agda.Termination.TermCheck.StripAllProjections Agda.Syntax.Internal.Args
instance Agda.Termination.TermCheck.StripAllProjections Agda.Syntax.Internal.Term

module Agda.TypeChecking.Constraints

-- | Catches pattern violation errors and adds a constraint.
catchConstraint :: Constraint -> TCM () -> TCM ()
addConstraint :: Constraint -> TCM ()

-- | Don't allow the argument to produce any constraints.
noConstraints :: TCM a -> TCM a

-- | Create a fresh problem for the given action.
newProblem :: TCM a -> TCM (ProblemId, a)
newProblem_ :: TCM () -> TCM ProblemId
ifNoConstraints :: TCM a -> (a -> TCM b) -> (ProblemId -> a -> TCM b) -> TCM b
ifNoConstraints_ :: TCM () -> TCM a -> (ProblemId -> TCM a) -> TCM a

-- | <tt>guardConstraint c blocker</tt> tries to solve <tt>blocker</tt>
--   first. If successful without constraints, it moves on to solve
--   <tt>c</tt>, otherwise it adds a <tt>Guarded c cs</tt> constraint to
--   the <tt>blocker</tt>-generated constraints <tt>cs</tt>.
guardConstraint :: Constraint -> TCM () -> TCM ()
whenConstraints :: TCM () -> TCM () -> TCM ()

-- | Wake up the constraints depending on the given meta.
wakeupConstraints :: MetaId -> TCM ()

-- | Wake up all constraints.
wakeupConstraints_ :: TCM ()
solveAwakeConstraints :: TCM ()
solveAwakeConstraints' :: Bool -> TCM ()
solveConstraint :: Constraint -> TCM ()
solveConstraint_ :: Constraint -> TCM ()
checkTypeCheckingProblem :: TypeCheckingProblem -> TCM Term
debugConstraints :: TCM ()

module Agda.TypeChecking.Injectivity
headSymbol :: Term -> TCM (Maybe TermHead)
checkInjectivity :: QName -> [Clause] -> TCM FunctionInverse

-- | Argument should be in weak head normal form.
functionInverse :: Term -> TCM InvView
data InvView
Inv :: QName -> [Elim] -> (Map TermHead Clause) -> InvView
NoInv :: InvView
data MaybeAbort
Abort :: MaybeAbort
KeepGoing :: MaybeAbort
useInjectivity :: Comparison -> Type -> Term -> Term -> TCM ()

module Agda.TypeChecking.MetaVars

-- | Find position of a value in a list. Used to change metavar argument
--   indices during assignment.
--   
--   <tt>reverse</tt> is necessary because we are directly abstracting over
--   the list.
findIdx :: Eq a => [a] -> a -> Maybe Int

-- | Check whether a meta variable is a place holder for a blocked term.
isBlockedTerm :: MetaId -> TCM Bool
isEtaExpandable :: [MetaKind] -> MetaId -> TCM Bool

-- | Performing the meta variable assignment.
--   
--   The instantiation should not be an <a>InstV</a> and the <a>MetaId</a>
--   should point to something <a>Open</a> or a <a>BlockedConst</a>.
--   Further, the meta variable may not be <a>Frozen</a>.
assignTerm :: MetaId -> [Arg ArgName] -> Term -> TCM ()

-- | Skip frozen check. Used for eta expanding frozen metas.
assignTerm' :: MetaId -> [Arg ArgName] -> Term -> TCM ()

-- | Create a sort meta that cannot be instantiated with <a>Inf</a> (Setω).
newSortMetaBelowInf :: TCM Sort

-- | Create a sort meta that may be instantiated with <a>Inf</a> (Setω).
newSortMeta :: TCM Sort
newSortMeta' :: (Type -> Judgement ()) -> TCM Sort

-- | Create a sort meta that may be instantiated with <a>Inf</a> (Setω).
newSortMetaCtx :: Args -> TCM Sort
newSortMetaCtx' :: (Type -> Judgement ()) -> Args -> TCM Sort
newTypeMeta :: Sort -> TCM Type
newTypeMeta_ :: TCM Type

-- | <tt>newIFSMeta s t cands</tt> creates a new "implicit from scope"
--   metavariable of type the output type of <tt>t</tt> with name
--   suggestion <tt>s</tt>. If <tt>t</tt> is a function type, then insert
--   enough lambdas in front of it.
newIFSMeta :: MetaNameSuggestion -> Type -> TCM (MetaId, Term)
newIFSMetaCtx :: MetaNameSuggestion -> Type -> Args -> TCM (MetaId, Term)

-- | Create a new value meta with specific dependencies, possibly
--   η-expanding in the process.
newNamedValueMeta :: RunMetaOccursCheck -> MetaNameSuggestion -> Type -> TCM (MetaId, Term)

-- | Create a new value meta with specific dependencies without
--   η-expanding.
newNamedValueMeta' :: RunMetaOccursCheck -> MetaNameSuggestion -> Type -> TCM (MetaId, Term)

-- | Create a new metavariable, possibly η-expanding in the process.
newValueMeta :: RunMetaOccursCheck -> Type -> TCM (MetaId, Term)
newValueMetaCtx :: RunMetaOccursCheck -> Type -> Telescope -> Permutation -> Args -> TCM (MetaId, Term)

-- | Create a new value meta without η-expanding.
newValueMeta' :: RunMetaOccursCheck -> Type -> TCM (MetaId, Term)

-- | Create a new value meta with specific dependencies.
newValueMetaCtx' :: RunMetaOccursCheck -> Type -> Telescope -> Permutation -> Args -> TCM (MetaId, Term)
newTelMeta :: Telescope -> TCM Args
type Condition = Dom Type -> Abs Type -> Bool
trueCondition :: Condition
newArgsMeta :: Type -> TCM Args
newArgsMeta' :: Condition -> Type -> TCM Args
newArgsMetaCtx :: Type -> Telescope -> Permutation -> Args -> TCM Args
newArgsMetaCtx' :: Condition -> Type -> Telescope -> Permutation -> Args -> TCM Args

-- | Create a metavariable of record type. This is actually one
--   metavariable for each field.
newRecordMeta :: QName -> Args -> TCM Term
newRecordMetaCtx :: QName -> Args -> Telescope -> Permutation -> Args -> TCM Term
newQuestionMark :: InteractionId -> Type -> TCM (MetaId, Term)
newQuestionMark' :: (Type -> TCM (MetaId, Term)) -> InteractionId -> Type -> TCM (MetaId, Term)

-- | Construct a blocked constant if there are constraints.
blockTerm :: Type -> TCM Term -> TCM Term
blockTermOnProblem :: Type -> Term -> ProblemId -> TCM Term
blockTypeOnProblem :: Type -> ProblemId -> TCM Type

-- | <tt>unblockedTester t</tt> returns <tt>False</tt> if <tt>t</tt> is a
--   meta or a blocked term.
--   
--   Auxiliary function to create a postponed type checking problem.
unblockedTester :: Type -> TCM Bool

-- | Create a postponed type checking problem <tt>e : t</tt> that waits for
--   type <tt>t</tt> to unblock (become instantiated or its constraints
--   resolved).
postponeTypeCheckingProblem_ :: TypeCheckingProblem -> TCM Term

-- | Create a postponed type checking problem <tt>e : t</tt> that waits for
--   conditon <tt>unblock</tt>. A new meta is created in the current
--   context that has as instantiation the postponed type checking problem.
--   An <a>UnBlock</a> constraint is added for this meta, which links to
--   this meta.
postponeTypeCheckingProblem :: TypeCheckingProblem -> TCM Bool -> TCM Term

-- | Type of the term that is produced by solving the
--   <a>TypeCheckingProblem</a>.
problemType :: TypeCheckingProblem -> TCM Type

-- | Eta expand metavariables listening on the current meta.
etaExpandListeners :: MetaId -> TCM ()

-- | Wake up a meta listener and let it do its thing
wakeupListener :: Listener -> TCM ()

-- | Do safe eta-expansions for meta (<tt>SingletonRecords,Levels</tt>).
etaExpandMetaSafe :: MetaId -> TCM ()

-- | Various kinds of metavariables.
data MetaKind

-- | Meta variables of record type.
Records :: MetaKind

-- | Meta variables of "hereditarily singleton" record type.
SingletonRecords :: MetaKind

-- | Meta variables of level type, if type-in-type is activated.
Levels :: MetaKind

-- | All possible metavariable kinds.
allMetaKinds :: [MetaKind]

-- | Eta expand a metavariable, if it is of the specified kind. Don't do
--   anything if the metavariable is a blocked term.
etaExpandMeta :: [MetaKind] -> MetaId -> TCM ()

-- | Eta expand blocking metavariables of record type, and reduce the
--   blocked thing.
etaExpandBlocked :: Reduce t => Blocked t -> TCM (Blocked t)

-- | Assign to an open metavar which may not be frozen. First check that
--   metavar args are in pattern fragment. Then do extended occurs check on
--   given thing.
--   
--   Assignment is aborted by throwing a <tt>PatternErr</tt> via a call to
--   <tt>patternViolation</tt>. This error is caught by
--   <tt>catchConstraint</tt> during equality checking
--   (<tt>compareAtom</tt>) and leads to restoration of the original
--   constraints.
assignV :: CompareDirection -> MetaId -> Args -> Term -> TCM ()
assignWrapper :: CompareDirection -> MetaId -> Elims -> Term -> TCM () -> TCM ()

-- | Miller pattern unification:
--   
--   <tt>assign x vs v</tt> solves problem <tt>x vs = v</tt> for meta
--   <tt>x</tt> if <tt>vs</tt> are distinct variables (linearity check) and
--   <tt>v</tt> depends only on these variables and does not contain
--   <tt>x</tt> itself (occurs check).
--   
--   This is the basic story, but we have added some features:
--   
--   <ol>
--   <li>Pruning.</li>
--   <li>Benign cases of non-linearity.</li>
--   <li><tt>vs</tt> may contain record patterns.</li>
--   </ol>
--   
--   For a reference to some of these extensions, read Andreas Abel and
--   Brigitte Pientka's TLCA 2011 paper.
assign :: CompareDirection -> MetaId -> Args -> Term -> TCM ()

-- | <tt>assignMeta m x t ids u</tt> solves <tt>x ids = u</tt> for meta
--   <tt>x</tt> of type <tt>t</tt>, where term <tt>u</tt> lives in a
--   context of length <tt>m</tt>. Precondition: <tt>ids</tt> is linear.
assignMeta :: Int -> MetaId -> Type -> [Int] -> Term -> TCM ()

-- | <tt>assignMeta' m x t ids u</tt> solves <tt>x = [ids]u</tt> for meta
--   <tt>x</tt> of type <tt>t</tt>, where term <tt>u</tt> lives in a
--   context of length <tt>m</tt>, and <tt>ids</tt> is a partial
--   substitution.
assignMeta' :: Int -> MetaId -> Type -> Int -> SubstCand -> Term -> TCM ()

-- | Turn the assignment problem <tt>_X args &lt;= SizeLt u</tt> into
--   <tt>_X args = SizeLt (_Y args)</tt> and constraint <tt>_Y args &lt;=
--   u</tt>.
subtypingForSizeLt :: CompareDirection -> MetaId -> MetaVariable -> Type -> Args -> Term -> (Term -> TCM ()) -> TCM ()

-- | Eta-expand bound variables like <tt>z</tt> in <tt>X (fst z)</tt>.
expandProjectedVars :: (Normalise a, TermLike a, Show a, PrettyTCM a, NoProjectedVar a, Subst Term a, PrettyTCM b, Subst Term b) => a -> b -> (a -> b -> TCM c) -> TCM c

-- | Eta-expand a de Bruijn index of record type in context and passed
--   term(s).
etaExpandProjectedVar :: (PrettyTCM a, Subst Term a) => Int -> a -> TCM c -> (a -> TCM c) -> TCM c

-- | Check whether one of the meta args is a projected var.
class NoProjectedVar a
noProjectedVar :: NoProjectedVar a => a -> Either ProjVarExc ()
data ProjVarExc
ProjVarExc :: Int -> [(ProjOrigin, QName)] -> ProjVarExc
type FVs = VarSet
type SubstCand = [(Int, Term)]  a possibly non-deterministic substitution

-- | Turn non-det substitution into proper substitution, if possible.
--   Otherwise, raise the error.
checkLinearity :: SubstCand -> ExceptT () TCM SubstCand
type Res = [(Arg Nat, Term)]

-- | Exceptions raised when substitution cannot be inverted.
data InvertExcept

-- | Cannot recover.
CantInvert :: InvertExcept

-- | A potentially neutral arg: can't invert, but can try pruning.
NeutralArg :: InvertExcept

-- | Try to eta-expand var to remove projs.
ProjectedVar :: Int -> [(ProjOrigin, QName)] -> InvertExcept

-- | Check that arguments <tt>args</tt> to a metavar are in pattern
--   fragment. Assumes all arguments already in whnf and eta-reduced.
--   Parameters are represented as <tt>Var</tt>s so <tt>checkArgs</tt>
--   really checks that all args are <tt>Var</tt>s and returns the
--   "substitution" to be applied to the rhs of the equation to solve. (If
--   <tt>args</tt> is considered a substitution, its inverse is returned.)
--   
--   The returned list might not be ordered. Linearity, i.e., whether the
--   substitution is deterministic, has to be checked separately.
inverseSubst :: Args -> ExceptT InvertExcept TCM SubstCand

-- | Turn open metas into postulates.
--   
--   Preconditions:
--   
--   <ol>
--   <li>We are <a>inTopContext</a>.</li>
--   <li><a>envCurrentModule</a> is set to the top-level module.</li>
--   </ol>
openMetasToPostulates :: TCM ()
instance GHC.Show.Show Agda.TypeChecking.MetaVars.MetaKind
instance GHC.Enum.Bounded Agda.TypeChecking.MetaVars.MetaKind
instance GHC.Enum.Enum Agda.TypeChecking.MetaVars.MetaKind
instance GHC.Classes.Eq Agda.TypeChecking.MetaVars.MetaKind
instance Agda.TypeChecking.MetaVars.NoProjectedVar Agda.Syntax.Internal.Term
instance Agda.TypeChecking.MetaVars.NoProjectedVar a => Agda.TypeChecking.MetaVars.NoProjectedVar (Agda.Syntax.Common.Arg a)
instance Agda.TypeChecking.MetaVars.NoProjectedVar a => Agda.TypeChecking.MetaVars.NoProjectedVar [a]


-- | Generates data used for precise syntax highlighting.
module Agda.Interaction.Highlighting.Generate

-- | Highlighting levels.
data Level

-- | Full highlighting. Should only be used after typechecking has
--   completed successfully.
Full :: Level

-- | Highlighting without disambiguation of overloaded constructors.
Partial :: Level

-- | Generate syntax highlighting information for the given declaration,
--   and (if appropriate) print it. If the <a>HighlightingLevel</a> is
--   <tt><a>Full</a></tt>, then the state is additionally updated with the
--   new highlighting info (in case of a conflict new info takes precedence
--   over old info).
--   
--   The procedure makes use of some of the token highlighting info in
--   <a>stTokens</a> (that corresponding to the interval covered by the
--   declaration). If the <a>HighlightingLevel</a> is <tt><a>Full</a></tt>,
--   then this token highlighting info is additionally removed from
--   <a>stTokens</a>.
generateAndPrintSyntaxInfo :: Declaration -> Level -> TCM ()

-- | Generate and return the syntax highlighting information for the tokens
--   in the given file.
generateTokenInfo :: AbsolutePath -> TCM CompressedFile

-- | Same as <a>generateTokenInfo</a> but takes a string instead of a
--   filename.
generateTokenInfoFromString :: Range -> String -> TCM CompressedFile
printSyntaxInfo :: Range -> TCM ()

-- | Prints syntax highlighting info for an error.
printErrorInfo :: TCErr -> TCM ()

-- | Generate highlighting for error. Does something special for
--   termination errors.
errorHighlighting :: TCErr -> TCM File

-- | Generates and prints syntax highlighting information for unsolved
--   meta-variables and certain unsolved constraints.
printUnsolvedInfo :: TCM ()

-- | Lispify and print the given highlighting information.
printHighlightingInfo :: MonadTCM tcm => HighlightingInfo -> tcm ()

-- | <tt>highlightAsTypeChecked rPre r m</tt> runs <tt>m</tt> and returns
--   its result. Additionally, some code may be highlighted:
--   
--   <ul>
--   <li>If <tt>r</tt> is non-empty and not a sub-range of <tt>rPre</tt>
--   (after <a>continuousPerLine</a> has been applied to both): <tt>r</tt>
--   is highlighted as being type-checked while <tt>m</tt> is running (this
--   highlighting is removed if <tt>m</tt> completes
--   <i>successfully</i>).</li>
--   <li>Otherwise: Highlighting is removed for <tt>rPre - r</tt> before
--   <tt>m</tt> runs, and if <tt>m</tt> completes successfully, then
--   <tt>rPre - r</tt> is highlighted as being type-checked.</li>
--   </ul>
highlightAsTypeChecked :: MonadTCM tcm => Range -> Range -> tcm a -> tcm a

-- | Generates syntax highlighting information for unsolved meta variables.
computeUnsolvedMetaWarnings :: TCM File

-- | Generates syntax highlighting information for unsolved constraints
--   that are not connected to a meta variable.
computeUnsolvedConstraints :: TCM File

-- | Remember a name disambiguation (during type checking). To be used
--   later during syntax highlighting.
storeDisambiguatedName :: QName -> TCM ()

module Agda.TypeChecking.Conversion

-- | Try whether a computation runs without errors or new constraints (may
--   create new metas, though). Restores state upon failure.
tryConversion :: TCM () -> TCM Bool

-- | Try whether a computation runs without errors or new constraints (may
--   create new metas, though). Return <a>Just</a> the result upon success.
--   Return <a>Nothing</a> and restore state upon failure.
tryConversion' :: TCM a -> TCM (Maybe a)

-- | Check if to lists of arguments are the same (and all variables).
--   Precondition: the lists have the same length.
sameVars :: Elims -> Elims -> Bool

-- | <tt>intersectVars us vs</tt> checks whether all relevant elements in
--   <tt>us</tt> and <tt>vs</tt> are variables, and if yes, returns a prune
--   list which says <tt>True</tt> for arguments which are different and
--   can be pruned.
intersectVars :: Elims -> Elims -> Maybe [Bool]
equalTerm :: Type -> Term -> Term -> TCM ()
equalAtom :: Type -> Term -> Term -> TCM ()
equalType :: Type -> Type -> TCM ()

-- | Ignore errors in irrelevant context.
convError :: TypeError -> TCM ()

-- | Type directed equality on values.
compareTerm :: Comparison -> Type -> Term -> Term -> TCM ()
unifyPointers :: Comparison -> Term -> Term -> TCM () -> TCM ()

-- | Try to assign meta. If meta is projected, try to eta-expand and run
--   conversion check again.
assignE :: CompareDirection -> MetaId -> Elims -> Term -> (Term -> Term -> TCM ()) -> TCM ()
compareTermDir :: CompareDirection -> Type -> Term -> Term -> TCM ()
compareTerm' :: Comparison -> Type -> Term -> Term -> TCM ()

-- | <tt>compareTel t1 t2 cmp tel1 tel1</tt> checks whether pointwise
--   <tt>tel1 `cmp` tel2</tt> and complains that <tt>t2 `cmp` t1</tt>
--   failed if not.
compareTel :: Type -> Type -> Comparison -> Telescope -> Telescope -> TCM ()

-- | Raise <a>UnequalTerms</a> if there is no hope that by meta solving and
--   subsequent eta-contraction these terms could become equal.
--   Precondition: the terms are in reduced form (with no top-level
--   pointer) and failed to be equal in the <a>compareAtom</a> check.
--   
--   By eta-contraction, a lambda or a record constructor term can become
--   anything.
etaInequal :: Comparison -> Type -> Term -> Term -> TCM ()
compareAtomDir :: CompareDirection -> Type -> Term -> Term -> TCM ()

-- | Syntax directed equality on atomic values
compareAtom :: Comparison -> Type -> Term -> Term -> TCM ()

-- | Check whether <tt>a1 <tt>cmp</tt> a2</tt> and continue in context
--   extended by <tt>a1</tt>.
compareDom :: Free c => Comparison -> Dom Type -> Dom Type -> Abs b -> Abs c -> TCM () -> TCM () -> TCM () -> TCM ()
compareRelevance :: Comparison -> Relevance -> Relevance -> Bool

-- | <tt>compareElims pols a v els1 els2</tt> performs type-directed
--   equality on eliminator spines. <tt>t</tt> is the type of the head
--   <tt>v</tt>.
compareElims :: [Polarity] -> Type -> Term -> [Elim] -> [Elim] -> TCM ()

-- | <a>Compare</a> two terms in irrelevant position. This always succeeds.
--   However, we can dig for solutions of irrelevant metas in the terms we
--   compare. (Certainly not the systematic solution, that'd be proof
--   search...)
compareIrrelevant :: Type -> Term -> Term -> TCM ()
compareWithPol :: Polarity -> (Comparison -> a -> a -> TCM ()) -> a -> a -> TCM ()
polFromCmp :: Comparison -> Polarity

-- | Type-directed equality on argument lists
compareArgs :: [Polarity] -> Type -> Term -> Args -> Args -> TCM ()

-- | Equality on Types
compareType :: Comparison -> Type -> Type -> TCM ()
leqType :: Type -> Type -> TCM ()

-- | <tt>coerce v a b</tt> coerces <tt>v : a</tt> to type <tt>b</tt>,
--   returning a <tt>v' : b</tt> with maybe extra hidden applications or
--   hidden abstractions.
--   
--   In principle, this function can host coercive subtyping, but currently
--   it only tries to fix problems with hidden function types.
coerce :: Term -> Type -> Type -> TCM Term

-- | Account for situations like <tt>k : (Size&lt; j) &lt;= (Size&lt; k +
--   1)</tt>
--   
--   Actually, the semantics is <tt>(Size&lt;= k) ∩ (Size&lt; j) ⊆ rhs</tt>
--   which gives a disjunctive constraint. Mmmh, looks like stuff TODO.
--   
--   For now, we do a cheap heuristics.
coerceSize :: (Type -> Type -> TCM ()) -> Term -> Type -> Type -> TCM Term
compareLevel :: Comparison -> Level -> Level -> TCM ()
compareSort :: Comparison -> Sort -> Sort -> TCM ()

-- | Check that the first sort is less or equal to the second.
--   
--   We can put <tt>SizeUniv</tt> below <tt>Inf</tt>, but otherwise, it is
--   unrelated to the other universes.
leqSort :: Sort -> Sort -> TCM ()
leqLevel :: Level -> Level -> TCM ()
equalLevel :: Level -> Level -> TCM ()

-- | Precondition: levels are <a>normalise</a>d.
equalLevel' :: Level -> Level -> TCM ()

-- | Check that the first sort equal to the second.
equalSort :: Sort -> Sort -> TCM ()
bothAbsurd :: QName -> QName -> TCM Bool


-- | A bidirectional type checker for internal syntax.
--   
--   Performs checking on unreduced terms. With the exception that
--   projection-like function applications have to be reduced since they
--   break bidirectionality.
module Agda.TypeChecking.CheckInternal

-- | Entry point for e.g. checking WithFunctionType.
checkType :: Type -> TCM ()

-- | Entry point for term checking.
checkInternal :: Term -> Type -> TCM ()
checkInternal' :: Action -> Term -> Type -> TCM Term
defaultAction :: Action
data Action
Action :: (Type -> Term -> TCM Term) -> (Type -> Term -> TCM Term) -> Action
[preAction] :: Action -> Type -> Term -> TCM Term
[postAction] :: Action -> Type -> Term -> TCM Term

-- | Infer type of a neutral term.
infer :: Term -> TCM Type


-- | Functions for abstracting terms over other terms.
module Agda.TypeChecking.Abstract
typeOf :: Type -> Type

-- | <tt>abstractType a v b[v] = b</tt> where <tt>a : v</tt>.
abstractType :: Type -> Term -> Type -> TCM Type

-- | <pre>
--   piAbstractTerm v a b[v] = (w : a) -&gt; b[w]
--   </pre>
piAbstractTerm :: Term -> Type -> Type -> TCM Type

-- | <pre>
--   piAbstract (v, a) b[v] = (w : a) -&gt; b[w]
--   </pre>
--   
--   For <tt>rewrite</tt>, it does something special:
--   
--   <pre>
--   piAbstract (prf, Eq a v v') b[v,prf] = (w : a) (w' : Eq a w v') -&gt; b[w,w']
--   </pre>
piAbstract :: (Term, EqualityView) -> Type -> TCM Type

-- | <tt>isPrefixOf u v = Just es</tt> if <tt>v == u <a>applyE</a> es</tt>.
class IsPrefixOf a
isPrefixOf :: IsPrefixOf a => a -> a -> Maybe Elims
abstractTerm :: Type -> Term -> Type -> Term -> TCM Term
class AbsTerm a

-- | <pre>
--   subst u . absTerm u == id
--   </pre>
absTerm :: AbsTerm a => Term -> a -> a

-- | This swaps <tt>var 0</tt> and <tt>var 1</tt>.
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.Class.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 <tt>x</tt> is forced in <tt>sing</tt> and <tt>n</tt> is
--   forced in <tt>zero</tt> and <tt>suc</tt>:
--   
--   <pre>
--   data Sing {a}{A : Set a} : A -&gt; Set where
--     sing : (x : A) -&gt; Sing x
--   
--   data Fin : Nat -&gt; Set where
--     zero : (n : Nat) -&gt; Fin (suc n)
--     suc  : (n : Nat) (i : Fin n) -&gt; Fin (suc n)
--   </pre>
--   
--   At runtime, forced constructor arguments may be erased as they can be
--   recovered from dot patterns. In the epic backend, <tt> unsing : {A :
--   Set} (x : A) -&gt; Sing x -&gt; A unsing .x (sing x) = x </tt> becomes
--   <tt> unsing x sing = x </tt> and <tt> proj : (n : Nat) (i : Fin n)
--   -&gt; Nat proj .(suc n) (zero n) = n proj .(suc n) (suc n i) = n </tt>
--   becomes <tt> proj (suc n) zero = n proj (suc n) (suc i) = n </tt>
--   
--   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 <tt>Skip</tt> 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 <tt>Γ → D vs</tt>
--   and the <tt>vs</tt> 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.

-- | <tt>force s xs t</tt> marks the domains <tt>xs</tt> in function type
--   <tt>t</tt> as forced. Domains bigger than <tt>s</tt> are marked as
--   <tt><a>Forced</a> <a>Big</a></tt>, others as <tt><a>Forced</a>
--   <a>Small</a></tt>. 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 <tt> {--} </tt>
--   where <tt>rel</tt> should be of type <tt>Δ → (lhs rhs : A) → Set
--   i</tt>.
--   
--   Then the user can add rewrite rules by the pragma <tt> {--} </tt>
--   where <tt>q</tt> should be a closed term of type <tt>Γ → rel us lhs
--   rhs</tt>.
--   
--   We then intend to add a rewrite rule <tt> Γ ⊢ lhs ↦ rhs : B </tt> to
--   the signature where <tt>B = A[us/Δ]</tt>.
--   
--   To this end, we normalize <tt>lhs</tt>, which should be of the form
--   <tt> f ts </tt> for a <tt><a>Def</a></tt>-symbol f (postulate,
--   function, data, record, constructor). Further, <tt>FV(ts) =
--   dom(Γ)</tt>. The rule <tt>q :: Γ ⊢ f ts ↦ rhs : B</tt> is added to the
--   signature to the definition of <tt>f</tt>.
--   
--   When reducing a term <tt>Ψ ⊢ f vs</tt> is stuck, we try the rewrites
--   for <tt>f</tt>, by trying to unify <tt>vs</tt> with <tt>ts</tt>. This
--   is for now done by substituting fresh metas Xs for the bound variables
--   in <tt>ts</tt> and checking equality with <tt>vs</tt> <tt> Ψ ⊢ (f
--   ts)[Xs<i>Γ] = f vs : B[Xs</i>Γ] </tt> If successful (no open
--   metas/constraints), we replace <tt>f vs</tt> by <tt>rhs[Xs/Γ]</tt> 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 <tt>Δ → (lhs :
--   A) (rhs : B) → Set ℓ</tt>. Note: we do not care about
--   hiding/non-hiding of lhs and rhs.
verifyBuiltinRewrite :: Term -> Type -> TCM ()

-- | Deconstructing a type into <tt>Δ → t → t' → core</tt>.
data RelView
RelView :: Telescope -> ListTel -> Dom Type -> Dom Type -> Type -> RelView

-- | The whole telescope <tt>Δ, t, t'</tt>.
[relViewTel] :: RelView -> Telescope

-- | <tt>Δ</tt>.
[relViewDelta] :: RelView -> ListTel

-- | <tt>t</tt>.
[relViewType] :: RelView -> Dom Type

-- | <tt>t'</tt>.
[relViewType'] :: RelView -> Dom Type

-- | <tt>core</tt>.
[relViewCore] :: RelView -> Type

-- | Deconstructing a type into <tt>Δ → t → t' → core</tt>. Returns
--   <tt>Nothing</tt> if not enough argument types.
relView :: Type -> TCM (Maybe RelView)

-- | Add <tt>q : Γ → rel us lhs rhs</tt> as rewrite rule <tt> Γ ⊢ lhs ↦ rhs
--   : B </tt> to the signature where <tt>B = A[us/Δ]</tt>. Remember that
--   <tt>rel : Δ → A → A → Set i</tt>, so <tt>rel us : (lhs rhs : A[us/Δ])
--   → Set i</tt>.
addRewriteRule :: QName -> TCM ()

-- | Append rewrite rules to a definition.
addRewriteRules :: QName -> RewriteRules -> TCM ()

-- | Sledgehammer approach to local rewrite rules. Rebind them after each
--   left-hand side (which scrambles the context).
rebindLocalRewriteRules :: TCM ()

-- | <tt>rewriteWith t f es rew</tt> tries to rewrite <tt>f es : t</tt>
--   with <tt>rew</tt>, returning the reduct if successful.
rewriteWith :: Maybe Type -> Term -> RewriteRule -> Elims -> ReduceM (Either (Blocked Term) Term)

-- | <tt>rewrite b v rules es</tt> tries to rewrite <tt>v</tt> applied to
--   <tt>es</tt> with the rewrite rules <tt>rules</tt>. <tt>b</tt> is the
--   default blocking tag.
rewrite :: Blocked_ -> Term -> RewriteRules -> Elims -> ReduceM (Reduced (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

-- | Get all symbols that a rewrite rule matches against
class GetMatchables a
getMatchables :: GetMatchables a => a -> [QName]
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.NLPType
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.NLPType
instance Agda.TypeChecking.Rewriting.KillCtxId Agda.TypeChecking.Monad.Base.NLPat
instance (Data.Foldable.Foldable f, Agda.TypeChecking.Rewriting.GetMatchables a) => Agda.TypeChecking.Rewriting.GetMatchables (f a)
instance Agda.TypeChecking.Rewriting.GetMatchables Agda.TypeChecking.Monad.Base.NLPat
instance Agda.TypeChecking.Rewriting.GetMatchables Agda.TypeChecking.Monad.Base.RewriteRule
instance Agda.TypeChecking.Free.Lazy.Free' Agda.TypeChecking.Monad.Base.NLPat c
instance Agda.TypeChecking.Free.Lazy.Free' Agda.TypeChecking.Monad.Base.NLPType c


-- | This module contains an optimised implementation of the reduction
--   algorithm from <a>Reduce</a> and <a>Match</a>. It runs roughly an
--   order of magnitude faster than the original implementation.
--   
--   The differences are the following:
--   
--   <ul>
--   <li>Only applies when we don't have --sharing and when all reductions
--   are allowed.</li>
--   </ul>
--   
--   This means we can skip a number of checks that would otherwise be
--   performed at each reduction step.
--   
--   <ul>
--   <li>Does not track whether simplifications were made.</li>
--   </ul>
--   
--   This information is only used when trying to simplify terms, so the
--   simplifier runs the slow implementation.
--   
--   <ul>
--   <li>Precomputes primZero and primSuc.</li>
--   </ul>
--   
--   Since all the functions involved in reduction are implemented in this
--   module in a single where block, we can look up zero and suc once
--   instead of once for each reduction step.
--   
--   <ul>
--   <li>Run outside ReduceM</li>
--   </ul>
--   
--   ReduceM is already just a plain reader monad, but pulling out the
--   environment and doing all reduction non-monadically saves a
--   significant amount of time.
--   
--   <ul>
--   <li>Memoise getConstInfo.</li>
--   </ul>
--   
--   A big chunk of the time during reduction is spent looking up
--   definitions in the signature. Any long-running reduction will use only
--   a handful definitions though, so memoising getConstInfo is a big win.
--   
--   <ul>
--   <li>Optimised case trees.</li>
--   </ul>
--   
--   Since we memoise getConstInfo we can do some preprocessing of the
--   definitions, returning a <a>CompactDef</a> instead of a
--   <a>Definition</a>. In particular we streamline the case trees used for
--   matching in a few ways:
--   
--   <ul>
--   <li>Drop constructor arity information.</li>
--   <li>Use NameId instead of QName as map keys.</li>
--   <li>Special branch for natural number successor.</li>
--   </ul>
--   
--   None of these changes would make sense to incorporate into the actual
--   case trees. The first two loses information that we need in other
--   places and the third would complicate a lot of code working with case
--   trees.
--   
--   <ul>
--   <li>Optimised parallel substitution.</li>
--   </ul>
--   
--   When substituting arguments into function bodies we always have a
--   complete (a term for every free variable) parallel substitution. We
--   run an specialised substitution for this case that falls back to
--   normal substitution when it hits a binder.
module Agda.TypeChecking.Reduce.Fast

-- | First argument: allow non-terminating reductions.
fastReduce :: Bool -> Term -> ReduceM (Blocked Term)

module Agda.TypeChecking.Rules.Data

-- | Type check a datatype definition. Assumes that the type has already
--   been checked.
checkDataDef :: DefInfo -> QName -> [LamBinding] -> [Constructor] -> TCM ()

-- | Ensure that the type is a sort. If it is not directly a sort, compare
--   it to a <a>newSortMetaBelowInf</a>.
forceSort :: Type -> TCM Sort

-- | A parameter is small if its sort fits into the data sort.
--   <tt>smallParams</tt> 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 -&gt; Type -&gt; 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 <tt>data Eq (A : Set)(a : A) : A -&gt; Set where refl : Eq A a
--   a</tt> this would include parameter <tt>a</tt>, but not <tt>A</tt>.
--   
--   TODO: what if there's a meta here?
constructs :: Int -> Type -> QName -> TCM [Int]

-- | Is the type coinductive? Returns <a>Nothing</a> 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


-- | Unification algorithm for specializing datatype indices, as described
--   in "Unifiers as Equivalences: Proof-Relevant Unification of
--   Dependently Typed Data" by Jesper Cockx, Dominique Devriese, and Frank
--   Piessens (ICFP 2016).
--   
--   This is the unification algorithm used for checking the left-hand side
--   of clauses (see <tt>Agda.TypeChecking.Rules.LHS</tt>), coverage
--   checking (see <tt>Agda.TypeChecking.Coverage</tt>) and indirectly also
--   for interactive case splitting (see
--   <tt>Agda.Interaction.MakeCase</tt>).
--   
--   A unification problem (of type <tt>UnifyState</tt>) consists of: 1. A
--   telescope <tt>varTel</tt> of free variables, some or all of which are
--   flexible (as indicated by <tt>flexVars</tt>). 2. A telescope
--   <tt>eqTel</tt> containing the types of the equations. 3. Left- and
--   right-hand sides for each equation: <tt>varTel ⊢ eqLHS : eqTel</tt>
--   and <tt>varTel ⊢ eqRHS : eqTel</tt>.
--   
--   The unification algorithm can end in three different ways: (type
--   <tt>UnificationResult</tt>): - A *positive success* <tt>Unifies (tel,
--   sigma, ps)</tt> with <tt>tel ⊢ sigma : varTel</tt>, <tt>tel ⊢ eqLHS [
--   varTel ↦ sigma ] ≡ eqRHS [ varTel ↦ sigma ] : eqTel</tt>, and <tt>tel
--   ⊢ ps : eqTel</tt>. In this case, <tt>sigma;ps</tt> is an *equivalence*
--   between the telescopes <tt>tel</tt> and <tt>varTel(eqLHS ≡
--   eqRHS)</tt>. - A *negative success* <tt>NoUnify err</tt> means that a
--   conflicting equation was found (e.g an equation between two distinct
--   constructors or a cycle). - A *failure* <tt>DontKnow err</tt> means
--   that the unifier got stuck.
--   
--   The unification algorithm itself consists of two parts: 1. A
--   *unification strategy* takes a unification problem and produces a list
--   of suggested unification rules (of type <tt>UnifyStep</tt>).
--   Strategies can be constructed by composing simpler strategies (see for
--   example the definition of <tt>completeStrategyAt</tt>). 2. The
--   *unification engine* <tt>unifyStep</tt> takes a unification rule and
--   tries to apply it to the given state, writing the result to the
--   UnifyOutput on a success.
--   
--   The unification steps (of type <tt>UnifyStep</tt>) are the following:
--   - *Deletion* removes a reflexive equation <tt>u =?= v : a</tt> if the
--   left- and right-hand side <tt>u</tt> and <tt>v</tt> are
--   (definitionally) equal. This rule results in a failure if --without-K
--   is enabled (see "Pattern Matching Without K" by Jesper Cockx,
--   Dominique Devriese, and Frank Piessens (ICFP 2014). - *Solution*
--   solves an equation if one side is (eta-equivalent to) a flexible
--   variable. In case both sides are flexible variables, the unification
--   strategy makes a choice according to the <tt>chooseFlex</tt> function
--   in <tt>Agda.TypeChecking.Rules.LHS.Problem</tt>. - *Injectivity*
--   decomposes an equation of the form <tt>c us =?= c vs : D pars is</tt>
--   where <tt>c : Δc → D pars js</tt> is a constructor of the inductive
--   datatype <tt>D</tt> into a sequence of equations <tt>us =?= vs :
--   delta</tt>. In case <tt>D</tt> is an indexed datatype,
--   *higher-dimensional unification* is applied (see below). - *Conflict*
--   detects absurd equations of the form <tt>c₁ us =?= c₂ vs : D pars
--   is</tt> where <tt>c₁</tt> and <tt>c₂</tt> are two distinct
--   constructors of the datatype <tt>D</tt>. - *Cycle* detects absurd
--   equations of the form <tt>x =?= v : D pars is</tt> where <tt>x</tt> is
--   a variable of the datatype <tt>D</tt> that occurs strongly rigid in
--   <tt>v</tt>. - *EtaExpandVar* eta-expands a single flexible variable
--   <tt>x : R</tt> where <tt>R</tt> is a (eta-expandable) record type,
--   replacing it by one variable for each field of <tt>R</tt>. -
--   *EtaExpandEquation* eta-expands an equation <tt>u =?= v : R</tt> where
--   <tt>R</tt> is a (eta-expandable) record type, replacing it by one
--   equation for each field of <tt>R</tt>. The left- and right-hand sides
--   of these equations are the projections of <tt>u</tt> and <tt>v</tt>. -
--   *LitConflict* detects absurd equations of the form <tt>l₁ =?= l₂ :
--   A</tt> where <tt>l₁</tt> and <tt>l₂</tt> are distinct literal terms. -
--   *StripSizeSuc* simplifies an equation of the form <tt>sizeSuc x =?=
--   sizeSuc y : Size</tt> to <tt>x =?= y : Size</tt>. -
--   *SkipIrrelevantEquation<tt> removes an equation between irrelevant
--   terms. - *TypeConInjectivity* decomposes an equation of the form
--   </tt>D us =?= D vs : Set i<tt> where </tt>D@ is a datatype. This rule
--   is only used if --injective-type-constructors is enabled.
--   
--   Higher-dimensional unification (new, does not yet appear in any
--   paper): If an equation of the form <tt>c us =?= c vs : D pars is</tt>
--   is encountered where <tt>c : Δc → D pars js</tt> is a constructor of
--   an indexed datatype <tt>D pars : Φ → Set ℓ</tt>, it is in general
--   unsound to just simplify this equation to <tt>us =?= vs : Δc</tt>. For
--   this reason, the injectivity rule in the paper restricts the indices
--   <tt>is</tt> to be distinct variables that are bound in the telescope
--   <tt>eqTel</tt>. But we can be more general by introducing new
--   variables <tt>ks</tt> to the telescope <tt>eqTel</tt> and equating
--   these to <tt>is</tt>: <tt> Δ₁(x : D pars is)Δ₂ ≃ Δ₁(ks : Φ)(x : D pars
--   ks)(ps : is ≡Φ ks)Δ₂ </tt> Since <tt>ks</tt> are distinct variables,
--   it's now possible to apply injectivity to the equation <tt>x</tt>,
--   resulting in the following new equation telescope: <tt> Δ₁(ys : Δc)(ps
--   : is ≡Φ js[Δc ↦ ys])Δ₂ </tt> Now we can solve the equations
--   <tt>ps</tt> by recursively calling the unification algorithm with
--   flexible variables <tt>Δ₁(ys : Δc)</tt>. This is called
--   *higher-dimensional unification* since we are unifying equality proofs
--   rather than terms. If the higher-dimensional unification succeeds, the
--   resulting telescope serves as the new equation telescope for the
--   original unification problem.
module Agda.TypeChecking.Rules.LHS.Unify

-- | Result of <a>unifyIndices</a>.
type UnificationResult = UnificationResult' (Telescope, PatternSubstitution, [NamedArg DeBruijnPattern])
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 <tt>unifyIndices_ flex a us vs</tt>,
--   
--   <tt>a</tt> is the type eliminated by <tt>us</tt> and <tt>vs</tt>
--   (usally the type of a constructor), need not be reduced,
--   
--   <tt>us</tt> and <tt>vs</tt> are the argument lists to unify,
--   
--   <tt>flex</tt> is the set of flexible (instantiable) variabes in
--   <tt>us</tt> and <tt>vs</tt>.
--   
--   The result is the most general unifier of <tt>us</tt> and <tt>vs</tt>.
unifyIndices_ :: MonadTCM tcm => Telescope -> FlexibleVars -> Type -> Args -> Args -> tcm (Telescope, PatternSubstitution, [NamedArg DeBruijnPattern])
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 Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.Rules.LHS.Unify.UnifyStep
instance Data.Semigroup.Semigroup Agda.TypeChecking.Rules.LHS.Unify.UnifyOutput
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 <a>apply</a> (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 -> ModuleParamDict -> Maybe (Arg Type) -> SplitClause

-- | Type of variables in <tt>scPats</tt>.
[scTel] :: SplitClause -> Telescope

-- | The patterns leading to the currently considered branch of the split
--   tree.
[scPats] :: SplitClause -> [NamedArg DeBruijnPattern]

-- | Substitution from <a>scTel</a> to old context. Only needed directly
--   after split on variable: * To update <a>scTarget</a> * To rename other
--   split variables when splitting on multiple variables. <tt>scSubst</tt>
--   is not `<tt>transitive'</tt>, i.e., does not record the substitution
--   from the original context to <a>scTel</a> over a series of splits. It
--   is freshly computed after each split by <tt>computeNeighborhood</tt>;
--   also <a>splitResult</a>, which does not split on a variable, should
--   reset it to the identity <a>idS</a>, lest it be applied to
--   <a>scTarget</a> again, leading to Issue 1294.
[scSubst] :: SplitClause -> PatternSubstitution

-- | We need to keep track of the module parameter substitutions for the
--   clause for the purpose of inferring missing instance clauses.
[scModuleParameterSub] :: SplitClause -> ModuleParamDict

-- | The type of the rhs, living in context <a>scTel</a>. This invariant is
--   broken before calls to <a>fixTarget</a>; there, <a>scTarget</a> lives
--   in the old context. <a>fixTarget</a> moves <a>scTarget</a> to the new
--   context by applying substitution <a>scSubst</a>.
[scTarget] :: SplitClause -> Maybe (Arg Type)

-- | Create a split clause from a clause in internal syntax. Used by
--   make-case.
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 <tt>Covering</tt> is the result of splitting a <a>SplitClause</a>.
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

-- | Top-level function for eliminating redundant clauses in the
--   interactive case splitter
isCovered :: QName -> [Clause] -> SplitClause -> TCM Bool

-- | Entry point from <tt>Interaction.MakeCase</tt>.
splitClauseWithAbsurd :: SplitClause -> Nat -> TCM (Either SplitError (Either SplitClause Covering))

-- | Entry point from <tt>TypeChecking.Empty</tt> and
--   <tt>Interaction.BasicOps</tt>. <tt>splitLast CoInductive</tt> is used
--   in the <tt>refine</tt> tactics.
splitLast :: Induction -> Telescope -> [NamedArg DeBruijnPattern] -> TCM (Either SplitError Covering)

-- | <pre>
--   splitResult f sc = return res
--   </pre>
--   
--   If the target type of <tt>sc</tt> is a record type, a covering set of
--   split clauses is returned (<tt>sc</tt> extended by all valid
--   projection patterns), otherwise <tt>res == Nothing</tt>. Note that the
--   empty set of split clauses is returned if the record has no fields.
splitResult :: QName -> SplitClause -> TCM (Maybe Covering)
normaliseProjP :: (NormaliseProjP a, HasConstInfo m) => a -> m a
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 <tt>Nothing</tt>.
compileClauses :: Maybe (QName, Type) -> [Clause] -> TCM CompiledClauses

-- | Stripped-down version of <a>Clause</a> used in clause compiler.
data Cl
Cl :: [Arg Pattern] -> Maybe Term -> Cl

-- | Pattern variables are considered in left-to-right order.
[clPats] :: Cl -> [Arg Pattern]
[clBody] :: Cl -> Maybe Term
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' a -> Maybe Bool

-- | Is this a variable pattern?
--   
--   Maintain invariant: <tt>isVar = isNothing . properSplit</tt>!
isVar :: Pattern' a -> Bool

-- | <tt>splitOn single n cs</tt> will force expansion of catch-alls if
--   <tt>single</tt>.
splitOn :: Bool -> Int -> Cls -> Case Cls
splitC :: Int -> Cl -> Case Cl

-- | Expand catch-alls that appear before actual matches.
--   
--   Example:
--   
--   <pre>
--   true  y
--   x     false
--   false y
--   </pre>
--   
--   will expand the catch-all <tt>x</tt> to <tt>false</tt>.
--   
--   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): <tt> f (x, (y, z)) true = a f _
--   false = b </tt> Split tree: <tt> 0 (first argument of f) - 1 (second
--   component of the pair) - 3 (last argument of f) -- true -&gt; a -
--   false -&gt; b </tt> We would like to get the following case tree: <tt>
--   case 0 of _,_ -&gt; case 1 of _,_ -&gt; case 3 of true -&gt; a; false
--   -&gt; b _ -&gt; case 3 of true -&gt; a; false -&gt; b _ -&gt; case 3
--   of true -&gt; a; false -&gt; b </tt>
--   
--   Example from issue #2168: <tt> f x false = a f false = _ -&gt; b f x
--   true = c </tt> case tree: <tt> f x y = case y of true -&gt; case x of
--   true -&gt; c false -&gt; b false -&gt; a </tt>
expandCatchAlls :: Bool -> Int -> Cls -> Cls

-- | Make sure (by eta-expansion) that clause has arity at least <tt>n</tt>
--   where <tt>n</tt> is also the length of the provided list.
ensureNPatterns :: Int -> [ArgInfo] -> Cl -> Cl
substBody :: (Subst t a) => Int -> Int -> t -> a -> a
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 <a>RecordFlex</a>.

-- | 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 <a>Problem</a>, 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 ()

-- | Temporary data structure for <tt>checkLeftoverPatterns</tt>
type Projectn = (ProjOrigin, QName)
type Projectns = [Projectn]

-- | 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 <a>Hiding</a> of
--   the patterns matches the hiding info in the type.
--   
--   Precondition: the patterns should all be <a>VarP</a>, <a>WildP</a>, or
--   <a>AbsurdP</a> and the telescope should have the same size as the
--   pattern list. There could also be <a>ConP</a>s 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 :: Nat -> Telescope -> [NamedArg DeBruijnPattern] -> Arg Type -> Substitution -> [AsBinding] -> LHSResult

-- | The number of original module parameters. These are present in the the
--   patterns.
[lhsParameters] :: LHSResult -> Nat

-- | Δ : The types of the pattern variables, in internal dependency order.
--   Corresponds to <a>clauseTel</a>.
[lhsVarTele] :: LHSResult -> Telescope

-- | The patterns in internal syntax.
[lhsPatterns] :: LHSResult -> [NamedArg DeBruijnPattern]

-- | The type of the body. Is <tt>bσ</tt> if <tt>Γ</tt> is defined.
--   <a>Irrelevant</a> to indicate the rhs must be checked in irrelevant
--   mode.
[lhsBodyType] :: LHSResult -> Arg Type

-- | Substitution version of <tt>lhsPatterns</tt>, only up to the first
--   projection pattern. <tt>Δ |- lhsPatSubst : Γ</tt>. Where <tt>Γ</tt> is
--   the argument telescope of the function. This is used to update
--   inherited dot patterns in with-function clauses.
[lhsPatSubst] :: LHSResult -> Substitution

-- | As-bindings from the left-hand side. Return instead of bound since we
--   want them in where's and right-hand sides, but not in with-clauses
--   (Issue 2303).
[lhsAsBindings] :: LHSResult -> [AsBinding]

-- | Check a LHS. Main function.
--   
--   <tt>checkLeftHandSide a ps a ret</tt> checks that user patterns
--   <tt>ps</tt> eliminate the type <tt>a</tt> of the defined function, and
--   calls continuation <tt>ret</tt> if successful.
checkLeftHandSide :: Call -> Maybe QName -> [NamedArg Pattern] -> Type -> Maybe Substitution -> (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:
--   
--   <ol>
--   <li>Get size constraints, cluster into connected components.</li>
--   </ol>
--   
--   All size constraints that mention the same metas go into the same
--   cluster. Each cluster can be solved by itself.
--   
--   Constraints that do not fit our format are ignored. We check whether
--   our computed solution fulfills them as well in the last step.
--   
--   <ol>
--   <li>Find a joint context for each cluster.</li>
--   </ol>
--   
--   Each constraint comes with its own typing context, which contains size
--   hypotheses <tt>j : Size&lt; i</tt>. We need to find a common super
--   context in which all constraints of a cluster live, and raise all
--   constraints to this context.
--   
--   There might not be a common super context. Then we are screwed, since
--   our solver is not ready to deal with such a situation. We will
--   blatantly refuse to solve this cluster and blame it on the user.
--   
--   <ol>
--   <li>Convert the joint context into a hypothesis graph.</li>
--   </ol>
--   
--   This is straightforward. Each de Bruijn index becomes a rigid
--   variable, each typing assumption <tt>j : Size&lt; i</tt> becomes an
--   arc.
--   
--   <ol>
--   <li>Convert the constraints into a constraint graph.</li>
--   </ol>
--   
--   Here we need to convert <tt>MetaV</tt>s into flexible variables.
--   
--   <ol>
--   <li>Run the solver</li>
--   <li>Convert the solution into meta instantiations.</li>
--   <li>Double-check whether the constraints are solved.</li>
--   </ol>
module Agda.TypeChecking.SizedTypes.Solve
type CC = Closure Constraint

-- | Flag to control the behavior of size solver.
data DefaultToInfty

-- | Instantiate all unconstrained size variables to ∞.
DefaultToInfty :: DefaultToInfty

-- | Leave unconstrained size variables unsolved.
DontDefaultToInfty :: DefaultToInfty

-- | Solve size constraints involving hypotheses.
solveSizeConstraints :: DefaultToInfty -> TCM ()

-- | TODO: this does not actually work!
--   
--   We would like to use a constraint <tt>c</tt> created in context
--   <tt>Δ</tt> from module <tt>N</tt> in the current context <tt>Γ</tt>
--   and current module <tt>M</tt>.
--   
--   <tt>Δ</tt> is module tel <tt>Δ₁</tt> of <tt>N</tt> extended by some
--   local bindings <tt>Δ₂</tt>. <tt>Γ</tt> is the current context. The
--   module parameter substitution from current <tt>M</tt> to <tt>N</tt> be
--   <tt>Γ ⊢ σ : Δ₁</tt>.
--   
--   If <tt>M == N</tt>, we do not need the parameter substitution. We try
--   raising.
--   
--   We first strengthen <tt>Δ ⊢ c</tt> to live in <tt>Δ₁</tt> and obtain
--   <tt>c₁ = strengthen Δ₂ c</tt>. We then transport <tt>c₁</tt> to
--   <tt>Γ</tt> and obtain <tt>c₂ = applySubst σ c₁</tt>.
--   
--   This works for different modules, but if <tt>M == N</tt> we should not
--   strengthen and then weaken, because strengthening is a partial
--   operation. We should rather lift the substitution <tt>σ</tt> by
--   <tt>Δ₂</tt> and then raise by <tt>Γ₂ - Δ₂</tt>. This "raising" might
--   be a strengthening if <tt>Γ₂</tt> is shorter than <tt>Δ₂</tt>.
--   
--   (TODO: If the module substitution does not exist, because <tt>N</tt>
--   is not a parent of <tt>M</tt>, we cannot use the constraint, as it has
--   been created in an unrelated context.)
castConstraintToCurrentContext' :: Closure Constraint -> MaybeT TCM Constraint

-- | A hazardous hack, may the Gods have mercy on us.
--   
--   To cast to the current context, we match the context of the given
--   constraint by <a>CtxId</a>, and as fallback, by variable name (douh!).
--   
--   This hack lets issue 2046 go through.
castConstraintToCurrentContext :: Closure Constraint -> MaybeT TCM Constraint

-- | Return the size metas occurring in the simplified constraints. A
--   constraint like <tt>↑ _j =&lt; ∞ : Size</tt> simplifies to nothing, so
--   <tt>_j</tt> would not be in this set.
solveSizeConstraints_ :: DefaultToInfty -> [CC] -> TCM (Set MetaId)

-- | Solve a cluster of constraints sharing some metas.
solveCluster :: DefaultToInfty -> [(CC, HypSizeConstraint)] -> TCM ()

-- | Collect constraints from a typing context, looking for SIZELT
--   hypotheses.
getSizeHypotheses :: Context -> TCM [(CtxId, SizeConstraint)]

-- | Convert size constraint into form where each meta is applied to
--   indices <tt>n-1,...,1,0</tt> where <tt>n</tt> is the arity of that
--   meta.
--   
--   <tt>X[σ] &lt;= t</tt> becomes <tt>X[id] &lt;= t[σ^-1]</tt>
--   
--   <tt>X[σ] ≤ Y[τ]</tt> becomes <tt>X[id] ≤ Y[τ[σ^-1]]</tt> or
--   <tt>X[σ[τ^1]] ≤ Y[id]</tt> whichever is defined. If none is defined,
--   we give up.
--   
--   Cf. <tt>SizedTypes.oldCanonicalizeSizeConstraint</tt>.
--   
--   Fixes (the rather artificial) issue 300. But it is unsound when pruned
--   metas occur and triggers issue 1914. Thus we deactivate it. This needs
--   to be properly implemented, possibly using the metaPermuatation of
--   each meta variable.
canonicalizeSizeConstraint :: SizeConstraint -> Maybe (SizeConstraint)

-- | Identifiers for rigid variables.
data NamedRigid
NamedRigid :: String -> Int -> NamedRigid

-- | Name for printing in debug messages.
[rigidName] :: NamedRigid -> String

-- | De Bruijn index.
[rigidIndex] :: NamedRigid -> Int

-- | Size metas in size expressions.
data SizeMeta
SizeMeta :: MetaId -> [Int] -> SizeMeta
[sizeMetaId] :: SizeMeta -> MetaId

-- | De Bruijn indices.
[sizeMetaArgs] :: SizeMeta -> [Int]

-- | An equality which ignores the meta arguments.

-- | An order which ignores the meta arguments.

-- | Size expression with de Bruijn indices.
type DBSizeExpr = SizeExpr' NamedRigid SizeMeta

-- | Only for <a>raise</a>.
type SizeConstraint = Constraint' NamedRigid SizeMeta

-- | Assumes we are in the right context.

-- | Size constraint with de Bruijn indices.
data HypSizeConstraint
HypSizeConstraint :: Context -> [CtxId] -> [SizeConstraint] -> SizeConstraint -> HypSizeConstraint
[sizeContext] :: HypSizeConstraint -> Context
[sizeHypIds] :: HypSizeConstraint -> [CtxId]

-- | Living in <tt>Context</tt>.
[sizeHypotheses] :: HypSizeConstraint -> [SizeConstraint]

-- | Living in <tt>Context</tt>.
[sizeConstraint] :: HypSizeConstraint -> SizeConstraint

-- | Turn a constraint over de Bruijn indices into a size constraint.
computeSizeConstraint :: Closure Constraint -> TCM (Maybe HypSizeConstraint)

-- | Turn a term into a size expression.
--   
--   Returns <a>Nothing</a> if the term isn't a proper size expression.
sizeExpr :: Term -> TCM (Maybe DBSizeExpr)

-- | Turn a de size expression into a term.
unSizeExpr :: DBSizeExpr -> TCM Term
instance GHC.Show.Show Agda.TypeChecking.SizedTypes.Solve.DefaultToInfty
instance GHC.Classes.Ord Agda.TypeChecking.SizedTypes.Solve.DefaultToInfty
instance GHC.Classes.Eq Agda.TypeChecking.SizedTypes.Solve.DefaultToInfty
instance GHC.Classes.Eq Agda.TypeChecking.SizedTypes.Solve.NamedRigid
instance GHC.Classes.Ord Agda.TypeChecking.SizedTypes.Solve.NamedRigid
instance GHC.Show.Show Agda.TypeChecking.SizedTypes.Solve.NamedRigid
instance Agda.TypeChecking.SizedTypes.Utils.Plus Agda.TypeChecking.SizedTypes.Solve.NamedRigid GHC.Types.Int Agda.TypeChecking.SizedTypes.Solve.NamedRigid
instance GHC.Classes.Eq Agda.TypeChecking.SizedTypes.Solve.SizeMeta
instance GHC.Classes.Ord Agda.TypeChecking.SizedTypes.Solve.SizeMeta
instance GHC.Show.Show Agda.TypeChecking.SizedTypes.Solve.SizeMeta
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.SizedTypes.Solve.SizeMeta
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.SizedTypes.Solve.SizeMeta
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term (Agda.TypeChecking.SizedTypes.Syntax.SizeExpr' Agda.TypeChecking.SizedTypes.Solve.NamedRigid Agda.TypeChecking.SizedTypes.Solve.SizeMeta)
instance Agda.TypeChecking.Substitute.Class.Subst Agda.Syntax.Internal.Term Agda.TypeChecking.SizedTypes.Solve.SizeConstraint
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.SizedTypes.Solve.SizeConstraint
instance Agda.TypeChecking.SizedTypes.Syntax.Flexs Agda.TypeChecking.SizedTypes.Solve.SizeMeta Agda.TypeChecking.SizedTypes.Solve.HypSizeConstraint
instance Agda.TypeChecking.Pretty.PrettyTCM Agda.TypeChecking.SizedTypes.Solve.HypSizeConstraint

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
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 <tt>Term → TCM A</tt> for some A.
--   Returns the resulting term of type <tt>A</tt>. 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.Types.Bool
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
--   <a>SizeUniv</a>. Precondition: When <tt>noFunctionsIntoSize t
--   tBlame</tt> is called, we are in the context of <tt>tBlame</tt> in
--   order to print it correctly. Not being in context of <tt>t</tt> should
--   not matter, as we are only checking whether its sort reduces to
--   <a>SizeUniv</a>.
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 <a>WrongHidingInLambda</a>
insertHiddenLambdas :: Hiding -> Type -> (MetaId -> Type -> TCM Term) -> (Type -> TCM Term) -> TCM Term

-- | <tt>checkAbsurdLambda i h e t</tt> checks absurd lambda against type
--   <tt>t</tt>. Precondition: <tt>e = AbsurdLam i h</tt>
checkAbsurdLambda :: ExprInfo -> Hiding -> Expr -> Type -> TCM Term

-- | <tt>checkExtendedLambda i di qname cs e t</tt> check pattern matching
--   lambda. Precondition: <tt>e = ExtendedLam i di qname cs</tt>
checkExtendedLambda :: ExprInfo -> DefInfo -> QName -> [Clause] -> Expr -> Type -> TCM Term

-- | Run a computation.
--   
--   <ul>
--   <li>If successful, return Nothing.</li>
--   <li>If <tt>IlltypedPattern p a</tt> is thrown and type <tt>a</tt> is
--   blocked on some meta <tt>x</tt> return <tt>Just x</tt>. Note that the
--   returned meta might only exists in the state where the error was
--   thrown, thus, be an invalid <a>MetaId</a> in the current state.</li>
--   <li>If another error was thrown or the type <tt>a</tt> is not blocked,
--   reraise the error.</li>
--   </ul>
catchIlltypedPatternBlockedOnMeta :: TCM () -> TCM (Maybe (TCErr, MetaId))
expandModuleAssigns :: [Either Assign ModuleName] -> [Name] -> TCM Assigns

-- | <tt>checkRecordExpression fs e t</tt> checks record construction
--   against type <tt>t</tt>. Precondition <tt>e = Rec _ fs</tt>.
checkRecordExpression :: RecordAssigns -> Expr -> Type -> TCM Term

-- | <tt>checkRecordUpdate ei recexpr fs e t</tt> Precondition <tt>e =
--   RecUpdate ei recexpr fs</tt>.
checkRecordUpdate :: ExprInfo -> Expr -> Assigns -> Expr -> Type -> TCM Term
checkLiteral :: Literal -> Type -> TCM Term

-- | <tt>checkArguments' exph r args t0 t k</tt> tries <tt>checkArguments
--   exph args t0 t</tt>. If it succeeds, it continues <tt>k</tt> with the
--   returned results. If it fails, it registers a postponed typechecking
--   problem and returns the resulting new meta variable.
--   
--   Checks <tt>e := ((_ : t0) args) : t</tt>.
checkArguments' :: ExpandHidden -> Range -> [NamedArg Expr] -> Type -> Type -> (Args -> Type -> TCM Term) -> TCM Term

-- | Remove top layers of scope info of expression and set the scope
--   accordingly in the <a>TCState</a>.
scopedExpr :: Expr -> TCM Expr

-- | Type check an expression.
checkExpr :: Expr -> Type -> TCM Term

-- | DOCUMENT ME!
quoteGoal :: Type -> TCM (Either [MetaId] Term)

-- | DOCUMENT ME!
quoteContext :: TCM (Either [MetaId] Term)

-- | Unquote a TCM computation in a given hole.
unquoteM :: Expr -> Term -> Type -> TCM Term -> TCM Term

-- | DOCUMENT ME!
unquoteTactic :: Term -> Term -> Type -> TCM Term -> TCM Term

-- | Inferring the type of an overloaded projection application. See
--   <a>inferOrCheckProjApp</a>.
inferProjApp :: Expr -> ProjOrigin -> [QName] -> Args -> TCM (Term, Type)

-- | Checking the type of an overloaded projection application. See
--   <a>inferOrCheckProjApp</a>.
checkProjApp :: Expr -> ProjOrigin -> [QName] -> Args -> Type -> TCM Term

-- | Inferring or Checking an overloaded projection application.
--   
--   The overloaded projection is disambiguated by inferring the type of
--   its principal argument, which is the first visible argument.
inferOrCheckProjApp :: Expr -> ProjOrigin -> [QName] -> Args -> Maybe Type -> TCM (Term, Type)

-- | <tt>checkApplication hd args e t</tt> checks an application.
--   Precondition: <tt>Application hs args = appView e</tt>
--   
--   <tt>checkApplication</tt> disambiguates constructors (and continues to
--   <a>checkConstructorApplication</a>) and resolves pattern synonyms.
checkApplication :: Expr -> Args -> Expr -> Type -> TCM Term

-- | Check an interaction point without arguments.
checkQuestionMark :: (Type -> TCM (MetaId, Term)) -> Type -> MetaInfo -> InteractionId -> TCM Term

-- | Check an underscore without arguments.
checkUnderscore :: Type -> MetaInfo -> TCM Term

-- | Type check a meta variable.
checkMeta :: (Type -> TCM (MetaId, Term)) -> Type -> MetaInfo -> TCM Term

-- | Infer the type of a meta variable. If it is a new one, we create a new
--   meta for its type.
inferMeta :: (Type -> TCM (MetaId, Term)) -> MetaInfo -> TCM (Args -> Term, Type)

-- | Type check a meta variable. If its type is not given, we return its
--   type, or a fresh one, if it is a new meta. If its type is given, we
--   check that the meta has this type, and we return the same type.
checkOrInferMeta :: (Type -> TCM (MetaId, Term)) -> Maybe Type -> MetaInfo -> TCM (Term, Type)

-- | Turn a domain-free binding (e.g. lambda) into a domain-full one, by
--   inserting an underscore for the missing type.
domainFree :: ArgInfo -> Name -> LamBinding
inferHeadDef :: ProjOrigin -> QName -> TCM (Args -> Term, Type)

-- | Infer the type of a head thing (variable, function symbol, or
--   constructor). We return a function that applies the head to arguments.
--   This is because in case of a constructor we want to drop the
--   parameters.
inferHead :: Expr -> TCM (Args -> Term, Type)
inferDef :: (Args -> Term) -> QName -> TCM (Term, Type)

-- | Check the type of a constructor application. This is easier than a
--   general application since the implicit arguments can be inserted
--   without looking at the arguments to the constructor.
checkConstructorApplication :: Expr -> Type -> ConHead -> [NamedArg Expr] -> TCM Term

-- | <tt>checkHeadApplication e t hd args</tt> checks that <tt>e</tt> has
--   type <tt>t</tt>, assuming that <tt>e</tt> has the form <tt>hd
--   args</tt>. The corresponding type-checked term is returned.
--   
--   If the head term <tt>hd</tt> is a coinductive constructor, then a
--   top-level definition <tt>fresh tel = hd args</tt> (where the clause is
--   delayed) is added, where <tt>tel</tt> corresponds to the current
--   telescope. The returned term is <tt>fresh tel</tt>.
--   
--   Precondition: The head <tt>hd</tt> has to be unambiguous, and there
--   should not be any need to insert hidden lambdas.
checkHeadApplication :: Expr -> Type -> Expr -> [NamedArg Expr] -> TCM Term
traceCallE :: Call -> ExceptT e TCM r -> ExceptT e TCM r

-- | Check arguments whose value we already know.
--   
--   This function can be used to check user-supplied parameters we have
--   already computed by inference.
--   
--   Precondition: The type <tt>t</tt> of the head has enough domains.
checkKnownArguments :: [NamedArg Expr] -> Args -> Type -> TCM (Args, Type)

-- | Check an argument whose value we already know.
checkKnownArgument :: NamedArg Expr -> Args -> Type -> TCM (Args, Type)

-- | Check a single argument.
checkNamedArg :: NamedArg Expr -> Type -> TCM Term

-- | Check a list of arguments: <tt>checkArgs args t0 t1</tt> checks that
--   <tt>t0 = Delta -&gt; t0'</tt> and <tt>args : Delta</tt>. Inserts
--   hidden arguments to make this happen. Returns the evaluated arguments
--   <tt>vs</tt>, the remaining type <tt>t0'</tt> (which should be a
--   subtype of <tt>t1</tt>) and any constraints <tt>cs</tt> that have to
--   be solved for everything to be well-formed.
checkArguments :: ExpandHidden -> Range -> [NamedArg Expr] -> Type -> Type -> ExceptT (Args, [NamedArg Expr], Type) TCM (Args, Type)

-- | Check that a list of arguments fits a telescope. Inserts hidden
--   arguments as necessary. Returns the type-checked arguments and the
--   remaining telescope.
checkArguments_ :: ExpandHidden -> Range -> [NamedArg Expr] -> Telescope -> TCM (Args, Telescope)

-- | 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)
inferExpr' :: ExpandHidden -> Expr -> TCM (Term, Type)
defOrVar :: Expr -> Bool

-- | Used to check aliases <tt>f = e</tt>. Switches off <a>ExpandLast</a>
--   for the checking of top-level application.
checkDontExpandLast :: Expr -> Type -> TCM Term

-- | Check whether a de Bruijn index is bound by a module telescope.
isModuleFreeVar :: Int -> TCM Bool

-- | Infer the type of an expression, and if it is of the form <tt>{tel}
--   -&gt; D vs</tt> for some datatype <tt>D</tt> then insert the hidden
--   arguments. Otherwise, leave the type polymorphic.
inferExprForWith :: Expr -> TCM (Term, Type)
checkLetBindings :: [LetBinding] -> TCM a -> TCM a
checkLetBinding :: LetBinding -> TCM a -> TCM a
instance GHC.Show.Show Agda.TypeChecking.Rules.Term.LamOrPi
instance GHC.Classes.Eq Agda.TypeChecking.Rules.Term.LamOrPi

module Agda.TypeChecking.Rules.Record

-- | <pre>
--   checkRecDef i name con ps contel fields
--   </pre>
--   
--   <ul>
--   <li><i><tt>name</tt></i> Record type identifier.</li>
--   <li><i><tt>con</tt></i> Maybe constructor name and info.</li>
--   <li><i><tt>ps</tt></i> Record parameters.</li>
--   <li><i><tt>contel</tt></i> Approximate type of constructor
--   (<tt>fields</tt> -&gt; Set). Does not include record parameters.</li>
--   <li><i><tt>fields</tt></i> List of field signatures.</li>
--   </ul>
checkRecDef :: DefInfo -> QName -> Maybe (Ranged Induction) -> Maybe Bool -> Maybe QName -> [LamBinding] -> Expr -> [Field] -> TCM ()

-- | <tt>checkRecordProjections m r q tel ftel fs</tt>.
--   
--   <ul>
--   <li><i><tt>m</tt> </i> name of the generated module</li>
--   <li><i><tt>r</tt> </i> name of the record type</li>
--   <li><i><tt>con</tt> </i> name of the record constructor</li>
--   <li><i><tt>tel</tt> </i> parameters and record variable r
--   ("self")</li>
--   <li><i><tt>ftel</tt> </i> telescope of fields</li>
--   <li><i><tt>fs</tt> </i> the fields to be checked</li>
--   </ul>
checkRecordProjections :: ModuleName -> QName -> Bool -> ConHead -> Telescope -> Telescope -> [Declaration] -> TCM ()

module Agda.TypeChecking.With

-- | Split pattern variables according to with-expressions.
splitTelForWith :: Telescope -> Type -> [EqualityView] -> [Term] -> (Telescope, Telescope, Permutation, Type, [EqualityView], [Term])

-- | Abstract with-expressions <tt>vs</tt> to generate type for with-helper
--   function.
--   
--   Each <tt>EqualityType</tt>, coming from a <tt>rewrite</tt>, will turn
--   into 2 abstractions.
withFunctionType :: Telescope -> [Term] -> [EqualityView] -> Telescope -> Type -> TCM (Type, Nat)
countWithArgs :: [EqualityView] -> Nat

-- | From a list of <tt>with</tt> and <tt>rewrite</tt> expressions and
--   their types, compute the list of final <tt>with</tt> expressions
--   (after expanding the <tt>rewrite</tt>s).
withArguments :: [Term] -> [EqualityView] -> [Term]

-- | Compute the clauses for the with-function given the original patterns.
buildWithFunction :: [Name] -> QName -> QName -> Type -> [NamedArg DeBruijnPattern] -> Nat -> Substitution -> Permutation -> Nat -> Nat -> [SpineClause] -> TCM [SpineClause]

-- | <pre>
--   stripWithClausePatterns cxtNames parent f t qs np π ps = ps'
--   </pre>
--   
--   <ul>
--   <li><i><tt>Δ</tt></i> context bound by lhs of original function (not
--   an argument).</li>
--   <li><i><tt>f</tt></i> name of <tt>with</tt>-function.</li>
--   <li><i><tt>t</tt></i> type of the original function.</li>
--   <li><i><tt>qs</tt></i> internal patterns for original function.</li>
--   <li><i><tt>np</tt></i> number of module parameters in <tt>qs</tt></li>
--   <li><i><tt>π</tt></i> permutation taking <tt>vars(qs)</tt> to
--   <tt>support(Δ)</tt>.</li>
--   <li><i><tt>ps</tt></i> patterns in with clause (eliminating type
--   <tt>t</tt>).</li>
--   <li><i><tt>ps'</tt></i> patterns for with function (presumably of type
--   <tt>Δ</tt>).</li>
--   </ul>
--   
--   Example:
--   
--   <pre>
--   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 = {!!}
--   </pre>
--   
--   With function:
--   
--   <pre>
--   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
--   </pre>
--   
--   Resulting with-function clause is:
--   
--   <pre>
--   f t (b , bs) (suc n) as t p
--   </pre>
--   
--   Note: stripWithClausePatterns factors <tt>ps</tt> through <tt>qs</tt>,
--   thus
--   
--   <pre>
--   ps = qs[ps']
--   </pre>
--   
--   where <tt>[..]</tt> is to be understood as substitution. The
--   projection patterns have vanished from <tt>ps'</tt> (as they are
--   already in <tt>qs</tt>).
stripWithClausePatterns :: [Name] -> QName -> QName -> Type -> [NamedArg DeBruijnPattern] -> Nat -> Permutation -> [NamedArg Pattern] -> TCM ([NamedDotPattern], [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,
--   
--   <pre>
--   aux a b c
--   
--   </pre>
--   
--   as
--   
--   <pre>
--   f (suc a) (suc b) | c
--   
--   </pre>
withDisplayForm :: QName -> QName -> Telescope -> Telescope -> Nat -> [NamedArg DeBruijnPattern] -> Permutation -> Permutation -> TCM DisplayForm
patsToElims :: [NamedArg DeBruijnPattern] -> [Elim' DisplayTerm]

module Agda.TypeChecking.Rules.Def
checkFunDef :: Delayed -> DefInfo -> QName -> [Clause] -> TCM ()
checkMacroType :: Type -> TCM ()

-- | A single clause without arguments and without type signature is an
--   alias.
isAlias :: [Clause] -> Type -> Maybe (Expr, Maybe Expr, MetaId)

-- | Check a trivial definition of the form <tt>f = e</tt>
checkAlias :: Type -> ArgInfo -> Delayed -> DefInfo -> QName -> Expr -> Maybe Expr -> TCM ()

-- | Type check a definition by pattern matching.
checkFunDef' :: Type -> ArgInfo -> Delayed -> Maybe ExtLamInfo -> Maybe QName -> DefInfo -> QName -> [Clause] -> TCM ()

-- | Type check a definition by pattern matching.
checkFunDefS :: Type -> ArgInfo -> Delayed -> Maybe ExtLamInfo -> Maybe QName -> DefInfo -> QName -> Maybe Substitution -> [Clause] -> TCM ()

-- | Set <a>funTerminates</a> according to termination info in
--   <a>TCEnv</a>, 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 <tt>with</tt>-function.
data WithFunctionProblem
NoWithFunction :: WithFunctionProblem
WithFunction :: QName -> QName -> Type -> Telescope -> Telescope -> [Term] -> [EqualityView] -> Type -> [NamedArg DeBruijnPattern] -> Nat -> 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 DeBruijnPattern]

-- | Number of module parameters in parent patterns
[wfParentParams] :: WithFunctionProblem -> Nat

-- | 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]

-- | Type check a function clause.
checkClause :: Type -> Maybe Substitution -> SpineClause -> TCM Clause

-- | Type check the <tt>with</tt> and <tt>rewrite</tt> lhss and/or the rhs.
checkRHS :: LHSInfo -> QName -> [NamedArg Pattern] -> Type -> LHSResult -> RHS -> TCM (Maybe Term, WithFunctionProblem)
checkWithRHS :: QName -> QName -> Type -> LHSResult -> [Term] -> [EqualityView] -> [Clause] -> TCM (Maybe Term, WithFunctionProblem)
checkWithFunction :: [Name] -> WithFunctionProblem -> TCM ()

-- | Type check a where clause.
checkWhere :: [Declaration] -> TCM a -> TCM a

-- | Enter a new section during type-checking.
newSection :: ModuleName -> Telescope -> TCM a -> TCM a

-- | Check if a pattern contains an absurd pattern. For instance, <tt>suc
--   ()</tt>
containsAbsurdPattern :: Pattern -> Bool

-- | Set the current clause number.
atClause :: QName -> Int -> RHS -> TCM a -> TCM a

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 ()

-- | <tt>bindPostulatedName builtin e m</tt> checks that <tt>e</tt> is a
--   postulated name <tt>q</tt>, and binds the builtin <tt>builtin</tt> to
--   the term <tt>m q def</tt>, where <tt>def</tt> is the current
--   <a>Definition</a> of <tt>q</tt>.
bindPostulatedName :: String -> Expr -> (QName -> Definition -> TCM Term) -> TCM ()
isUntypedBuiltin :: String -> Bool
bindUntypedBuiltin :: String -> Expr -> TCM ()


-- | Translation from <a>Agda.Syntax.Concrete</a> to
--   <a>Agda.Syntax.Abstract</a>. 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 -> TopLevelModuleName -> a -> TopLevel a

-- | The file path from which we loaded this module.
[topLevelPath] :: TopLevel a -> AbsolutePath

-- | The expected module name (coming from the import statement that
--   triggered scope checking this file).
[topLevelExpectedName] :: TopLevel a -> TopLevelModuleName

-- | 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.PatternVars a => Agda.Syntax.Translation.ConcreteToAbstract.PatternVars [a]
instance Agda.Syntax.Translation.ConcreteToAbstract.PatternVars a => Agda.Syntax.Translation.ConcreteToAbstract.PatternVars (Agda.Syntax.Common.Arg a)
instance Agda.Syntax.Translation.ConcreteToAbstract.PatternVars a => Agda.Syntax.Translation.ConcreteToAbstract.PatternVars (Agda.Syntax.Common.Named n a)
instance Agda.Syntax.Translation.ConcreteToAbstract.PatternVars a => Agda.Syntax.Translation.ConcreteToAbstract.PatternVars (Agda.Syntax.Concrete.FieldAssignment' a)
instance Agda.Syntax.Translation.ConcreteToAbstract.PatternVars (Agda.Syntax.Abstract.Pattern' e)
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 <tt>∞</tt>.
typeOfInf :: TCM Type

-- | The type of <tt>♯_</tt>.
typeOfSharp :: TCM Type

-- | The type of <tt>♭</tt>.
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 ()

-- | Check if there is a inferred eta record type in the mutual block. If
--   yes, repeat the record pattern translation for all function
--   definitions in the block. This is necessary since the original record
--   pattern translation will have skipped record patterns of the new
--   record types (as eta was off for them). See issue 2197).
revisitRecordPatternTranslation :: [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 <a>Definition</a> associated to <a>QName</a>.
--   Makes sense after freezing metas. Some checks, like free variable
--   analysis, are not in <a>TCM</a>, 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_ :: 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 ()

-- | Freeze metas created by given computation if in abstract mode.
whenAbstractFreezeMetasAfter :: DefInfo -> TCM a -> TCM a

-- | Type check an axiom.
checkAxiom :: Axiom -> DefInfo -> ArgInfo -> Maybe [Occurrence] -> 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 <a>checkSectionApplication</a>.
--   
--   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 <i>not</i> 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
--   <tt><a>traceCall</a></tt>).
checkSectionApplication :: ModuleInfo -> ModuleName -> ModuleApplication -> ScopeCopyInfo -> TCM ()

-- | Check an application of a section.
checkSectionApplication' :: ModuleInfo -> ModuleName -> ModuleApplication -> ScopeCopyInfo -> 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 :: Maybe InteractionId -> MetaId -> Expr -> TCM ()

-- | After a give, redo termination etc. checks for function which was
--   complemented.
redoChecks :: Maybe InteractionId -> TCM ()

-- | Try to fill hole by expression.
--   
--   Returns the given expression unchanged (for convenient generalization
--   to <tt><a>refine</a></tt>).
give :: InteractionId -> Maybe Range -> Expr -> TCM Expr

-- | Try to refine hole by expression <tt>e</tt>.
--   
--   This amounts to successively try to give <tt>e</tt>, <tt>e ?</tt>,
--   <tt>e ? ?</tt>, ... 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 :: (Reduce t, Simplify t, Normalise t) => Rewrite -> t -> TCM t
data ComputeMode
DefaultCompute :: ComputeMode
IgnoreAbstract :: ComputeMode
UseShowInstance :: ComputeMode
computeIgnoreAbstract :: ComputeMode -> Bool
computeWrapInput :: ComputeMode -> String -> String
showComputed :: ComputeMode -> Expr -> TCM Doc
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 <a>OutputConstraint</a>.
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
reifyElimToExpr :: Elim -> TCM Expr
showComparison :: Comparison -> String
getConstraints :: TCM [OutputForm Expr Expr]

-- | <tt>getSolvedInteractionPoints True</tt> returns all solutions, even
--   if just solved by another, non-interaction meta.
--   
--   <tt>getSolvedInteractionPoints False</tt> only returns metas that are
--   solved by a non-meta.
getSolvedInteractionPoints :: Bool -> Rewrite -> 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.Classes.Eq Agda.Interaction.BasicOps.ComputeMode
instance GHC.Read.Read Agda.Interaction.BasicOps.ComputeMode
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 <a>envCurrentPath</a> to <tt>optInputFile</tt>.
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' a
NoWarnings :: MaybeWarnings' a
SomeWarnings :: a -> MaybeWarnings' a
type MaybeWarnings = MaybeWarnings' [TCWarning]
applyFlagsToMaybeWarnings :: IgnoreFlags -> MaybeWarnings -> TCM 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,
--   <tt>getInterface'</tt> 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 <a>typeCheckMain</a> instead.
getInterface :: ModuleName -> TCM Interface

-- | See <a>getInterface</a>.
getInterface_ :: TopLevelModuleName -> TCM Interface

-- | A more precise variant of <a>getInterface</a>. If warnings are
--   encountered then they are returned instead of being turned into
--   errors.
getInterface' :: TopLevelModuleName -> MainInterface -> TCM (Interface, MaybeWarnings)

-- | Check whether interface file exists and is in cache in the correct
--   version (as testified by the interface file hash).
isCached :: TopLevelModuleName -> AbsolutePath -> MaybeT TCM Interface

-- | Try to get the interface from interface file or cache.
getStoredInterface :: TopLevelModuleName -> AbsolutePath -> Bool -> TCM (Bool, (Interface, MaybeWarnings))

-- | Run the type checker on a file and create an interface.
--   
--   Mostly, this function calls <a>createInterface</a>. But if it is not
--   the main module we check, we do it in a fresh state, suitably
--   initialize, in order to forget some state changes after successful
--   type checking.
typeCheck :: TopLevelModuleName -> AbsolutePath -> Bool -> TCM (Bool, (Interface, MaybeWarnings))

-- | Formats and outputs the <a>Checking</a>, <a>Finished</a> and
--   <a>Skipping</a> messages.
chaseMsg :: String -> TopLevelModuleName -> Maybe String -> TCM ()

-- | 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.
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 -> Bool -> TCM (Interface, MaybeWarnings)

-- | Collect all warnings that have accumulated in the state. Depending on
--   the argument, we either respect the flags passed in by the user, or
--   not (for instance when deciding if we are writing an interface file or
--   not)
data WhichWarnings
ErrorWarnings :: WhichWarnings

-- | order of constructors important for derived Ord instance
AllWarnings :: WhichWarnings
classifyWarning :: Warning -> WhichWarnings
classifyWarnings :: [TCWarning] -> ([TCWarning], [TCWarning])
getAllWarnings' :: WhichWarnings -> IgnoreFlags -> TCM [TCWarning]
getAllWarnings :: WhichWarnings -> IgnoreFlags -> TCM 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.Classes.Ord Agda.Interaction.Imports.WhichWarnings
instance GHC.Classes.Eq Agda.Interaction.Imports.WhichWarnings
instance Data.Traversable.Traversable Agda.Interaction.Imports.MaybeWarnings'
instance Data.Foldable.Foldable Agda.Interaction.Imports.MaybeWarnings'
instance GHC.Base.Functor Agda.Interaction.Imports.MaybeWarnings'
instance GHC.Show.Show Agda.Interaction.Imports.MainInterface
instance GHC.Classes.Eq Agda.Interaction.Imports.MainInterface
instance Agda.Utils.Null.Null a => Agda.Utils.Null.Null (Agda.Interaction.Imports.MaybeWarnings' a)

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.Show.Show Agda.Compiler.Common.IsMain
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 :: Integral a => a -> 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
emptyBinds :: Maybe Binds

-- | Can the character be used in a Haskell module name part
--   (<tt>conid</tt>)? This function is more restrictive than what the
--   Haskell report allows.
isModChar :: Char -> Bool

module Agda.Compiler.MAlonzo.Encode

-- | Haskell module names have to satisfy the Haskell (including the
--   hierarchical module namespace extension) lexical syntax:
--   
--   <pre>
--   modid -&gt; [modid.] large {small | large | digit | ' }
--   </pre>
--   
--   <a>encodeModuleName</a> is an injective function into the set of
--   module names defined by <tt>modid</tt>. The function preserves
--   <tt>.</tt>s, and it also preserves module names whose first name part
--   is not <a>mazstr</a>.
--   
--   Precondition: The input must not start or end with <tt>.</tt>, and no
--   two <tt>.</tt>s may be adjacent.
encodeModuleName :: ModuleName -> ModuleName

module Agda.Compiler.MAlonzo.Pretty
prettyPrint :: Pretty a => a -> String
prettyWhere :: Maybe Binds -> Doc -> Doc
prettyRhs :: String -> Rhs -> Doc
prettyGuardedRhs :: String -> GuardedRhs -> Doc
isOperator :: QName -> Bool
prettyQName :: QName -> Doc
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.Module
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.ModulePragma
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.ImportDecl
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.ImportSpec
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.Decl
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.ConDecl
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.Match
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.Pat
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.Binds
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.DataOrNew
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.TyVarBind
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.Type
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.Stmt
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.Literal
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.Exp
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.Alt
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.ModuleName
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.QName
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.Name
instance Agda.Utils.Pretty.Pretty Agda.Utils.Haskell.Syntax.QOp

module Agda.Compiler.MAlonzo.Primitives

-- | Check that the main function has type IO a, for some a.
checkTypeOfMain :: QName -> Type -> TCM [Decl] -> TCM [Decl]
treelessPrimName :: TPrim -> String
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
--   <b>UNIT</b> 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 Data.Semigroup.Semigroup Agda.Compiler.UHC.CompileState.CoreMeta
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 -&gt; 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 :: IsMain -> 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 :: IsMain -> TCM Module
definition :: Maybe CoinductionKit -> (QName, Definition) -> TCM (Maybe Export)
definition' :: Maybe CoinductionKit -> QName -> Definition -> Type -> [MemberId] -> TCM (Maybe Export)
compileTerm :: TTerm -> TCM Exp
compilePrim :: TPrim -> Exp
compileAlt :: TAlt -> TCM (MemberId, Exp)
visitorName :: QName -> TCM MemberId
local :: Nat -> Exp
qname :: QName -> TCM Exp
literal :: Literal -> Exp
litqname :: QName -> Exp
writeModule :: Module -> TCM ()
outFile :: GlobalId -> TCM FilePath
outFile_ :: TCM FilePath
copyRTEModules :: TCM ()

-- | Primitives implemented in the JS Agda RTS.
primitives :: Set String

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 <a>CoinductionKit</a> is given):
--   
--   <pre>
--   type Infinity a b = b
--   
--   sharp :: a -&gt; a
--   sharp x = x
--   
--   flat :: a -&gt; a
--   flat x = x
--   </pre>
definition :: Maybe CoinductionKit -> Definition -> TCM [Decl]

-- | Environment for naming of local variables. Invariant: <tt>reverse
--   ccCxt ++ ccNameSupply</tt>
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 <tt>()</tt>. Types are extracted as <tt>()</tt>.
term :: TTerm -> CC Exp
compilePrim :: TPrim -> Exp
alt :: Int -> TAlt -> CC Alt
literal :: Literal -> Exp
hslit :: Literal -> Literal
litString :: String -> Exp
litqname :: QName -> Exp
litqnamepat :: QName -> Pat
erasedArity :: QName -> TCM Nat
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 => 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

-- | Parse variables (visible or hidden), returning their de Bruijn
--   indices. Used in <a>makeCase</a>.
parseVariables :: QName -> Telescope -> InteractionId -> Range -> [String] -> TCM [Int]

-- | Lookup the clause for an interaction point in the signature. Returns
--   the CaseContext, the clause itself, and a list of previous clauses
getClauseForIP :: QName -> Int -> TCM (CaseContext, Clause, [Clause])

-- | Entry point for case splitting tactic.
makeCase :: InteractionId -> Range -> String -> TCM (QName, CaseContext, [Clause])

-- | Mark the variables given by the list of deBruijn indices as
--   <a>UserWritten</a> in the <a>SplitClause</a>.
makePatternVarsVisible :: [Nat] -> SplitClause -> SplitClause

-- | Make clause with no rhs (because of absurd match).
makeAbsurdClause :: QName -> SplitClause -> TCM Clause

-- | Make a clause with a question mark as rhs.
makeAbstractClause :: QName -> RHS -> SplitClause -> TCM Clause

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 <a>mcompoint</a>. 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.
--   
--   <tt>a</tt> the type of the metavariable (what it can be instantiated
--   with). <tt>blk</tt> 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 <tt>blk</tt> parameter in <a>Metavar</a>.
--   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

-- | <tt>Hiding</tt> 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

-- | <tt>True</tt> if possibly dependent (var not known to not occur).
--   <tt>False</tt> 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 <a>ICArgList</a>. 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 <tt>a</tt> in an explicit substitution <tt>[CAction
--   a]</tt>.
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 <tt>CAction</tt>s. This is
--   isomorphic to the usual presentation where <tt>Skip</tt> and
--   <tt>Weak</tt> would be constructors of exp. substs.
data CAction o

-- | Instantation of variable.
Sub :: (ICExp o) -> CAction o

-- | For going under a binder, often called <a>Lift</a>.
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)
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
freeIn :: Nat -> MExp o -> Bool
negtype :: ConstRef o -> MExp o -> MExp o
findClauseDeep :: InteractionId -> 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).
--   
--   <pre>
--   auto ii rng s = return (res, mmsg)
--   </pre>
--   
--   If <tt>mmsg = Just msg</tt>, the message <tt>msg</tt> produced by Agsy
--   should be displayed to the user.
--   
--   The result <tt>res</tt> of the Auto tactic can be one of the following
--   three:
--   
--   <ol>
--   <li><tt>Left [(ii,s)]</tt> A list of solutions <tt>s</tt> for
--   interaction ids <tt>ii</tt>. In particular, <tt>Left []</tt> means
--   Agsy found no solution.</li>
--   <li><tt>Right (Left cs)</tt> A list of clauses (the user allowed
--   case-split).</li>
--   <li><tt>Right (Right s)</tt> A refinement for the interaction id
--   <tt>ii</tt> in which Auto was invoked.</li>
--   </ol>
auto :: InteractionId -> Range -> String -> TCM (Either [(InteractionId, String)] (Either [String] String), Maybe String)

module Agda.Interaction.InteractionTop

-- | Auxiliary state of an interactive computation.
data CommandState
CommandState :: [InteractionId] -> Maybe (AbsolutePath, ClockTime) -> CommandLineOptions -> !OldInteractionScopes -> CommandState

-- | The interaction points of the buffer, in the order in which they
--   appear in the buffer. The interaction points are recorded in
--   <tt>theTCState</tt>, but when new interaction points are added by give
--   or refine Agda does not ensure that the ranges of later interaction
--   points are updated.
[theInteractionPoints] :: CommandState -> [InteractionId]

-- | The file which the state applies to. Only stored if the module was
--   successfully type checked (potentially with warnings). The
--   <a>ClockTime</a> is the modification time stamp of the file when it
--   was last loaded.
[theCurrentFile] :: CommandState -> Maybe (AbsolutePath, ClockTime)

-- | Reset the options on each reload to these.
[optionsOnReload] :: CommandState -> CommandLineOptions

-- | We remember (the scope of) old interaction points to make it possible
--   to parse and compute highlighting information for the expression that
--   it got replaced by.
[oldInteractionScopes] :: CommandState -> !OldInteractionScopes
type OldInteractionScopes = Map InteractionId ScopeInfo

-- | Initial auxiliary interaction state
initCommandState :: CommandState

-- | Monad for computing answers to interactive commands.
--   
--   <a>CommandM</a> is <a>TCM</a> extended with state <a>CommandState</a>.
type CommandM = StateT CommandState TCM

-- | Restore both <a>TCState</a> and <a>CommandState</a>.
localStateCommandM :: CommandM a -> CommandM a

-- | Restore <a>TCState</a>, do not touch <a>CommandState</a>.
liftLocalState :: TCM a -> CommandM a

-- | Build an opposite action to <a>lift</a> for state monads.
revLift :: MonadState st m => (forall c. m c -> st -> k (c, st)) -> (forall b. k b -> m b) -> (forall x. (m a -> k x) -> k x) -> m a

-- | Opposite of <a>liftIO</a> for <a>CommandM</a>. Use only if main errors
--   are already catched.
commandMToIO :: (forall x. (CommandM a -> IO x) -> IO x) -> CommandM a

-- | Lift a TCM action transformer to a CommandM action transformer.
liftCommandMT :: (forall a. TCM a -> TCM a) -> CommandM a -> CommandM a

-- | Ditto, but restore state.
liftCommandMTLocalState :: (forall a. TCM a -> TCM a) -> CommandM a -> CommandM a

-- | Put a response by the callback function given by
--   <a>stInteractionOutputCallback</a>.
putResponse :: Response -> CommandM ()

-- | A Lens for <a>theInteractionPoints</a>.
modifyTheInteractionPoints :: ([InteractionId] -> [InteractionId]) -> CommandM ()

-- | A Lens for <a>oldInteractionScopes</a>.
modifyOldInteractionScopes :: (OldInteractionScopes -> OldInteractionScopes) -> CommandM ()
insertOldInteractionScope :: InteractionId -> ScopeInfo -> CommandM ()
removeOldInteractionScope :: InteractionId -> CommandM ()
getOldInteractionScope :: InteractionId -> CommandM ScopeInfo

-- | Do setup and error handling for a command.
handleCommand_ :: CommandM () -> CommandM ()
handleCommand :: (forall a. CommandM a -> CommandM a) -> CommandM () -> CommandM () -> CommandM ()

-- | Run an <a>IOTCM</a> value, catch the exceptions, emit output
--   
--   If an error happens the state of <a>CommandM</a> does not change, but
--   stPersistent may change (which contains successfully loaded interfaces
--   for example).
runInteraction :: IOTCM -> CommandM ()

-- | An interactive computation.
type Interaction = Interaction' Range
data Interaction' range

-- | <tt>cmd_load m argv</tt> loads the module in file <tt>m</tt>, using
--   <tt>argv</tt> as the command-line options.
Cmd_load :: FilePath -> [String] -> Interaction' range

-- | <tt>cmd_compile b m argv</tt> compiles the module in file <tt>m</tt>
--   using the backend <tt>b</tt>, using <tt>argv</tt> as the command-line
--   options.
Cmd_compile :: Backend -> FilePath -> [String] -> Interaction' range
Cmd_constraints :: Interaction' range

-- | Show unsolved metas. If there are no unsolved metas but unsolved
--   constraints show those instead.
Cmd_metas :: Interaction' range

-- | Display all warnings.
Cmd_warnings :: Interaction' range

-- | Shows all the top-level names in the given module, along with their
--   types. Uses the top-level scope.
Cmd_show_module_contents_toplevel :: Rewrite -> String -> Interaction' range

-- | Shows all the top-level names in scope which mention all the given
--   identifiers in their type.
Cmd_search_about_toplevel :: Rewrite -> String -> Interaction' range

-- | Solve (all goals / the goal at point) whose values are determined by
--   the constraints.
Cmd_solveAll :: Rewrite -> Interaction' range
Cmd_solveOne :: Rewrite -> InteractionId -> range -> String -> Interaction' range

-- | Parse the given expression (as if it were defined at the top-level of
--   the current module) and infer its type.
Cmd_infer_toplevel :: Rewrite -> String -> Interaction' range

-- | Parse and type check the given expression (as if it were defined at
--   the top-level of the current module) and normalise it.
Cmd_compute_toplevel :: ComputeMode -> String -> Interaction' range

-- | <tt>cmd_load_highlighting_info source</tt> loads syntax highlighting
--   information for the module in <tt>source</tt>, and asks Emacs to apply
--   highlighting info from this file.
--   
--   If the module does not exist, or its module name is malformed or
--   cannot be determined, or the module has not already been visited, or
--   the cached info is out of date, then no highlighting information is
--   printed.
--   
--   This command is used to load syntax highlighting information when a
--   new file is opened, and it would probably be annoying if jumping to
--   the definition of an identifier reset the proof state, so this command
--   tries not to do that. One result of this is that the command uses the
--   current include directories, whatever they happen to be.
Cmd_load_highlighting_info :: FilePath -> Interaction' range

-- | Tells Agda to compute highlighting information for the expression just
--   spliced into an interaction point.
Cmd_highlight :: InteractionId -> range -> String -> Interaction' range

-- | Tells Agda whether or not to show implicit arguments.
ShowImplicitArgs :: Bool -> Interaction' range

-- | Toggle display of implicit arguments.
ToggleImplicitArgs :: Interaction' range

-- | Goal commands
--   
--   If the range is <a>noRange</a>, then the string comes from the
--   minibuffer rather than the goal.
Cmd_give :: InteractionId -> range -> String -> Interaction' range
Cmd_refine :: InteractionId -> range -> String -> Interaction' range
Cmd_intro :: Bool -> InteractionId -> range -> String -> Interaction' range
Cmd_refine_or_intro :: Bool -> InteractionId -> range -> String -> Interaction' range
Cmd_auto :: InteractionId -> range -> String -> Interaction' range
Cmd_context :: Rewrite -> InteractionId -> range -> String -> Interaction' range
Cmd_helper_function :: Rewrite -> InteractionId -> range -> String -> Interaction' range
Cmd_infer :: Rewrite -> InteractionId -> range -> String -> Interaction' range
Cmd_goal_type :: Rewrite -> InteractionId -> range -> String -> Interaction' range

-- | Displays the current goal and context.
Cmd_goal_type_context :: Rewrite -> InteractionId -> range -> String -> Interaction' range

-- | Displays the current goal and context <i>and</i> infers the type of an
--   expression.
Cmd_goal_type_context_infer :: Rewrite -> InteractionId -> range -> String -> Interaction' range

-- | Shows all the top-level names in the given module, along with their
--   types. Uses the scope of the given goal.
Cmd_show_module_contents :: Rewrite -> InteractionId -> range -> String -> Interaction' range
Cmd_make_case :: InteractionId -> range -> String -> Interaction' range
Cmd_compute :: ComputeMode -> InteractionId -> range -> String -> Interaction' range
Cmd_why_in_scope :: InteractionId -> range -> String -> Interaction' range
Cmd_why_in_scope_toplevel :: String -> Interaction' range

-- | Displays version of the running Agda
Cmd_show_version :: Interaction' range
type IOTCM = IOTCM' Range
data IOTCM' range
IOTCM :: FilePath -> HighlightingLevel -> HighlightingMethod -> (Interaction' range) -> IOTCM' range

-- | The <a>Parse</a> monad. <a>StateT</a> state holds the remaining input.
type Parse a = ExceptT String (StateT String Identity) a

-- | Converter from the type of <a>reads</a> to <a>Parse</a> The first
--   paramter is part of the error message in case the parse fails.
readsToParse :: String -> (String -> Maybe (a, String)) -> Parse a
parseToReadsPrec :: Parse a -> Int -> String -> [(a, String)]

-- | Demand an exact string.
exact :: String -> Parse ()
readParse :: Read a => Parse a
parens' :: Parse a -> Parse a

-- | Note that the grammar implemented by this instance does not
--   necessarily match the current representation of ranges.

-- | Can the command run even if the relevant file has not been loaded into
--   the state?
independent :: Interaction -> Bool

-- | Interpret an interaction
interpret :: Interaction -> CommandM ()

-- | Show warnings
interpretWarnings :: CommandM (String, String)

-- | Solved goals already instantiated internally The second argument
--   potentially limits it to one specific goal.
solveInstantiatedGoals :: Rewrite -> Maybe InteractionId -> CommandM ()

-- | Print open metas nicely.
showOpenMetas :: TCM [String]

-- | <tt>cmd_load' file argv unsolvedOk cmd</tt> loads the module in file
--   <tt>file</tt>, using <tt>argv</tt> as the command-line options.
--   
--   If type checking completes without any exceptions having been
--   encountered then the command <tt>cmd r</tt> is executed, where
--   <tt>r</tt> is the result of <a>typeCheckMain</a>.
cmd_load' :: FilePath -> [String] -> Bool -> ((Interface, MaybeWarnings) -> CommandM ()) -> CommandM ()

-- | Set <a>envCurrentPath</a> to <a>theCurrentFile</a>, if any.
withCurrentFile :: CommandM a -> CommandM a

-- | Available backends.
data Backend
GHC :: Backend
GHCNoMain :: Backend
JS :: Backend
LaTeX :: Backend
data GiveRefine
Give :: GiveRefine
Refine :: GiveRefine
Intro :: GiveRefine

-- | A "give"-like action (give, refine, etc).
--   
--   <tt>give_gen ii rng s give_ref mk_newtxt</tt> acts on interaction
--   point <tt>ii</tt> occupying range <tt>rng</tt>, placing the new
--   content given by string <tt>s</tt>, and replacing <tt>ii</tt> by the
--   newly created interaction points in the state.
give_gen :: InteractionId -> Range -> String -> GiveRefine -> CommandM ()
highlightExpr :: Expr -> TCM ()

-- | Sorts interaction points based on their ranges.
sortInteractionPoints :: [InteractionId] -> TCM [InteractionId]

-- | Pretty-prints the type of the meta-variable.
prettyTypeOfMeta :: Rewrite -> InteractionId -> TCM Doc

-- | Pretty-prints the context of the given meta-variable.
prettyContext :: Rewrite -> Bool -> InteractionId -> TCM Doc

-- | Create type of application of new helper function that would solve the
--   goal.
cmd_helper_function :: Rewrite -> InteractionId -> Range -> String -> TCM Doc

-- | Displays the current goal, the given document, and the current
--   context.
--   
--   Should not modify the state.
cmd_goal_type_context_and :: Doc -> Rewrite -> InteractionId -> Range -> String -> StateT CommandState (TCMT IO) ()

-- | Shows all the top-level names in the given module, along with their
--   types.
showModuleContents :: Rewrite -> Range -> String -> CommandM ()

-- | Shows all the top-level names in scope which mention all the given
--   identifiers in their type.
searchAbout :: Rewrite -> Range -> String -> CommandM ()

-- | Explain why something is in scope.
whyInScope :: String -> CommandM ()

-- | Sets the command line options and updates the status information.
setCommandLineOpts :: CommandLineOptions -> CommandM ()

-- | Computes some status information.
--   
--   Does not change the state.
status :: CommandM Status

-- | Displays or updates status information.
--   
--   Does not change the state.
displayStatus :: CommandM ()

-- | <tt>display_info</tt> does what <tt><tt>display_info'</tt> False</tt>
--   does, but additionally displays some status information (see
--   <a>status</a> and <a>displayStatus</a>).
display_info :: DisplayInfo -> CommandM ()
refreshStr :: [String] -> String -> ([String], String)
nameModifiers :: [String]

-- | Parses and scope checks an expression (using the "inside scope" as the
--   scope), performs the given command with the expression as input, and
--   displays the result.
parseAndDoAtToplevel' :: (Expr -> TCM Doc) -> (Doc -> DisplayInfo) -> String -> CommandM ()
parseAndDoAtToplevel :: (Expr -> TCM Expr) -> (Doc -> DisplayInfo) -> String -> CommandM ()
maybeTimed :: CommandM a -> CommandM (Maybe Doc, a)

-- | Tell to highlight the code using the given highlighting info (unless
--   it is <tt>Nothing</tt>).
tellToUpdateHighlighting :: Maybe (HighlightingInfo, ModuleToSource) -> IO [Response]

-- | Tells the Emacs mode to go to the first error position (if any).
tellEmacsToJumpToError :: Range -> [Response]
instance GHC.Show.Show Agda.Interaction.InteractionTop.GiveRefine
instance GHC.Classes.Eq Agda.Interaction.InteractionTop.GiveRefine
instance Data.Traversable.Traversable Agda.Interaction.InteractionTop.IOTCM'
instance Data.Foldable.Foldable Agda.Interaction.InteractionTop.IOTCM'
instance GHC.Base.Functor Agda.Interaction.InteractionTop.IOTCM'
instance GHC.Read.Read range => GHC.Read.Read (Agda.Interaction.InteractionTop.IOTCM' range)
instance Data.Traversable.Traversable Agda.Interaction.InteractionTop.Interaction'
instance Data.Foldable.Foldable Agda.Interaction.InteractionTop.Interaction'
instance GHC.Base.Functor Agda.Interaction.InteractionTop.Interaction'
instance GHC.Read.Read range => GHC.Read.Read (Agda.Interaction.InteractionTop.Interaction' range)
instance GHC.Classes.Eq Agda.Interaction.InteractionTop.Backend
instance GHC.Read.Read Agda.Interaction.InteractionTop.Backend
instance GHC.Show.Show Agda.Interaction.InteractionTop.Backend
instance GHC.Read.Read Agda.Syntax.Common.InteractionId
instance GHC.Read.Read a => GHC.Read.Read (Agda.Syntax.Position.Range' a)
instance GHC.Read.Read a => GHC.Read.Read (Agda.Syntax.Position.Interval' a)
instance GHC.Read.Read Agda.Utils.FileName.AbsolutePath
instance GHC.Read.Read a => GHC.Read.Read (Agda.Syntax.Position.Position' a)

module Agda.Interaction.EmacsTop

-- | <a>mimicGHCi</a> is a fake ghci interpreter for the Emacs frontend and
--   for interaction tests.
--   
--   <a>mimicGHCi</a> reads the Emacs frontend commands from stdin,
--   interprets them and print the result into stdout.
mimicGHCi :: TCM () -> TCM ()


-- | Agda main module.
module Agda.Main

-- | The main function
runAgda :: TCM ()

-- | Run Agda with parsed command line options and with a custom HTML
--   generator
runAgdaWithOptions :: TCM () -> String -> CommandLineOptions -> TCM ()

-- | Print usage information.
printUsage :: IO ()

-- | Print version information.
printVersion :: IO ()

-- | What to do for bad options.
optionError :: String -> IO ()

-- | Run a TCM action in IO; catch and pretty print errors.
runTCMPrettyErrors :: TCM () -> IO ()

-- | Main
main :: IO ()
