-- 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.
--   
--   Note that if you want to use the command-line program (agda), then you
--   should also install the Agda-executable package. The Agda package
--   includes an Emacs mode for Agda, but you need to set up the Emacs mode
--   yourself (for instance by running <tt>agda-mode setup</tt>; see the
--   README).
--   
--   Note also that this library does not follow the package versioning
--   policy, because the library is only intended to be used by the Emacs
--   mode and the Agda-executable package.
@package Agda
@version 2.3.0.1


-- | Wrappers for <a>IORef</a>s.
module Agda.Utils.Pointer
type Ptr a = IORef a
deref :: MonadIO io => Ptr a -> io a
store :: MonadIO io => Ptr a -> a -> io ()
alloc :: MonadIO io => a -> io (Ptr a)
updatePtr :: MonadIO io => Ptr a -> (a -> io a) -> io a

module Agda.Utils.SemiRing
class SemiRing a
oplus :: SemiRing a => a -> a -> a
otimes :: SemiRing a => a -> a -> a
instance SemiRing a => SemiRing (Maybe a)

module Agda.Utils.Graph
newtype Graph n e
Graph :: Map n (Map n e) -> Graph n e
unGraph :: Graph n e -> Map n (Map n e)
edges :: Ord n => Graph n e -> [(n, n, e)]
nodes :: Ord n => Graph n e -> Set n
fromList :: (SemiRing e, Ord n) => [(n, n, e)] -> Graph n e
empty :: Graph n e
singleton :: n -> n -> e -> Graph n e
insert :: (SemiRing e, Ord n) => n -> n -> e -> Graph n e -> Graph n e
union :: (SemiRing e, Ord n) => Graph n e -> Graph n e -> Graph n e
unions :: (SemiRing e, Ord n) => [Graph n e] -> Graph n e
lookup :: Ord n => n -> n -> Graph n e -> Maybe e
neighbours :: Ord n => n -> Graph n e -> [(n, e)]
growGraph :: (SemiRing e, Ord n) => Graph n e -> Graph n e
transitiveClosure :: (Eq e, SemiRing e, Ord n) => Graph n e -> Graph n e
findPath :: (SemiRing e, Ord n) => (e -> Bool) -> n -> n -> Graph n e -> Maybe e
allPaths :: (SemiRing e, Ord n, Ord c) => (e -> c) -> n -> n -> Graph n e -> [e]
instance (Eq n, Eq e) => Eq (Graph n e)
instance Functor (Graph n)

module Agda.Utils.Hash
hash :: String -> Integer


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

-- | <i>O(n+m)</i>. The union of two sets, preferring the first set when
--   equal elements are encountered. The implementation uses the efficient
--   <i>hedge-union</i> algorithm. Hedge-union is more efficient on (bigset
--   <a>union</a> smallset).
union :: Ord a => Set a -> Set a -> Set a

-- | The union of a list of sets: (<tt><a>unions</a> == <a>foldl</a>
--   <a>union</a> <a>empty</a></tt>).
unions :: Ord a => [Set a] -> Set a

-- | <i>O(log n)</i>. Is the element in the set?
member :: Ord a => a -> Set a -> Bool

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

-- | <i>O(log n)</i>. Delete an element from a set.
delete :: Ord a => a -> Set a -> Set a

-- | <i>O(1)</i>. Create a singleton set.
singleton :: a -> Set a

-- | <i>O(n*log n)</i>. Create a set from a list of elements.
fromList :: Ord a => [a] -> Set a

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

-- | <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 :: Ord a => Set a -> Set a -> Bool
subtract :: Integer -> VarSet -> VarSet

module Agda.Utils.Maybe
fromMaybeM :: Monad m => m a -> m (Maybe a) -> m a

module Agda.Utils.Char
decDigit :: Char -> Int
hexDigit :: Char -> Int
octDigit :: Char -> Int

module Agda.Utils.Unicode
isUnicodeId :: Char -> Bool

-- | Converts many character sequences which may be interpreted as line or
--   paragraph separators into '\n'.
convertLineEndings :: String -> String

module Agda.Utils.Suffix
data Suffix
NoSuffix :: Suffix
Prime :: Int -> Suffix
Index :: Int -> Suffix
nextSuffix :: Suffix -> Suffix
suffixView :: String -> (String, Suffix)
addSuffix :: String -> Suffix -> String


-- | Binary IO.
module Agda.Utils.IO.Binary

-- | Returns a close function for the file together with the contents.
readBinaryFile' :: FilePath -> IO (ByteString, IO ())


-- | Contains some generic utility functions and reexports certain
--   definitions from <a>Data.Generics</a>.
module Agda.Utils.Generics
isString :: GenericQ Bool
everythingBut :: (r -> r -> r) -> GenericQ Bool -> GenericQ r -> GenericQ r

-- | Same as everywhereBut except that when the stop condition becomes
--   true, the function is called on the top level term (but not on the
--   children).
everywhereBut' :: GenericQ Bool -> GenericT -> GenericT
everywhereButM' :: Monad m => GenericQ Bool -> GenericM m -> GenericM m

module Agda.Packaging.Types

module Agda.Packaging.Monad

module Agda.Packaging.Database

module Agda.Packaging.Config

module Agda.Utils.QuickCheck
isSuccess :: Result -> Bool
quickCheck' :: Testable prop => prop -> IO Bool
quickCheckWith' :: Testable prop => Args -> prop -> IO Bool


module Agda.Utils.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

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

-- | 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 MonadPlus (ReadP t)
instance Monad (ReadP t)
instance Functor (ReadP t)
instance MonadPlus (P t)
instance Monad (P t)

module Agda.Utils.Function

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


-- | 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.
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.Tuple
(-*-) :: (a -> c) -> (b -> d) -> (a, b) -> (c, d)
(/\) :: (a -> b) -> (a -> c) -> a -> (b, c)
uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d

module Agda.Utils.Trie
data Trie k v
empty :: Trie k v
singleton :: [k] -> v -> Trie k v
insert :: Ord k => [k] -> v -> Trie k v -> Trie k v
lookupPath :: Ord k => [k] -> Trie k v -> [v]

-- | Left biased union.
union :: Ord k => Trie k v -> Trie k v -> Trie k v
instance (Show k, Show v) => Show (Trie k v)
instance Eq Key
instance Ord Key
instance Eq Val
instance Eq Model
instance Show Model
instance Arbitrary Model
instance Arbitrary Val
instance Arbitrary Key
instance Show Val
instance Show Key

module Agda.Utils.String

-- | <a>quote</a> adds double quotes around the string, 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


-- | A common interface for monads which allow some kind of fresh name
--   generation.
module Agda.Utils.Fresh
class HasFresh i a
nextFresh :: HasFresh i a => a -> (i, a)
fresh :: (HasFresh i s, MonadState s m) => m i
withFresh :: (HasFresh i e, MonadReader e m) => (i -> m a) -> m a

module Agda.Utils.Size
class Sized a
size :: (Sized a, Integral n) => a -> n
instance Sized a => Sized (Maybe a)
instance Sized (Set a)
instance Sized (Map k a)
instance Sized [a]


-- | 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 Typeable Impossible
instance Exception Impossible
instance Show Impossible

module Agda.ImpossibleTest
impossibleTest :: a

module Agda.Utils.Permutation

-- | <pre>
--   permute [2,3,1] [x,y,z] = [y,z,x]
--   </pre>
data Permutation
Perm :: Integer -> [Integer] -> Permutation

-- | <tt>permute [2,3,1] [x1,x2,x3] = [x2,x3,x1]</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 [2,4,1] [x1,x2,x3,x4] = [x2,x4,x1]</tt>
permute :: Permutation -> [a] -> [a]
idP :: Integer -> Permutation
takeP :: Integer -> Permutation -> Permutation

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

-- | Turn a possible non-surjective permutation into a surjective
--   permutation.
compactP :: Permutation -> Permutation
reverseP :: 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 :: Integer -> Integer -> 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
instance Typeable Permutation
instance Eq Permutation
instance Data Permutation
instance Sized Permutation
instance Show Permutation

module Agda.Auto.NarrowingSearch
type Prio = Int
class Trav a blk | a -> blk
traverse :: (Trav a blk, Monad m) => (forall b. Trav b blk => MM b blk -> m ()) -> a -> m ()
data Term blk
Term :: a -> Term blk
data Prop blk
OK :: Prop blk
Error :: String -> Prop blk
AddExtraRef :: String -> (Metavar a blk) -> (Int, RefCreateEnv blk a) -> Prop blk
And :: (Maybe [Term blk]) -> (MetaEnv (PB blk)) -> (MetaEnv (PB blk)) -> Prop blk
Sidecondition :: (MetaEnv (PB blk)) -> (MetaEnv (PB blk)) -> Prop blk
Or :: Prio -> (MetaEnv (PB blk)) -> (MetaEnv (PB blk)) -> Prop blk
ConnectHandle :: (OKHandle blk) -> (MetaEnv (PB blk)) -> Prop blk
data OKVal
OKVal :: OKVal
type OKHandle blk = MM OKVal blk
type OKMeta blk = Metavar OKVal blk
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
mbind :: Metavar a blk -> IORef (Maybe a)
mprincipalpresent :: Metavar a blk -> IORef Bool
mobs :: Metavar a blk -> IORef [(QPB a blk, Maybe (CTree blk))]
mcompoint :: Metavar a blk -> IORef [SubConstraints blk]
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 | 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 :: Refinable a blk => 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 :: 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 :: 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 Refinable OKVal blk
instance Refinable Choice blk
instance Eq (PrioMeta blk)
instance Eq (Metavar a blk)
instance Trav a blk => Trav (MM a blk) blk

module Agda.Auto.Syntax
type UId o = Metavar (Exp o) (RefInfo o)
data HintMode
HMNormal :: HintMode
HMRecCall :: HintMode
data EqReasoningConsts o
EqReasoningConsts :: ConstRef o -> ConstRef o -> ConstRef o -> ConstRef o -> ConstRef o -> ConstRef o -> EqReasoningConsts o
eqrcId :: EqReasoningConsts o -> ConstRef o
eqrcBegin :: EqReasoningConsts o -> ConstRef o
eqrcStep :: EqReasoningConsts o -> ConstRef o
eqrcEnd :: EqReasoningConsts o -> ConstRef o
eqrcSym :: EqReasoningConsts o -> ConstRef o
eqrcCong :: EqReasoningConsts o -> ConstRef o
data EqReasoningState
EqRSNone :: EqReasoningState
EqRSChain :: EqReasoningState
EqRSPrf1 :: EqReasoningState
EqRSPrf2 :: EqReasoningState
EqRSPrf3 :: EqReasoningState
data RefInfo o
RIEnv :: [(ConstRef o, HintMode)] -> Nat -> Maybe (EqReasoningConsts o) -> RefInfo o
rieHints :: RefInfo o -> [(ConstRef o, HintMode)]
rieDefFreeVars :: RefInfo o -> Nat
rieEqReasoningConsts :: RefInfo o -> Maybe (EqReasoningConsts o)
RIMainInfo :: Nat -> (HNExp o) -> Bool -> RefInfo o
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
data FMode
Hidden :: FMode
Instance :: FMode
NotHidden :: FMode
data MId
Id :: String -> MId
NoId :: MId
data Abs a
Abs :: MId -> a -> Abs a
data ConstDef o
ConstDef :: String -> o -> MExp o -> DeclCont o -> Nat -> ConstDef o
cdname :: ConstDef o -> String
cdorigin :: ConstDef o -> o
cdtype :: ConstDef o -> MExp o
cdcont :: ConstDef o -> DeclCont o
cddeffreevars :: ConstDef o -> Nat
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
PatExp :: Pat o
type ConstRef o = IORef (ConstDef o)
data Elr o
Var :: Nat -> Elr o
Const :: (ConstRef o) -> Elr o
data Sort
Set :: Nat -> Sort
UnknownSort :: Sort
Type :: Sort
data Exp o
App :: (Maybe (UId o)) -> (OKHandle (RefInfo o)) -> (Elr o) -> (MArgList o) -> Exp o
Lam :: FMode -> (Abs (MExp o)) -> Exp o
Pi :: (Maybe (UId o)) -> FMode -> Bool -> (MExp o) -> (Abs (MExp o)) -> Exp o
Sort :: Sort -> Exp o
AbsurdLambda :: FMode -> Exp o
dontCare :: Exp o
type MExp o = MM (Exp o) (RefInfo o)
data ArgList o
ALNil :: ArgList o
ALCons :: FMode -> (MExp o) -> (MArgList o) -> ArgList o
ALProj :: (MArgList o) -> (MM (ConstRef o) (RefInfo o)) -> FMode -> (MArgList o) -> ArgList o
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
data HNArgList o
HNALNil :: HNArgList o
HNALCons :: FMode -> (ICExp o) -> (ICArgList o) -> HNArgList o
HNALConPar :: (ICArgList o) -> HNArgList o
type ICExp o = Clos (MExp o) o
type CExp o = TrBr (ICExp o) o
data ICArgList o
CALNil :: ICArgList o
CALConcat :: (Clos (MArgList o) o) -> (ICArgList o) -> ICArgList o
data Clos a o
Clos :: [CAction o] -> a -> Clos a o
data TrBr a o
TrBr :: [MExp o] -> a -> TrBr a o
data CAction o
Sub :: (ICExp o) -> CAction o
Skip :: CAction o
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
doclos :: [CAction o] -> Nat -> Either Nat (ICExp o)
instance Eq EqReasoningState
instance Show EqReasoningState
instance Eq FMode

module Agda.Auto.SearchControl
data ExpRefInfo o
ExpRefInfo :: Maybe (RefInfo o) -> [RefInfo o] -> Bool -> 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 :: ExpRefInfo o -> Bool
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))
costIotaStep :: Int
costIncrease :: Int
costAppExtraRef :: Int
costUnificationOccurs :: Int
costUnification :: Int
costAppVar :: Int
costAppVarUsed :: Int
costAppHint :: Int
costAppHintUsed :: Int
costAppRecCall :: Int
costAppRecCallUsed :: Int
costAppConstructor :: Int
costAppConstructorSingle :: Int
costLam :: Int
costLamUnfold :: Int
costPi :: Int
costSort :: Int
costInferredTypeUnkown :: Int
costAbsurdLam :: Int
costEqStep :: Int
costEqEnd :: Int
costEqSym :: Int
costEqCong :: Int
prioNo :: Int
prioAbsurdLambda :: Int
prioNoIota :: Int
prioCompCopy :: Int
prioCompUnif :: Int
prioCompChoice :: Int
prioCompIota :: Int
prioCompareArgList :: Int
prioCompBetaStructured :: Int
prioCompBeta :: Int
prioInferredTypeUnknown :: Int
prioTypecheckArgList :: Int
prioTypeUnknown :: Int
prioTypecheck :: Num a => Bool -> a
prioProjIndex :: Int
instance Trav (ArgList o) (RefInfo o)
instance Trav (Exp o) (RefInfo o)
instance Trav (TrBr a o) (RefInfo o)
instance Trav (MId, CExp o) (RefInfo o)
instance Trav a blk => Trav [a] blk
instance Refinable (ConstRef o) (RefInfo o)
instance Refinable (ICExp o) (RefInfo o)
instance Refinable (Exp o) (RefInfo o)
instance Refinable (ArgList o) (RefInfo o)

module Agda.Auto.Typecheck
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) t -> MM (Exp o) blk
copyarg :: t -> Bool
type HNNBlks o = [HNExp o]
noblks :: [a]
addblk :: a -> [a] -> [a]
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' :: Bool -> CExp o -> CExp o -> EE (MyPB o)
checkeliminand :: MExp o -> EE (MyPB o)
maybeor :: t -> t1 -> t2 -> t3 -> t2
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 :: [Char]
costCaseSplitVeryHigh :: Int
costCaseSplitHigh :: Int
costCaseSplitLow :: Int
costAddVarDepth :: Int
data HI a
HI :: FMode -> a -> HI a
drophid :: [HI b] -> [b]
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 :: IORef Int -> Int -> [ConstRef o] -> Maybe (EqReasoningConsts o) -> Int -> Int -> ConstRef o -> CSCtx o -> MExp o -> [CSPat o] -> IO [Sol o]
caseSplitSearch' :: (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 :: Eq a => [a] -> a -> 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.Version

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


-- | Pretty printing functions.
module Agda.Utils.Pretty
class Pretty a where pretty = prettyPrec 0 prettyPrec = const pretty
pretty :: Pretty a => a -> Doc
prettyPrec :: Pretty a => Int -> 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
instance Pretty Doc


-- | IO functions which are used when reading from standard input and
--   writing to standard output. Uses the UTF-8 character encoding under
--   versions of the base library up to 4.1, and whatever the locale
--   specifies under base 4.2 (and later?; only if the locale is supported,
--   see <a>System.IO</a>).
--   
--   Note that <tt>hSetEncoding</tt> can be used to change the behaviour of
--   the functions below if base 4.2 (or later?) is used.
module Agda.Utils.IO.Locale

-- | Prints the value.
print :: Show a => a -> IO ()

-- | Prints the string.
putStr :: String -> IO ()

-- | Prints the string with an appended newline.
putStrLn :: String -> IO ()
stdoutFlush :: IO ()

-- | Returns the stream represented by the handle lazily.
hGetContents :: Handle -> IO String


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

-- | Writes a response command to standard output.
putResponse :: Lisp String -> IO ()
instance Pretty a => Show (Lisp a)
instance Pretty String
instance Pretty a => Pretty (Lisp a)


-- | Some functions and generators suitable for writing QuickCheck
--   properties.
module Agda.Utils.TestHelpers

-- | Is the operator associative?
associative :: (Arbitrary a, Eq a, Show a) => (a -> a -> a) -> a -> a -> a -> Bool

-- | Is the operator commutative?
commutative :: (Arbitrary a, Eq a, Show a) => (a -> a -> a) -> a -> a -> Bool

-- | Is the element a zero for the operator?
isZero :: (Arbitrary a, Eq a, Show a) => a -> (a -> a -> a) -> a -> Bool

-- | Is the element a unit for the operator?
identity :: (Arbitrary a, Eq a, Show a) => a -> (a -> a -> a) -> a -> Bool

-- | Does the first operator distribute (from the left) over the second
--   one?
leftDistributive :: (Arbitrary a, Eq a, Show a) => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Bool

-- | Does the first operator distribute (from the right) over the second
--   one?
rightDistributive :: (Arbitrary a, Eq a, Show a) => (a -> a -> a) -> (a -> a -> a) -> a -> a -> a -> Bool

-- | Generates natural numbers.
natural :: Integral i => Gen i

-- | Generates positive numbers.
positive :: Integral i => Gen i

-- | Generates values of <a>Maybe</a> type, using the given generator to
--   generate the contents of the <a>Just</a> constructor.
maybeGen :: Gen a -> Gen (Maybe a)

-- | <tt>Coarbitrary</tt> "generator" for <a>Maybe</a>.
maybeCoGen :: (a -> Gen b -> Gen b) -> (Maybe a -> Gen b -> Gen b)

-- | Generates a list of elements picked from a given list.
listOfElements :: [a] -> Gen [a]

-- | Generates two elements.
two :: Gen a -> Gen (a, a)

-- | Generates three elements.
three :: Gen a -> Gen (a, a, a)

-- | Runs the tests, and returns <a>True</a> if all tests were successful.
runTests :: String -> [IO Bool] -> IO Bool


-- | 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.
data AbsolutePath
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
tests :: IO Bool
instance Typeable AbsolutePath
instance Show AbsolutePath
instance Eq AbsolutePath
instance Ord AbsolutePath
instance Data AbsolutePath
instance Arbitrary AbsolutePath


-- | Position information for syntax. Crucial for giving good error
--   messages.
module Agda.Syntax.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
Pn :: Maybe AbsolutePath -> !Int32 -> !Int32 -> !Int32 -> Position

-- | File.
srcFile :: Position -> Maybe AbsolutePath

-- | Position.
posPos :: Position -> !Int32

-- | Line number, counting from 1.
posLine :: Position -> !Int32

-- | Column number, counting from 1.
posCol :: Position -> !Int32
positionInvariant :: Position -> 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 -> Char -> Position

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

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

-- | 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
Interval :: !Position -> !Position -> Interval
iStart :: Interval -> !Position
iEnd :: Interval -> !Position
intervalInvariant :: Interval -> Bool

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

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

-- | A range is a list of intervals. The intervals should be consecutive
--   and separated.
--   
--   Note the invariant which ranges have to satisfy:
--   <a>rangeInvariant</a>.
newtype Range
Range :: [Interval] -> Range
rangeInvariant :: Range -> Bool

-- | Ranges between two unknown positions
noRange :: Range

-- | Converts two positions to a range.
posToRange :: Position -> Position -> Range

-- | The initial position in the range, if any.
rStart :: Range -> Maybe Position

-- | The position after the final position in the range, if any.
rEnd :: Range -> Maybe Position

-- | Converts a range to an interval, if possible.
rangeToInterval :: Range -> Maybe Interval

-- | Returns the shortest continuous range containing the given one.
continuous :: Range -> Range

-- | Removes gaps between intervals on the same line.
continuousPerLine :: Range -> Range

-- | 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 => a -> a
killRange1 :: KillRange a => (a -> t) -> a -> t
killRange2 :: (KillRange a1, KillRange a) => (a1 -> a -> t) -> a1 -> a -> t
killRange3 :: (KillRange a2, KillRange a, KillRange a1) => (a2 -> a1 -> a -> t) -> a2 -> a1 -> a -> t
killRange4 :: (KillRange a3, KillRange a1, KillRange a, KillRange a2) => (a3 -> a2 -> a1 -> a -> t) -> a3 -> a2 -> a1 -> a -> t
killRange5 :: (KillRange a4, KillRange a2, KillRange a, KillRange a1, KillRange a3) => (a4 -> a3 -> a2 -> a1 -> a -> t) -> a4 -> a3 -> a2 -> a1 -> a -> t
killRange6 :: (KillRange a5, KillRange a3, KillRange a1, KillRange a, KillRange a2, KillRange a4) => (a5 -> a4 -> a3 -> a2 -> a1 -> a -> t) -> a5 -> a4 -> a3 -> a2 -> a1 -> a -> t
killRange7 :: (KillRange a6, KillRange a4, KillRange a2, KillRange a, KillRange a1, KillRange a3, KillRange a5) => (a6 -> a5 -> a4 -> a3 -> a2 -> a1 -> a -> t) -> a6 -> a5 -> a4 -> a3 -> a2 -> a1 -> a -> t

-- | <tt>x <a>withRangeOf</a> y</tt> sets the range of <tt>x</tt> to the
--   range of <tt>y</tt>.
withRangeOf :: (SetRange t, HasRange u) => t -> u -> t
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>.
fuseRanges :: Range -> Range -> Range

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

-- | Test suite.
tests :: IO Bool
instance Typeable Position
instance Typeable Interval
instance Typeable Range
instance Data Position
instance Data Interval
instance Eq Interval
instance Ord Interval
instance Data Range
instance Eq Range
instance Ord Range
instance Arbitrary Range
instance Arbitrary Interval
instance Arbitrary Position
instance Show Range
instance Show Interval
instance Show Position
instance (KillRange a, KillRange b) => KillRange (Either a b)
instance KillRange a => KillRange (Maybe a)
instance (KillRange a, KillRange b) => KillRange (a, b)
instance KillRange a => KillRange [a]
instance KillRange Range
instance SetRange Range
instance HasRange a => HasRange (Maybe a)
instance (HasRange a, HasRange b, HasRange c, HasRange d) => HasRange (a, b, c, d)
instance (HasRange a, HasRange b, HasRange c) => HasRange (a, b, c)
instance (HasRange a, HasRange b) => HasRange (a, b)
instance HasRange a => HasRange [a]
instance HasRange Range
instance HasRange Interval
instance Ord Position
instance Eq Position


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

-- | Head function (safe).
mhead :: [a] -> Maybe a

-- | Sublist relation.
isSublistOf :: Eq a => [a] -> [a] -> Bool
type Prefix a = [a]
type Suffix a = [a]

-- | Check if a list has a given prefix. If so, return the list minus the
--   prefix.
maybePrefixMatch :: Eq a => Prefix a -> [a] -> Maybe (Suffix a)

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

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

-- | 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
prop_distinct_fastDistinct :: [Integer] -> 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

-- | A variant of <a>groupBy</a> which applies the predicate to consecutive
--   pairs.
groupBy' :: (a -> a -> Bool) -> [a] -> [[a]]
prop_groupBy' :: (Bool -> Bool -> Bool) -> [Bool] -> Property

-- | <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><a>extractNthElement</a> n xs</tt> gives the <tt>n</tt>-th element
--   in <tt>xs</tt> (counting from 0), plus the remaining elements
--   (preserving order).
extractNthElement' :: Integral i => i -> [a] -> ([a], a, [a])
extractNthElement :: Integral i => i -> [a] -> (a, [a])
prop_extractNthElement :: Integer -> [Integer] -> Property
genericElemIndex :: (Eq a, Integral i) => a -> [a] -> Maybe i
prop_genericElemIndex :: Integer -> [Integer] -> Property

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

-- | Efficient version of nub that sorts the list first. The tag function
--   is assumed to be cheap. If it isn't pair up the elements with their
--   tags and call uniqBy fst (or snd).
uniqBy :: Ord b => (a -> b) -> [a] -> [a]
prop_uniqBy :: [Integer] -> Bool
tests :: IO Bool

module Agda.Utils.Monad
(<.>) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
whenM :: Monad m => m Bool -> m () -> m ()
unlessM :: Monad m => m Bool -> m () -> m ()
ifM :: Monad m => m Bool -> m a -> m a -> m a
forgetM :: Applicative m => m a -> m ()
concatMapM :: Applicative m => (a -> m [b]) -> [a] -> m [b]

-- | Depending on the monad you have to look at the result for the force to
--   be effective. For the <a>IO</a> monad you do.
forceM :: Monad m => [a] -> m ()
commuteM :: (Traversable f, Applicative m) => f (m a) -> m (f a)
fmapM :: (Traversable f, Applicative m) => (a -> m b) -> f a -> m (f 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]

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

-- | Bracket for the <a>Error</a> class.
bracket :: (Error e, MonadError e m) => m a -> (a -> m c) -> (a -> m b) -> m b
mapMaybeM :: Applicative m => (a -> m b) -> Maybe a -> m (Maybe b)
liftEither :: MonadError e m => Either e a -> m a
readM :: (Error e, MonadError e m, Read a) => String -> m a

-- | An infix synonym for <a>fmap</a>.
(<$>) :: Functor f => (a -> b) -> f a -> f b

-- | Sequential application.
(<*>) :: Applicative f => forall a b. f (a -> b) -> f a -> f b

module Agda.Interaction.Options
data CommandLineOptions
Options :: String -> Maybe FilePath -> Either [FilePath] [AbsolutePath] -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Maybe FilePath -> Bool -> Bool -> Maybe FilePath -> FilePath -> Maybe FilePath -> Bool -> Bool -> [String] -> PragmaOptions -> [String] -> Bool -> CommandLineOptions
optProgramName :: CommandLineOptions -> String
optInputFile :: CommandLineOptions -> Maybe FilePath

-- | <a>Left</a> is used temporarily, before the paths have been made
--   absolute. An empty <a>Left</a> list is interpreted as
--   <tt>[<a>.</a>]</tt> (see <a>makeIncludeDirsAbsolute</a>).
optIncludeDirs :: CommandLineOptions -> Either [FilePath] [AbsolutePath]
optShowVersion :: CommandLineOptions -> Bool
optShowHelp :: CommandLineOptions -> Bool
optInteractive :: CommandLineOptions -> Bool
optRunTests :: CommandLineOptions -> Bool
optCompile :: CommandLineOptions -> Bool
optEpicCompile :: CommandLineOptions -> Bool
optJSCompile :: CommandLineOptions -> Bool

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

-- | Options which can be set in a pragma.
data PragmaOptions
PragmaOptions :: Bool -> Verbosity -> Bool -> Bool -> Bool -> Bool -> Int -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> PragmaOptions
optShowImplicit :: PragmaOptions -> Bool
optVerbose :: PragmaOptions -> Verbosity
optProofIrrelevance :: PragmaOptions -> Bool
optAllowUnsolved :: PragmaOptions -> Bool
optDisablePositivity :: PragmaOptions -> Bool
optTerminationCheck :: PragmaOptions -> Bool
optTerminationDepth :: PragmaOptions -> Int
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

-- | 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 -> Either String opts
type Verbosity = Trie String Int

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

-- | Parse the standard options.
parseStandardOptions :: [String] -> Either String CommandLineOptions

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

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

-- | Used for printing usage info.
standardOptions_ :: [OptDescr ()]
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, [String], [OptDescr ()])] -> String -> String
tests :: IO Bool
instance Functor ArgDescr
instance Functor OptDescr
instance Show PragmaOptions
instance Show CommandLineOptions


-- | Some common syntactic entities are defined in this module.
module Agda.Syntax.Common
data Induction
Inductive :: Induction
CoInductive :: Induction
data Hiding
Hidden :: Hiding
Instance :: Hiding
NotHidden :: Hiding

-- | A function argument can be relevant or irrelevant. See
--   <a>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
Forced :: Relevance

-- | Information ordering. <tt>Relevant <a>moreRelevant</a> Forced
--   <a>moreRelevant</a> NonStrict <a>moreRelevant</a> Irrelevant</tt>
moreRelevant :: Relevance -> Relevance -> Bool

-- | A function argument can be hidden and/or irrelevant.
data Arg e
Arg :: Hiding -> Relevance -> e -> Arg e
argHiding :: Arg e -> Hiding
argRelevance :: Arg e -> Relevance
unArg :: Arg e -> e
makeInstance :: Arg a -> Arg a
hide :: Arg a -> Arg a
defaultArg :: a -> Arg a
isHiddenArg :: Arg a -> Bool

-- | <tt>xs <a>withArgsFrom</a> 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]
data Named name a
Named :: Maybe name -> a -> Named name a
nameOf :: Named name a -> Maybe name
namedThing :: Named name a -> a
unnamed :: a -> Named name a
named :: name -> a -> Named name a

-- | Only <a>Hidden</a> arguments can have names.
type NamedArg a = Arg (Named String a)

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

-- | Access modifier.
data Access
PrivateAccess :: Access
PublicAccess :: Access

-- | Visible from outside, but not exported when opening the module Used
--   for qualified constructors.
OnlyQualified :: Access

-- | Abstract or concrete
data IsAbstract
AbstractDef :: IsAbstract
ConcreteDef :: IsAbstract
type Nat = Integer
type Arity = Nat

-- | The unique identifier of a name. Second argument is the top-level
--   module identifier.
data NameId
NameId :: Nat -> Integer -> NameId
newtype Constr a
Constr :: a -> Constr a
instance Typeable Induction
instance Typeable Hiding
instance Typeable Relevance
instance Typeable1 Arg
instance Typeable2 Named
instance Typeable IsInfix
instance Typeable Access
instance Typeable IsAbstract
instance Typeable NameId
instance Data Induction
instance Show Induction
instance Eq Induction
instance Ord Induction
instance Data Hiding
instance Show Hiding
instance Eq Hiding
instance Ord Hiding
instance Data Relevance
instance Show Relevance
instance Eq Relevance
instance Data e => Data (Arg e)
instance Ord e => Ord (Arg e)
instance Functor Arg
instance Foldable Arg
instance Traversable Arg
instance (Eq name, Eq a) => Eq (Named name a)
instance (Ord name, Ord a) => Ord (Named name a)
instance (Data name, Data a) => Data (Named name a)
instance Functor (Named name)
instance Foldable (Named name)
instance Traversable (Named name)
instance Data IsInfix
instance Show IsInfix
instance Eq IsInfix
instance Ord IsInfix
instance Data Access
instance Show Access
instance Eq Access
instance Ord Access
instance Data IsAbstract
instance Show IsAbstract
instance Eq IsAbstract
instance Ord IsAbstract
instance Eq NameId
instance Ord NameId
instance Data NameId
instance CoArbitrary Induction
instance Arbitrary Induction
instance Enum NameId
instance Show a => Show (Named String a)
instance Sized a => Sized (Named name a)
instance KillRange a => KillRange (Named name a)
instance HasRange a => HasRange (Named name a)
instance Show a => Show (Arg a)
instance Sized a => Sized (Arg a)
instance KillRange a => KillRange (Arg a)
instance HasRange a => HasRange (Arg a)
instance Eq a => Eq (Arg a)
instance KillRange Hiding
instance KillRange Induction
instance Ord Relevance


-- | 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 <a>+</a>,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
Name :: !Range -> [NamePart] -> Name
NoName :: !Range -> NameId -> Name
data NamePart
Hole :: NamePart
Id :: String -> NamePart

-- | <pre>
--   noName_ = <a>noName</a> <a>noRange</a>
--   </pre>
noName_ :: Name

-- | <pre>
--   noName r = <a>Name</a> r [<a>Hole</a>]
--   </pre>
noName :: Range -> Name
isNoName :: Name -> Bool

-- | Is the name an operator?
isOperator :: Name -> Bool
nameParts :: Name -> [NamePart]
nameStringParts :: Name -> [String]

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

-- | <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
Qual :: Name -> QName -> QName
QName :: Name -> QName

-- | Top-level module names.
--   
--   Invariant: The list must not be empty.
newtype TopLevelModuleName
TopLevelModuleName :: [String] -> TopLevelModuleName
moduleNameParts :: TopLevelModuleName -> [String]

-- | 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 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
isHole :: NamePart -> Bool
isPrefix :: Name -> Bool
isNonfix :: Name -> Bool
isInfix :: Name -> Bool
isPostfix :: Name -> Bool
instance Typeable NamePart
instance Typeable Name
instance Typeable QName
instance Typeable TopLevelModuleName
instance Data NamePart
instance Data Name
instance Data QName
instance Eq QName
instance Ord QName
instance Show TopLevelModuleName
instance Eq TopLevelModuleName
instance Ord TopLevelModuleName
instance Data TopLevelModuleName
instance KillRange Name
instance KillRange QName
instance SetRange Name
instance HasRange QName
instance HasRange Name
instance CoArbitrary TopLevelModuleName
instance Arbitrary TopLevelModuleName
instance Pretty TopLevelModuleName
instance Show QName
instance Show NamePart
instance Show Name
instance Ord NamePart
instance Eq NamePart
instance Ord Name
instance Eq Name

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
newtype LocalId
LocalId :: Nat -> LocalId
newtype GlobalId
GlobalId :: [String] -> GlobalId
newtype MemberId
MemberId :: String -> MemberId
data Export
Export :: [MemberId] -> Exp -> Export
expName :: Export -> [MemberId]
defn :: Export -> Exp
data Module
Module :: GlobalId -> [Export] -> Module
modName :: Module -> GlobalId
exports :: Module -> [Export]
class Uses a
uses :: Uses a => a -> Set [MemberId]
class Globals a
globals :: Globals a => a -> Set GlobalId
instance Typeable LocalId
instance Typeable GlobalId
instance Typeable MemberId
instance Typeable Exp
instance Typeable Export
instance Typeable Module
instance Data LocalId
instance Eq LocalId
instance Ord LocalId
instance Show LocalId
instance Data GlobalId
instance Eq GlobalId
instance Ord GlobalId
instance Show GlobalId
instance Data MemberId
instance Eq MemberId
instance Ord MemberId
instance Show MemberId
instance Data Exp
instance Show Exp
instance Data Export
instance Show Export
instance Data Module
instance Show Module
instance Globals Module
instance Globals Export
instance Globals Exp
instance Globals a => Globals (Map k a)
instance Globals a => Globals [a]
instance Uses Export
instance Uses Exp
instance Uses a => Uses (Map k a)
instance Uses a => Uses [a]

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 Pretty Module
instance Pretty Exp
instance Pretty MemberId
instance Pretty GlobalId
instance Pretty LocalId
instance (Pretty a, Pretty b) => Pretties (Map a b)
instance Pretty a => Pretties [a]
instance (Pretty a, Pretty b) => Pretty (a, b)

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.Case
data Case
Case :: [Patt] -> Exp -> Case
pats :: Case -> [Patt]
body :: Case -> Exp
data Patt
VarPatt :: Patt
Tagged :: Tag -> [Patt] -> Patt
data Tag
Tag :: MemberId -> [MemberId] -> (Exp -> [Exp] -> Exp) -> Tag
numVars :: [Patt] -> Nat
numVars' :: Patt -> Nat
lambda :: [Case] -> Exp
lambda' :: Nat -> Nat -> Nat -> [Case] -> Exp
pop :: Case -> Case
match :: Nat -> Nat -> Nat -> [Case] -> MemberId -> Nat -> Exp
refine :: MemberId -> Nat -> Case -> [Case]
visit :: [Case] -> Exp -> [Exp] -> Exp
tags :: [Case] -> Map MemberId Nat
tag :: Case -> Map MemberId Nat
instance Show Patt
instance Show Case
instance Show Tag
instance Pretty Patt
instance Pretty Case

module Agda.Compiler.JS.Parser
type Parser = ReadP Char
identifier :: Parser String
wordBoundary :: Parser ()
token :: String -> Parser ()
punct :: Char -> Parser ()
parened :: Parser a -> Parser a
braced :: Parser a -> Parser a
bracketed :: Parser a -> Parser a
quoted :: Parser a -> Parser a
stringLit :: Parser Exp
stringStr :: Parser String
stringChr :: Parser Char
escChr :: Parser Char
intLit :: Parser Exp
undef :: Parser Exp
localid :: (Map String Nat) -> Parser Exp
globalid :: Parser Exp
preop :: Parser String
binop :: Parser String
field :: (Map String Nat) -> Parser (MemberId, Exp)
object :: (Map String Nat) -> Parser Exp
function :: (Map String Nat) -> Parser Exp
bracedBlock :: (Map String Nat) -> Parser Exp
returnBlock :: (Map String Nat) -> Parser Exp
ifBlock :: (Map String Nat) -> Parser Exp
exp0 :: (Map String Nat) -> Parser Exp
exp1 :: (Map String Nat) -> Parser Exp
exp2 :: (Map String Nat) -> Parser Exp
exp2' :: (Map String Nat) -> Exp -> Parser Exp
exp3 :: (Map String Nat) -> Parser Exp
exp3' :: (Map String Nat) -> Exp -> Parser Exp
exp :: (Map String Nat) -> Parser Exp
topLevel :: Parser Exp
parse :: String -> Either Exp String

module Agda.Syntax.Notation

-- | A name is a non-empty list of alternating <tt>Id</tt>s and
--   <tt>Hole</tt>s. A normal name is represented by a singleton list, and
--   operators are represented by a list with <tt>Hole</tt>s where the
--   arguments should go. For instance: <tt>[Hole,Id <a>+</a>,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 type constructed in the Happy parser; converted to <a>GenPart</a>
--   before it leaves the Happy code.
data HoleName

-- | (x -&gt; y) ; 1st argument is the bound name (unused for now)
LambdaHole :: String -> String -> HoleName

-- | simple named hole
ExprHole :: String -> HoleName

-- | Target of a hole
holeName :: HoleName -> String
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 :: Int -> GenPart
IdPart :: String -> GenPart

-- | Get a flat list of identifier parts of a notation.
stringParts :: Notation -> [String]

-- | Target argument position of a part (Nothing if it is not a hole)
holeTarget :: GenPart -> Maybe Int

-- | Is the part a hole?
isAHole :: GenPart -> Bool
isBindingHole :: GenPart -> Bool
isLambdaHole :: HoleName -> Bool

-- | From notation with names to notation with indices.
mkNotation :: [HoleName] -> [String] -> Either String Notation

-- | No notation by default
defaultNotation :: [a]
noNotation :: [a]
instance Typeable GenPart
instance Data GenPart
instance Show GenPart
instance Eq GenPart


-- | Definitions for fixity and precedence levels.
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 -> Fixity'
theFixity :: Fixity' -> Fixity
theNotation :: Fixity' -> Notation
data ThingWithFixity x
ThingWithFixity :: x -> Fixity' -> ThingWithFixity x

-- | All the notation information related to a name.
type NewNotation = (Name, Fixity, Notation)

-- | If an operator has no specific notation, recover it from its name.
oldToNewNotation :: (Name, Fixity') -> NewNotation
syntaxOf :: Name -> Notation
defaultFixity' :: Fixity'
noFixity :: Fixity

-- | Fixity of operators.
data Fixity
LeftAssoc :: Range -> Nat -> Fixity
RightAssoc :: Range -> Nat -> Fixity
NonAssoc :: Range -> Nat -> Fixity
fixityLevel :: Fixity -> Nat

-- | The default fixity. Currently defined to be <tt><a>NonAssoc</a>
--   20</tt>.
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
instance Typeable Fixity
instance Typeable Fixity'
instance Typeable1 ThingWithFixity
instance Typeable Precedence
instance Data Fixity
instance Show Fixity
instance Data Fixity'
instance Show Fixity'
instance Eq Fixity'
instance Functor ThingWithFixity
instance Foldable ThingWithFixity
instance Traversable ThingWithFixity
instance Data x => Data (ThingWithFixity x)
instance Show x => Show (ThingWithFixity x)
instance Show Precedence
instance Data Precedence
instance HasRange Fixity
instance Eq Fixity


-- | Abstract names should carry unique identifiers and stuff. Not right
--   now though.
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

-- | 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.
newtype AmbiguousQName
AmbQ :: [QName] -> AmbiguousQName
unAmbQ :: AmbiguousQName -> [QName]

-- | 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 <a>withRangesOf</a> [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

-- | The <a>Range</a> sets the <i>definition site</i> of the name, not the
--   use site.
mkName :: Range -> NameId -> String -> Name
mkName_ :: NameId -> String -> 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

-- | Is the name an operator?
isOperator :: QName -> Bool
isSubModuleOf :: ModuleName -> ModuleName -> Bool
isInModule :: QName -> ModuleName -> Bool
freshName :: (MonadState s m, HasFresh NameId s) => Range -> String -> m Name
freshName_ :: (MonadState s m, HasFresh NameId s) => String -> m Name
freshNoName :: (MonadState s m, HasFresh NameId s) => Range -> m Name
freshNoName_ :: (MonadState s m, HasFresh NameId s) => m Name

-- | Get the next version of the concrete name. For instance, <tt>nextName
--   <a>x</a> = <a>x'</a></tt>. The name must not be a <tt>NoName</tt>.
nextName :: Name -> Name
instance Typeable Name
instance Typeable ModuleName
instance Typeable QName
instance Typeable AmbiguousQName
instance Data Name
instance Eq ModuleName
instance Ord ModuleName
instance Data ModuleName
instance Data QName
instance Data AmbiguousQName
instance HasRange AmbiguousQName
instance Show AmbiguousQName
instance Sized ModuleName
instance Sized QName
instance KillRange AmbiguousQName
instance KillRange ModuleName
instance KillRange Name
instance KillRange QName
instance SetRange ModuleName
instance SetRange QName
instance SetRange Name
instance HasRange QName
instance HasRange Name
instance Ord QName
instance Eq QName
instance Show ModuleName
instance Show QName
instance Show Name
instance Ord Name
instance Eq Name
instance Show NameId
instance HasRange ModuleName

module Agda.Syntax.Literal
data Literal
LitInt :: Range -> Integer -> Literal
LitFloat :: Range -> Double -> Literal
LitString :: Range -> String -> Literal
LitChar :: Range -> Char -> Literal
LitQName :: Range -> QName -> Literal
instance Typeable Literal
instance Data Literal
instance Show Literal
instance KillRange Literal
instance SetRange Literal
instance HasRange Literal
instance Ord Literal
instance Eq Literal


-- | 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>
Underscore :: !Range -> (Maybe Nat) -> 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>
OpApp :: !Range -> Name -> [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 String Expr) -> Expr

-- | ex: <tt>{{e}}</tt> or <tt>{{x=e}}</tt>
InstanceArg :: !Range -> (Named String 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)] -> 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 -> Nat -> Expr

-- | ex: <tt>record {x = a; y = b}</tt>
Rec :: !Range -> [(Name, Expr)] -> Expr

-- | ex: <tt>record e {x = a; y = b}</tt>
RecUpdate :: !Range -> Expr -> [(Name, Expr)] -> Expr

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

-- | ex: <tt>(e)</tt>
Paren :: !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>quote</tt>, should be applied to a name
Quote :: !Range -> Expr

-- | ex: <tt>quoteTerm</tt>, should be applied to a term
QuoteTerm :: !Range -> 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
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.
data LamBinding

-- | . <tt>x</tt> or <tt>{x}</tt> or <tt>.x</tt> or <tt>.{x}</tt> or
--   <tt>{.x}</tt>
DomainFree :: Hiding -> Relevance -> BoundName -> LamBinding

-- | . <tt>(xs : e)</tt> or <tt>{xs : e}</tt>
DomainFull :: TypedBindings -> LamBinding

-- | A sequence of typed bindings with hiding information. Appears in
--   dependent function spaces, typed lambdas, and telescopes.
data TypedBindings

-- | . <tt>(xs : e)</tt> or <tt>{xs : e}</tt>
TypedBindings :: !Range -> (Arg TypedBinding) -> TypedBindings

-- | A typed binding.
data TypedBinding
TBind :: !Range -> [BoundName] -> Expr -> TypedBinding
TNoBind :: Expr -> TypedBinding
data BoundName
BName :: Name -> Fixity' -> BoundName
boundName :: BoundName -> Name
bnameFixity :: BoundName -> Fixity'
mkBoundName_ :: Name -> BoundName

-- | A telescope is a sequence of typed bindings. Bound variables are in
--   scope in later types.
type Telescope = [TypedBindings]

-- | 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.
TypeSig :: Relevance -> Name -> Expr -> Declaration

-- | Record field, can be hidden and/or irrelevant.
Field :: Name -> (Arg Expr) -> Declaration
FunClause :: LHS -> RHS -> WhereClause -> Declaration

-- | lone data signature in mutual block
DataSig :: !Range -> Induction -> Name -> [LamBinding] -> Expr -> Declaration
Data :: !Range -> Induction -> Name -> [LamBinding] -> (Maybe Expr) -> [Constructor] -> 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 Name) -> [LamBinding] -> (Maybe Expr) -> [Declaration] -> Declaration
Infix :: Fixity -> [Name] -> Declaration

-- | notation declaration for a name
Syntax :: Name -> Notation -> Declaration
Mutual :: !Range -> [Declaration] -> Declaration
Abstract :: !Range -> [Declaration] -> Declaration
Private :: !Range -> [Declaration] -> Declaration
Postulate :: !Range -> [TypeSignature] -> 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
Pragma :: Pragma -> Declaration
data ModuleApplication
SectionApp :: Range -> [TypedBindings] -> Expr -> ModuleApplication
RecordModuleIFS :: Range -> QName -> ModuleApplication

-- | Just type signatures.
type TypeSignature = Declaration

-- | A constructor or field declaration is just a type signature.
type Constructor = TypeSignature
type Field = TypeSignature

-- | 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
ImportDirective :: !Range -> UsingOrHiding -> [Renaming] -> Bool -> ImportDirective
importDirRange :: ImportDirective -> !Range
usingOrHiding :: ImportDirective -> UsingOrHiding
renaming :: ImportDirective -> [Renaming]

-- | Only for <tt>open</tt>. Exports the opened names from the current
--   module.
publicOpen :: ImportDirective -> Bool
data UsingOrHiding
Hiding :: [ImportedName] -> UsingOrHiding
Using :: [ImportedName] -> UsingOrHiding

-- | An imported name can be a module or a defined name
data ImportedName
ImportedModule :: Name -> ImportedName
importedName :: ImportedName -> Name
ImportedName :: Name -> ImportedName
importedName :: ImportedName -> Name
data Renaming
Renaming :: ImportedName -> Name -> Range -> Renaming

-- | Rename from this name.
renFrom :: Renaming -> ImportedName

-- | To this one.
renTo :: Renaming -> Name

-- | The range of the "to" keyword. Retained for highlighting purposes.
renToRange :: Renaming -> Range
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
defaultImportDir :: ImportDirective
data OpenShortHand
DoOpen :: OpenShortHand
DontOpen :: OpenShortHand

-- | 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
lhsOriginalPattern :: LHS -> Pattern
lhsWithPattern :: LHS -> [Pattern]
lhsRewriteEqn :: LHS -> [RewriteEqn]
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
IdentP :: QName -> Pattern
AppP :: Pattern -> (NamedArg Pattern) -> Pattern
RawAppP :: !Range -> [Pattern] -> Pattern
OpAppP :: !Range -> Name -> [Pattern] -> Pattern
HiddenP :: !Range -> (Named String Pattern) -> Pattern
InstanceP :: !Range -> (Named String Pattern) -> Pattern
ParenP :: !Range -> Pattern -> Pattern
WildP :: !Range -> Pattern
AbsurdP :: !Range -> Pattern
AsP :: !Range -> Name -> Pattern -> Pattern
DotP :: !Range -> Expr -> Pattern
LitP :: Literal -> Pattern
data RHS
AbsurdRHS :: RHS
RHS :: Expr -> RHS
data WhereClause
NoWhere :: WhereClause
AnyWhere :: [Declaration] -> WhereClause
SomeWhere :: Name -> [Declaration] -> WhereClause
data Pragma
OptionsPragma :: !Range -> [String] -> Pragma
BuiltinPragma :: !Range -> String -> Expr -> Pragma
CompiledDataPragma :: !Range -> QName -> String -> [String] -> Pragma
CompiledTypePragma :: !Range -> QName -> String -> Pragma
CompiledPragma :: !Range -> QName -> String -> Pragma
CompiledEpicPragma :: !Range -> QName -> String -> Pragma
CompiledJSPragma :: !Range -> QName -> String -> Pragma
StaticPragma :: !Range -> QName -> Pragma

-- | Invariant: The string must be a valid Haskell module name.
ImportPragma :: !Range -> String -> Pragma
ImpossiblePragma :: !Range -> Pragma
EtaPragma :: !Range -> QName -> Pragma

-- | Modules: Top-level pragmas plus other top-level declarations.
type Module = ([Pragma], [Declaration])
data ThingWithFixity x
ThingWithFixity :: x -> Fixity' -> ThingWithFixity x

-- | Computes the top-level module name.
--   
--   Precondition: The <a>Module</a> has to be well-formed.
topLevelModuleName :: Module -> TopLevelModuleName

-- | Get the leftmost symbol in a pattern.
patternHead :: Pattern -> Maybe Name

-- | Get all the identifiers in a pattern in left-to-right order.
patternNames :: Pattern -> [Name]
instance Typeable BoundName
instance Typeable ImportedName
instance Typeable UsingOrHiding
instance Typeable Renaming
instance Typeable ImportDirective
instance Typeable AsName
instance Typeable OpenShortHand
instance Typeable Pragma
instance Typeable Expr
instance Typeable Declaration
instance Typeable ModuleApplication
instance Typeable TypedBindings
instance Typeable TypedBinding
instance Typeable WhereClause
instance Typeable RHS
instance Typeable LHS
instance Typeable Pattern
instance Typeable LamBinding
instance Typeable1 OpApp
instance Data BoundName
instance Data ImportedName
instance Eq ImportedName
instance Ord ImportedName
instance Data UsingOrHiding
instance Data Renaming
instance Data ImportDirective
instance Data AsName
instance Show AsName
instance Data OpenShortHand
instance Show OpenShortHand
instance Data Pragma
instance Data Expr
instance Data Declaration
instance Data ModuleApplication
instance Data TypedBindings
instance Data TypedBinding
instance Data WhereClause
instance Data RHS
instance Data LHS
instance Data Pattern
instance Data LamBinding
instance Data e => Data (OpApp e)
instance Functor OpApp
instance HasRange Pattern
instance HasRange AsName
instance HasRange Renaming
instance HasRange ImportedName
instance HasRange ImportDirective
instance HasRange UsingOrHiding
instance HasRange Pragma
instance HasRange RHS
instance HasRange LHS
instance HasRange Declaration
instance HasRange ModuleApplication
instance HasRange WhereClause
instance HasRange BoundName
instance HasRange LamBinding
instance HasRange TypedBinding
instance HasRange TypedBindings
instance HasRange Expr
instance HasRange e => HasRange (OpApp e)
instance Show ImportedName


-- | Pretty printer for the concrete syntax.
module Agda.Syntax.Concrete.Pretty
braces' :: Doc -> Doc
dbraces :: Doc -> Doc
arrow :: Doc
lambda :: Doc
underscore :: Doc
pHidden :: Pretty a => Hiding -> a -> Doc
pRelevance :: Pretty a => Relevance -> a -> Doc
showString' :: String -> ShowS
showChar' :: Char -> ShowS
smashTel :: Telescope -> Telescope
instance Pretty ImportedName
instance Pretty UsingOrHiding
instance Pretty ImportDirective
instance Pretty Pattern
instance Pretty [Pattern]
instance Pretty e => Pretty (Named String e)
instance Pretty e => Pretty (Arg e)
instance Pretty Fixity
instance Pretty Pragma
instance Pretty OpenShortHand
instance Pretty Declaration
instance Pretty ModuleApplication
instance Show ModuleApplication
instance Pretty [Declaration]
instance Pretty LHS
instance Show LHS
instance Pretty WhereClause
instance Show WhereClause
instance Pretty RHS
instance Pretty TypedBinding
instance Pretty TypedBindings
instance Pretty LamBinding
instance Pretty BoundName
instance Pretty Expr
instance Pretty (OpApp Expr)
instance Pretty Induction
instance Pretty Relevance
instance Pretty Literal
instance Pretty QName
instance Pretty Name
instance Pretty (ThingWithFixity Name)
instance Show RHS
instance Show Pragma
instance Show ImportDirective
instance Show LamBinding
instance Show TypedBindings
instance Show Pattern
instance Show Declaration
instance Show Expr

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
KwOpen :: Keyword
KwImport :: Keyword
KwModule :: Keyword
KwPrimitive :: Keyword
KwInfix :: Keyword
KwInfixL :: Keyword
KwInfixR :: Keyword
KwWith :: Keyword
KwRewrite :: Keyword
KwSet :: Keyword
KwProp :: Keyword
KwForall :: Keyword
KwRecord :: Keyword
KwConstructor :: Keyword
KwField :: Keyword
KwHiding :: Keyword
KwUsing :: Keyword
KwRenaming :: Keyword
KwTo :: Keyword
KwPublic :: Keyword
KwOPTIONS :: Keyword
KwBUILTIN :: Keyword
KwLINE :: Keyword
KwCOMPILED_DATA :: Keyword
KwCOMPILED_TYPE :: Keyword
KwCOMPILED :: Keyword
KwCOMPILED_EPIC :: Keyword
KwCOMPILED_JS :: Keyword
KwIMPORT :: Keyword
KwIMPOSSIBLE :: Keyword
KwETA :: Keyword
KwSTATIC :: Keyword
KwQuoteGoal :: Keyword
KwQuote :: Keyword
KwQuoteTerm :: Keyword
KwUnquote :: Keyword
KwSyntax :: 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
SymDoubleOpenBrace :: Symbol
SymDoubleCloseBrace :: Symbol
SymOpenBrace :: Symbol
SymCloseBrace :: Symbol
SymOpenVirtualBrace :: Symbol
SymCloseVirtualBrace :: Symbol
SymOpenPragma :: Symbol
SymClosePragma :: Symbol
SymEllipsis :: Symbol
SymDotDot :: Symbol
instance Eq Keyword
instance Show Keyword
instance Eq Symbol
instance Show Symbol
instance Eq Token
instance Show Token
instance HasRange Token


-- | Functions for inserting implicit arguments at the right places.
module Agda.TypeChecking.Implicit
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 :: String -> ImplicitInsertion
NoInsertNeeded :: ImplicitInsertion
impInsert :: [Hiding] -> ImplicitInsertion

-- | The list should be non-empty.
insertImplicit :: NamedArg e -> [Arg String] -> ImplicitInsertion
instance Show ImplicitInsertion

module Agda.Syntax.Internal

-- | 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
Var :: Nat -> Args -> Term

-- | terms are beta normal
Lam :: Hiding -> (Abs Term) -> Term
Lit :: Literal -> Term
Def :: QName -> Args -> Term
Con :: QName -> Args -> Term
Pi :: (Arg Type) -> (Abs Type) -> Term
Sort :: Sort -> Term
Level :: Level -> Term
MetaV :: MetaId -> Args -> Term

-- | irrelevant stuff
DontCare :: Term -> Term
data Type
El :: Sort -> Term -> Type
data Elim
Apply :: (Arg Term) -> Elim

-- | name of a record projection
Proj :: QName -> Elim

-- | Top sort (Setomega).
topSort :: Type
data Sort
Type :: Level -> Sort
Prop :: Sort
Inf :: Sort

-- | 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
newtype Level
Max :: [PlusLevel] -> Level
data PlusLevel
ClosedLevel :: Integer -> PlusLevel
Plus :: Integer -> LevelAtom -> PlusLevel
data LevelAtom
MetaLevel :: MetaId -> Args -> LevelAtom
BlockedLevel :: MetaId -> Term -> LevelAtom
NeutralLevel :: Term -> LevelAtom
UnreducedLevel :: Term -> LevelAtom

-- | Something where a meta variable may block reduction.
data Blocked t
Blocked :: MetaId -> t -> Blocked t
NotBlocked :: t -> Blocked t

-- | Type of argument lists.
type Args = [Arg Term]

-- | Sequence of types. An argument of the first type is bound in later
--   types and so on.
data Tele a
EmptyTel :: Tele a

-- | Abs is never NoAbs.
ExtendTel :: a -> (Abs (Tele a)) -> Tele a
type Telescope = Tele (Arg Type)

-- | The body has (at least) one free variable.
data Abs a
Abs :: String -> a -> Abs a
NoAbs :: String -> a -> Abs a

-- | Danger: doesn't shift variables properly
unAbs :: Abs a -> a
absName :: Abs a -> String

-- | A clause is a list of patterns and the clause body should
--   <tt>Bind</tt>.
--   
--   The telescope contains the types of the pattern variables and the
--   permutation is how to get from the order the variables occur in the
--   patterns to the order they occur in the telescope. The body binds the
--   variables in the order they appear in the patterns.
--   
--   For the purpose of the permutation and the body dot patterns count as
--   variables. TODO: Change this!
data Clause
Clause :: Range -> Telescope -> Permutation -> [Arg Pattern] -> ClauseBody -> Clause
clauseRange :: Clause -> Range
clauseTel :: Clause -> Telescope
clausePerm :: Clause -> Permutation
clausePats :: Clause -> [Arg Pattern]
clauseBody :: Clause -> ClauseBody
data ClauseBody
Body :: Term -> ClauseBody
Bind :: (Abs ClauseBody) -> ClauseBody

-- | for absurd clauses.
NoBody :: ClauseBody

-- | 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
VarP :: String -> Pattern
DotP :: Term -> Pattern

-- | The type is <tt><a>Just</a> t</tt>' iff the pattern is a record
--   pattern. The scope used for the type is given by any outer scope plus
--   the clause's telescope (<a>clauseTel</a>).
ConP :: QName -> (Maybe (Arg Type)) -> [Arg Pattern] -> Pattern
LitP :: Literal -> Pattern
newtype MetaId
MetaId :: Nat -> MetaId

-- | Doesn't do any reduction.
arity :: Type -> Nat

-- | Suggest a name for the first argument of a function of the given type.
argName :: Type -> String
blockingMeta :: Blocked t -> Maybe MetaId
blocked :: MetaId -> a -> Blocked a
notBlocked :: a -> Blocked a
ignoreBlocking :: Blocked a -> a
set0 :: Type
set :: Integer -> Type
prop :: Type
sort :: Sort -> Type
varSort :: Nat -> Sort

-- | Get the next higher sort.
sSuc :: Sort -> Sort
levelSuc :: Level -> Level
mkType :: Integer -> Sort
getSort :: Type -> Sort
unEl :: Type -> Term
impossibleTerm :: String -> Int -> Term
instance Typeable1 Abs
instance Typeable1 Tele
instance Typeable MetaId
instance Typeable1 Blocked
instance Typeable Term
instance Typeable Level
instance Typeable PlusLevel
instance Typeable LevelAtom
instance Typeable Sort
instance Typeable Type
instance Typeable ClauseBody
instance Typeable Pattern
instance Typeable Clause
instance Data a => Data (Abs a)
instance Functor Abs
instance Foldable Abs
instance Traversable Abs
instance Data a => Data (Tele a)
instance Show a => Show (Tele a)
instance Functor Tele
instance Foldable Tele
instance Traversable Tele
instance Eq MetaId
instance Ord MetaId
instance Num MetaId
instance Real MetaId
instance Enum MetaId
instance Integral MetaId
instance Data MetaId
instance Data t => Data (Blocked t)
instance Eq t => Eq (Blocked t)
instance Ord t => Ord (Blocked t)
instance Functor Blocked
instance Foldable Blocked
instance Traversable Blocked
instance Data Term
instance Show Term
instance Show Level
instance Data Level
instance Show PlusLevel
instance Data PlusLevel
instance Show LevelAtom
instance Data LevelAtom
instance Data Sort
instance Show Sort
instance Data Type
instance Show Type
instance Data ClauseBody
instance Show ClauseBody
instance Show Elim
instance Data Pattern
instance Show Pattern
instance Data Clause
instance Show Clause
instance Show MetaId
instance HasRange Clause
instance Sized a => Sized (Abs a)
instance Show a => Show (Abs a)
instance Sized (Tele a)
instance KillRange a => KillRange (Abs a)
instance KillRange a => KillRange (Blocked a)
instance KillRange a => KillRange (Tele a)
instance KillRange Sort
instance KillRange Type
instance KillRange LevelAtom
instance KillRange PlusLevel
instance KillRange Level
instance KillRange Term
instance Sized LevelAtom
instance Sized PlusLevel
instance Sized Level
instance Sized Type
instance Sized Term
instance Applicative Blocked
instance Show t => Show (Blocked t)


-- | Computing the free variables of a term.
module Agda.TypeChecking.Free

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

-- | variables at top and under constructors
stronglyRigidVars :: FreeVars -> VarSet

-- | ord. rigid variables, e.g., in arguments of variables
weaklyRigidVars :: FreeVars -> VarSet

-- | variables occuring in arguments of metas. These are potentially free,
--   depending how the meta variable is instantiated.
flexibleVars :: FreeVars -> VarSet

-- | variables under a <tt>DontCare</tt>, i.e., in irrelevant positions
irrelevantVars :: FreeVars -> VarSet
class Free a

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

-- | <tt>allVars fv</tt> includes irrelevant variables.
allVars :: FreeVars -> VarSet

-- | All but the irrelevant variables.
relevantVars :: FreeVars -> VarSet
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
relevantIn :: Free a => Nat -> a -> Bool
data Occurrence
NoOccurrence :: Occurrence
StronglyRigid :: Occurrence
WeaklyRigid :: Occurrence
Flexible :: Occurrence

-- | <tt>occurrence x fv</tt> ignores irrelevant variables in <tt>fv</tt>
occurrence :: Nat -> FreeVars -> Occurrence
instance Eq Occurrence
instance Show Occurrence
instance Free ClauseBody
instance Free a => Free (Tele a)
instance Free a => Free (Abs a)
instance Free a => Free (Arg a)
instance (Free a, Free b) => Free (a, b)
instance Free a => Free (Maybe a)
instance Free a => Free [a]
instance Free LevelAtom
instance Free PlusLevel
instance Free Level
instance Free Sort
instance Free Type
instance Free Term


-- | 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 Typeable Tag
instance Typeable Forced
instance Typeable Relevance
instance Typeable InjectiveFun
instance Typeable EInterface
instance Show Tag
instance Eq Tag
instance Ord Tag
instance Show Forced
instance Eq Forced
instance Eq Relevance
instance Ord Relevance
instance Show Relevance
instance Show InjectiveFun
instance Eq InjectiveFun
instance Show EInterface
instance Monoid 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 Show Lit
instance Ord Lit
instance Eq Lit
instance Show Branch
instance Ord Branch
instance Eq Branch
instance Show Expr
instance Ord Expr
instance Eq Expr
instance Eq Fun
instance Ord Fun
instance Show Fun

module Agda.TypeChecking.CompiledClause
type :-> key value = Map key value
data Case c
Branches :: QName :-> c -> Literal :-> c -> Maybe c -> Case c
conBranches :: Case c -> QName :-> c
litBranches :: Case c -> Literal :-> c
catchAllBranch :: Case c -> Maybe c
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.
Case :: 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 String] -> Term -> CompiledClauses

-- | Absurd case.
Fail :: CompiledClauses
litCase :: Literal -> c -> Case c
conCase :: QName -> c -> Case c
catchAll :: c -> Case c
instance Typeable1 Case
instance Typeable CompiledClauses
instance Data c => Data (Case c)
instance Functor Case
instance Data CompiledClauses
instance Pretty CompiledClauses
instance Pretty a => Pretty (Case a)
instance Show CompiledClauses
instance Pretty a => Show (Case a)
instance Monoid m => Monoid (Case m)

module Agda.Syntax.Internal.Generic
class TermLike a
traverseTerm :: TermLike a => (Term -> Term) -> a -> a
traverseTermM :: (TermLike a, Monad m, Applicative m) => (Term -> m Term) -> a -> m a
foldTerm :: (TermLike a, Monoid m) => (Term -> m) -> a -> m
instance TermLike Type
instance TermLike LevelAtom
instance TermLike PlusLevel
instance TermLike Level
instance TermLike Term
instance TermLike a => TermLike (Abs a)
instance (TermLike a, TermLike b) => TermLike (a, b)
instance TermLike a => TermLike (Maybe a)
instance TermLike a => TermLike [a]
instance TermLike a => TermLike (Arg a)

module Agda.Syntax.Internal.Pattern
data OneHolePatterns
OHPats :: [Arg Pattern] -> (Arg OneHolePattern) -> [Arg Pattern] -> OneHolePatterns
data OneHolePattern
Hole :: OneHolePattern

-- | The type serves the same role as the type argument to <a>ConP</a>.
--   
--   TODO: If a hole is plugged this type may have to be updated in some
--   way.
OHCon :: QName -> (Maybe (Arg Type)) -> OneHolePatterns -> OneHolePattern
plugHole :: Pattern -> OneHolePatterns -> [Arg Pattern]
allHoles :: [Arg Pattern] -> [OneHolePatterns]
allHolesWithContents :: [Arg Pattern] -> [(Pattern, OneHolePatterns)]
instance Show OneHolePattern
instance Show OneHolePatterns

module Agda.TypeChecking.Coverage.Match

-- | We use a special representation of the patterns we're trying to match
--   against a clause. In particular we want to keep track of which
--   variables are blocking a match.
data MPat
VarMP :: Nat -> MPat
ConMP :: QName -> [Arg MPat] -> MPat
LitMP :: Literal -> MPat
WildMP :: MPat
buildMPatterns :: Permutation -> [Arg Pattern] -> [Arg MPat]

-- | If matching is inconclusive (<tt>Block</tt>) we want to know which
--   variable is blocking the match.
data Match a
Yes :: a -> Match a
No :: Match a
Block :: Nat -> Match a
choice :: Match a -> Match a -> Match a
type MatchLit = Literal -> MPat -> Match ()
noMatchLit :: MatchLit
yesMatchLit :: MatchLit

-- | Match the given patterns against a list of clauses
match :: [Clause] -> [Arg Pattern] -> Permutation -> Match Nat

-- | Check if a clause could match given generously chosen literals
matchLits :: Clause -> [Arg Pattern] -> Permutation -> Bool
matchClause :: MatchLit -> [Arg MPat] -> Nat -> Clause -> Match Nat
matchPats :: MatchLit -> [Arg Pattern] -> [Arg MPat] -> Match ()
matchPat :: MatchLit -> Pattern -> MPat -> Match ()
instance Functor Match
instance Monoid a => Monoid (Match a)

module Agda.Syntax.Concrete.Operators.Parser
data ExprView e
LocalV :: Name -> ExprView e
WildV :: e -> ExprView e
OtherV :: e -> ExprView e
AppV :: e -> (NamedArg e) -> ExprView e
OpAppV :: Name -> [OpApp e] -> ExprView e
HiddenArgV :: (Named String e) -> ExprView e
InstanceArgV :: (Named String 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

-- | Combining a hierarchy of parsers.
recursive :: (ReadP tok a -> [ReadP tok a -> ReadP tok a]) -> ReadP tok a

-- | Variant of chainr1
chainr1' :: ReadP t a -> ReadP t (a -> a -> ReadP t a) -> ReadP t a

-- | Variant of chainl1
chainl1' :: ReadP t a -> ReadP t (a -> a -> ReadP t a) -> ReadP t a

-- | Parse a specific identifier as a NamePart
partP :: IsExpr e => String -> ReadP e (Range, NamePart)
binop :: IsExpr e => ReadP e (NewNotation, Range, [e]) -> ReadP e (e -> e -> ReadP a e)
preop :: IsExpr e => ReadP e (NewNotation, Range, [e]) -> ReadP e (e -> ReadP a e)
postop :: IsExpr e => ReadP e (NewNotation, Range, [e]) -> ReadP e (e -> ReadP a e)

-- | Parse the <a>operator part</a> of the given syntax. holes at beginning
--   and end are IGNORED.
opP :: IsExpr e => ReadP e e -> NewNotation -> ReadP e (NewNotation, Range, [e])

-- | Given a name with a syntax spec, and a list of parsed expressions
--   fitting it, rebuild the expression. Note that this function must not
--   parse any input (as guaranteed by the type)
rebuild :: IsExpr e => NewNotation -> Range -> [e] -> ReadP symbol e
rebuildBinding :: ExprView e -> ReadP a LamBinding
($$$) :: (e -> ReadP a e) -> ReadP a e -> ReadP a e

-- | Parse using the appropriate fixity, given a parser parsing the
--   operator part, the name of the operator, and a parser of
--   subexpressions.
infixP :: IsExpr e => ReadP e (NewNotation, Range, [e]) -> ReadP e e -> ReadP e e

-- | Parse using the appropriate fixity, given a parser parsing the
--   operator part, the name of the operator, and a parser of
--   subexpressions.
nonfixP :: IsExpr e => ReadP e (NewNotation, Range, [e]) -> ReadP e e -> ReadP e e

-- | Parse using the appropriate fixity, given a parser parsing the
--   operator part, the name of the operator, and a parser of
--   subexpressions.
prefixP :: IsExpr e => ReadP e (NewNotation, Range, [e]) -> ReadP e e -> ReadP e e

-- | Parse using the appropriate fixity, given a parser parsing the
--   operator part, the name of the operator, and a parser of
--   subexpressions.
postfixP :: IsExpr e => ReadP e (NewNotation, Range, [e]) -> ReadP e e -> ReadP e e

-- | Parse using the appropriate fixity, given a parser parsing the
--   operator part, the name of the operator, and a parser of
--   subexpressions.
infixlP :: IsExpr e => ReadP e (NewNotation, Range, [e]) -> ReadP e e -> ReadP e e

-- | Parse using the appropriate fixity, given a parser parsing the
--   operator part, the name of the operator, and a parser of
--   subexpressions.
infixrP :: IsExpr e => ReadP e (NewNotation, Range, [e]) -> ReadP e e -> ReadP e e
appP :: IsExpr e => ReadP e e -> ReadP e e -> ReadP e e
atomP :: IsExpr e => (Name -> Bool) -> ReadP e e

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 :: !Position -> !Position -> String -> !Char -> String -> [LayoutContext] -> [LexState] -> ParseFlags -> ParseState

-- | position at current input location
parsePos :: ParseState -> !Position

-- | position of last token
parseLastPos :: ParseState -> !Position

-- | the current input
parseInp :: ParseState -> String

-- | the character before the input
parsePrevChar :: ParseState -> !Char

-- | the previous token
parsePrevToken :: ParseState -> String

-- | the stack of layout contexts
parseLayout :: ParseState -> [LayoutContext]

-- | the state of the lexer (states can be nested so we need a stack)
parseLexState :: ParseState -> [LexState]

-- | currently there are no flags
parseFlags :: ParseState -> ParseFlags

-- | What you get if parsing fails.
data ParseError
ParseError :: Position -> String -> String -> String -> ParseError

-- | where the error occured
errPos :: ParseError -> Position

-- | the remaining input
errInput :: ParseError -> String

-- | the previous token
errPrevToken :: ParseError -> String

-- | hopefully an explanation of what happened
errMsg :: ParseError -> String

-- | To do context sensitive lexing alex provides what is called <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 even more general way of parsing a string.
parsePosString :: Position -> ParseFlags -> [LexState] -> Parser a -> String -> ParseResult a

-- | The most general way of parsing a file. The <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)
setParsePos :: Position -> Parser ()
setLastPos :: Position -> 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 :: Position -> 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 Typeable ParseError
instance Show LayoutContext
instance Show ParseFlags
instance Show ParseState
instance HasRange ParseError
instance Show ParseError
instance MonadState ParseState Parser
instance MonadError ParseError Parser
instance Applicative Parser
instance Functor Parser
instance Monad Parser
instance Exception ParseError


-- | This module defines the things required by Alex and some other Alex
--   related things.
module Agda.Syntax.Parser.Alex

-- | This is what the lexer manipulates.
data AlexInput
AlexInput :: !Position -> String -> !Char -> AlexInput

-- | current position
lexPos :: AlexInput -> !Position

-- | current input
lexInput :: AlexInput -> String

-- | previously read character
lexPrevChar :: AlexInput -> !Char

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


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

-- | This is the initial state for parsing a literate file. Code blocks
--   should be enclosed in <tt>\begin{code}</tt> <tt>\end{code}</tt> pairs.
literate :: 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)
instance Functor AlexLastAcc

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, Functor m, 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)

-- | Filter a map based on the keys.
filterKeys :: Ord k => (k -> Bool) -> Map k a -> Map k a


-- | 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] -> [(NameSpaceId, NameSpace)] -> Map QName ModuleName -> Scope
scopeName :: Scope -> ModuleName
scopeParents :: Scope -> [ModuleName]
scopeNameSpaces :: Scope -> [(NameSpaceId, NameSpace)]
scopeImports :: Scope -> Map QName ModuleName
data NameSpaceId
PrivateNS :: NameSpaceId
PublicNS :: NameSpaceId
ImportedNS :: NameSpaceId
OnlyQualifiedNS :: NameSpaceId
localNameSpace :: Access -> NameSpaceId
nameSpaceAccess :: NameSpaceId -> Access
scopeNameSpace :: NameSpaceId -> Scope -> NameSpace

-- | 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 -> ScopeInfo
scopeCurrent :: ScopeInfo -> ModuleName
scopeModules :: ScopeInfo -> Map ModuleName Scope
scopeLocals :: ScopeInfo -> LocalVars
scopePrecedence :: ScopeInfo -> Precedence

-- | Local variables
type LocalVars = [(Name, Name)]

-- | 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 -> NameSpace
nsNames :: NameSpace -> NamesInScope
nsModules :: NameSpace -> ModulesInScope
type ThingsInScope a = Map Name [a]
type NamesInScope = ThingsInScope AbstractName
type ModulesInScope = ThingsInScope AbstractModule
data InScopeTag a
NameTag :: InScopeTag AbstractName
ModuleTag :: InScopeTag AbstractModule
class Eq a => InScope a
inScopeTag :: InScope a => InScopeTag a
inNameSpace :: InScope a => NameSpace -> ThingsInScope a

-- | We distinguish constructor names from other names.
data KindOfName
ConName :: KindOfName
DefName :: KindOfName

-- | Apart from the name, we also record whether it's a constructor or not
--   and what the fixity is.
data AbstractName
AbsName :: QName -> KindOfName -> AbstractName
anameName :: AbstractName -> QName
anameKind :: AbstractName -> KindOfName

-- | For modules we record the arity. I'm not sure that it's every used
--   anywhere.
data AbstractModule
AbsModule :: ModuleName -> AbstractModule
amodName :: AbstractModule -> ModuleName
blockOfLines :: String -> [String] -> [String]
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) -> NameSpace -> NameSpace

-- | Zip together two name spaces.
zipNameSpace :: (NamesInScope -> NamesInScope -> NamesInScope) -> (ModulesInScope -> ModulesInScope -> ModulesInScope) -> NameSpace -> NameSpace -> NameSpace

-- | Map monadic function over a namespace.
mapNameSpaceM :: Monad m => (NamesInScope -> m NamesInScope) -> (ModulesInScope -> m ModulesInScope) -> 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) -> Scope -> Scope

-- | Same as <a>mapScope</a> but applies the same function to all name
--   spaces.
mapScope_ :: (NamesInScope -> NamesInScope) -> (ModulesInScope -> ModulesInScope) -> Scope -> Scope

-- | Map monadic functions over the names and modules in a scope.
mapScopeM :: (Functor m, Monad m) => (NameSpaceId -> NamesInScope -> m NamesInScope) -> (NameSpaceId -> ModulesInScope -> m ModulesInScope) -> Scope -> m Scope

-- | Same as <a>mapScopeM</a> but applies the same function to both the
--   public and private name spaces.
mapScopeM_ :: (Functor m, Monad m) => (NamesInScope -> m NamesInScope) -> (ModulesInScope -> m ModulesInScope) -> 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) -> 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) -> Scope -> 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
setNameSpace :: NameSpaceId -> 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

-- | Add a module to a scope.
addModuleToScope :: NameSpaceId -> Name -> AbstractModule -> Scope -> Scope

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

-- | Restrict the private name space of a scope
restrictPrivate :: Scope -> Scope

-- | Remove names that can only be used qualified (when opening a scope)
removeOnlyQualified :: Scope -> Scope

-- | Get the public parts of the public modules of a scope
publicModules :: ScopeInfo -> Map ModuleName Scope
everythingInScope :: ScopeInfo -> NameSpace

-- | Look up a name in the scope
scopeLookup :: InScope a => QName -> ScopeInfo -> [a]
scopeLookup' :: InScope a => QName -> ScopeInfo -> [(a, Access)]

-- | Find the shortest concrete name that maps (uniquely) to a given
--   abstract name.
inverseScopeLookup :: Either ModuleName QName -> ScopeInfo -> Maybe QName

-- | Takes the first component of <a>inverseScopeLookup</a>.
inverseScopeLookupName :: QName -> ScopeInfo -> Maybe QName

-- | Takes the second component of <a>inverseScopeLookup</a>.
inverseScopeLookupModule :: ModuleName -> ScopeInfo -> Maybe QName
instance Typeable NameSpaceId
instance Typeable KindOfName
instance Typeable AbstractName
instance Typeable AbstractModule
instance Typeable NameSpace
instance Typeable Scope
instance Typeable ScopeInfo
instance Data NameSpaceId
instance Eq NameSpaceId
instance Bounded NameSpaceId
instance Enum NameSpaceId
instance Eq KindOfName
instance Show KindOfName
instance Data KindOfName
instance Data AbstractName
instance Data AbstractModule
instance Data NameSpace
instance Data Scope
instance Data ScopeInfo
instance SetRange AbstractName
instance HasRange AbstractName
instance Show AbstractModule
instance Show AbstractName
instance Show NameSpace
instance Show NameSpaceId
instance Show Scope
instance Show ScopeInfo
instance Ord AbstractModule
instance Eq AbstractModule
instance Ord AbstractName
instance Eq AbstractName
instance InScope AbstractModule
instance InScope AbstractName
instance KillRange ScopeInfo


-- | 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 posisiton of an expression or the
--   concrete syntax that an internal expression originates from.
module Agda.Syntax.Info
data Info
Nope :: Info
data MetaInfo
MetaInfo :: Range -> ScopeInfo -> Maybe Nat -> MetaInfo
metaRange :: MetaInfo -> Range
metaScope :: MetaInfo -> ScopeInfo
metaNumber :: MetaInfo -> Maybe Nat

-- | For a general expression we can either remember just the source code
--   position or the entire concrete expression it came from.
data ExprInfo
ExprRange :: Range -> ExprInfo

-- | Even if we store the original expression we have to know whether to
--   put parenthesis around it.
ExprSource :: Range -> (Precedence -> Expr) -> ExprInfo
data ModuleInfo
ModuleInfo :: Range -> Range -> Maybe Name -> Maybe OpenShortHand -> Maybe ImportDirective -> ModuleInfo
minfoRange :: ModuleInfo -> Range
minfoAsTo :: ModuleInfo -> Range
minfoAsName :: ModuleInfo -> Maybe Name
minfoOpenShort :: ModuleInfo -> Maybe OpenShortHand
minfoDirective :: ModuleInfo -> Maybe ImportDirective
newtype LetInfo
LetRange :: Range -> LetInfo
data DefInfo
DefInfo :: Fixity' -> Access -> IsAbstract -> DeclInfo -> DefInfo
defFixity :: DefInfo -> Fixity'
defAccess :: DefInfo -> Access
defAbstract :: DefInfo -> IsAbstract
defInfo :: DefInfo -> DeclInfo
mkDefInfo :: Name -> Fixity' -> Access -> IsAbstract -> Range -> DefInfo
data DeclInfo
DeclInfo :: Name -> Range -> DeclInfo
declName :: DeclInfo -> Name
declRange :: DeclInfo -> Range
newtype LHSInfo
LHSRange :: Range -> LHSInfo
data PatInfo
PatRange :: Range -> PatInfo
PatSource :: Range -> (Precedence -> Pattern) -> PatInfo
instance Typeable MetaInfo
instance Typeable ExprInfo
instance Typeable ModuleInfo
instance Typeable LetInfo
instance Typeable DeclInfo
instance Typeable DefInfo
instance Typeable LHSInfo
instance Typeable PatInfo
instance (Show OpenShortHand, Show ImportDirective) => Show ModuleInfo
instance Data MetaInfo
instance Show MetaInfo
instance Data ExprInfo
instance Show ExprInfo
instance Data ModuleInfo
instance Data LetInfo
instance Show LetInfo
instance Data DeclInfo
instance Show DeclInfo
instance Data DefInfo
instance Show DefInfo
instance Data LHSInfo
instance Show LHSInfo
instance Data PatInfo
instance KillRange PatInfo
instance HasRange PatInfo
instance Show PatInfo
instance KillRange LHSInfo
instance HasRange LHSInfo
instance KillRange DeclInfo
instance HasRange DeclInfo
instance KillRange DefInfo
instance HasRange DefInfo
instance KillRange LetInfo
instance HasRange LetInfo
instance KillRange ModuleInfo
instance HasRange ModuleInfo
instance KillRange ExprInfo
instance HasRange ExprInfo
instance KillRange MetaInfo
instance HasRange MetaInfo


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

-- | Bound variables
Var :: Name -> Expr

-- | Constants (i.e. axioms, functions, and datatypes)
Def :: QName -> Expr

-- | Constructors
Con :: AmbiguousQName -> Expr

-- | Literals
Lit :: Literal -> Expr

-- | meta variable for interaction
QuestionMark :: MetaInfo -> Expr

-- | meta variable for hidden argument (must be inferred locally)
Underscore :: MetaInfo -> Expr
App :: ExprInfo -> Expr -> (NamedArg Expr) -> Expr

-- | with application
WithApp :: ExprInfo -> Expr -> [Expr] -> Expr
Lam :: ExprInfo -> LamBinding -> Expr -> Expr
AbsurdLam :: ExprInfo -> Hiding -> Expr
ExtendedLam :: ExprInfo -> DefInfo -> QName -> [Clause] -> Expr
Pi :: ExprInfo -> Telescope -> Expr -> Expr

-- | independent function space
Fun :: ExprInfo -> (Arg Expr) -> Expr -> Expr

-- | Set, Set1, Set2, ...
Set :: ExprInfo -> Nat -> Expr
Prop :: ExprInfo -> Expr
Let :: ExprInfo -> [LetBinding] -> Expr -> Expr

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

-- | record construction
Rec :: ExprInfo -> [(Name, Expr)] -> Expr

-- | record update
RecUpdate :: ExprInfo -> Expr -> [(Name, Expr)] -> Expr

-- | scope annotation
ScopedExpr :: ScopeInfo -> Expr -> Expr
QuoteGoal :: ExprInfo -> Name -> Expr -> Expr
Quote :: ExprInfo -> Expr
QuoteTerm :: ExprInfo -> Expr

-- | The splicing construct: unquote ...
Unquote :: ExprInfo -> Expr

-- | for printing DontCare from Syntax.Internal
DontCare :: Expr -> Expr
data Declaration

-- | postulate
Axiom :: DefInfo -> Relevance -> 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 :: DeclInfo -> [Declaration] -> Declaration
Section :: ModuleInfo -> ModuleName -> [TypedBindings] -> [Declaration] -> Declaration
Apply :: ModuleInfo -> ModuleName -> ModuleApplication -> (Map QName QName) -> (Map ModuleName ModuleName) -> Declaration
Import :: ModuleInfo -> ModuleName -> Declaration
Pragma :: Range -> Pragma -> Declaration

-- | only retained for highlighting purposes
Open :: ModuleInfo -> ModuleName -> Declaration
FunDef :: DefInfo -> QName -> [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 QName) -> [LamBinding] -> Expr -> [Declaration] -> Declaration

-- | scope annotation
ScopedDecl :: ScopeInfo -> [Declaration] -> Declaration
class GetDefInfo a
getDefInfo :: GetDefInfo a => a -> Maybe DefInfo
data ModuleApplication
SectionApp :: [TypedBindings] -> ModuleName -> [NamedArg Expr] -> ModuleApplication
RecordModuleIFS :: ModuleName -> ModuleApplication
data Pragma
OptionsPragma :: [String] -> Pragma
BuiltinPragma :: String -> Expr -> Pragma
CompiledPragma :: QName -> String -> Pragma
CompiledTypePragma :: QName -> String -> Pragma
CompiledDataPragma :: QName -> String -> [String] -> Pragma
CompiledEpicPragma :: QName -> String -> Pragma
CompiledJSPragma :: QName -> String -> Pragma
StaticPragma :: QName -> Pragma
EtaPragma :: QName -> Pragma
data LetBinding

-- | LetBind info rel name type defn
LetBind :: LetInfo -> Relevance -> Name -> Expr -> Expr -> LetBinding
LetApply :: ModuleInfo -> ModuleName -> ModuleApplication -> (Map QName QName) -> (Map ModuleName ModuleName) -> LetBinding

-- | only for highlighting and abstractToConcrete
LetOpen :: ModuleInfo -> ModuleName -> LetBinding

-- | Only <a>Axiom</a>s.
type TypeSignature = Declaration
type Constructor = 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 :: Hiding -> Relevance -> Name -> LamBinding

-- | . <tt>(xs:e)</tt> or <tt>{xs:e}</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. I might be tempting to simplify this to only bind a
--   single name at a time. This would mean that we would have to typecheck
--   the type several times (<tt>x,y:A</tt> vs. <tt>x:A; y:A</tt>). In most
--   cases this wouldn't really be a problem, but it's good principle to
--   not do extra work unless you have to.
data TypedBinding
TBind :: Range -> [Name] -> Expr -> TypedBinding
TNoBind :: Expr -> TypedBinding
type Telescope = [TypedBindings]

-- | 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
Clause :: LHS -> RHS -> [Declaration] -> Clause
data RHS
RHS :: Expr -> RHS
AbsurdRHS :: RHS

-- | The <a>QName</a> is the name of the with function.
WithRHS :: QName -> [Expr] -> [Clause] -> RHS

-- | The <a>QName</a>s are the names of the generated with functions. One
--   for each <a>Expr</a>. The RHS shouldn't be another RewriteRHS
RewriteRHS :: [QName] -> [Expr] -> RHS -> [Declaration] -> RHS
data LHS
LHS :: LHSInfo -> QName -> [NamedArg Pattern] -> [Pattern] -> LHS

-- | Parameterised over the type of dot patterns.
data Pattern' e
VarP :: Name -> Pattern' e
ConP :: PatInfo -> AmbiguousQName -> [NamedArg (Pattern' e)] -> Pattern' e

-- | defined pattern
DefP :: PatInfo -> QName -> [NamedArg (Pattern' e)] -> Pattern' e
WildP :: PatInfo -> Pattern' e
AsP :: PatInfo -> Name -> (Pattern' e) -> Pattern' e
DotP :: PatInfo -> e -> Pattern' e
AbsurdP :: PatInfo -> Pattern' e
LitP :: Literal -> Pattern' e

-- | generated at type checking for implicit arguments
ImplicitP :: PatInfo -> Pattern' e
type Pattern = Pattern' Expr

-- | 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.
allNames :: Declaration -> Seq QName

-- | The name defined by the given axiom.
--   
--   Precondition: The declaration has to be an <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
instance Typeable1 Pattern'
instance Typeable Expr
instance Typeable Clause
instance Typeable LHS
instance Typeable RHS
instance Typeable Declaration
instance Typeable TypedBindings
instance Typeable TypedBinding
instance Typeable LamBinding
instance Typeable Pragma
instance Typeable ModuleApplication
instance Typeable LetBinding
instance Data e => Data (Pattern' e)
instance Show e => Show (Pattern' e)
instance Functor Pattern'
instance Foldable Pattern'
instance Traversable Pattern'
instance Data Expr
instance Show Expr
instance Data Clause
instance Show Clause
instance Data LHS
instance Show LHS
instance Data RHS
instance Show RHS
instance Data Declaration
instance Show Declaration
instance Data TypedBindings
instance Show TypedBindings
instance Data TypedBinding
instance Show TypedBinding
instance Data LamBinding
instance Show LamBinding
instance Data Pragma
instance Show Pragma
instance Data ModuleApplication
instance Show ModuleApplication
instance Data LetBinding
instance Show LetBinding
instance AnyAbstract Declaration
instance AnyAbstract a => AnyAbstract [a]
instance KillRange LetBinding
instance KillRange RHS
instance KillRange Clause
instance KillRange LHS
instance KillRange e => KillRange (Pattern' e)
instance KillRange x => KillRange (ThingWithFixity x)
instance KillRange ModuleApplication
instance KillRange Declaration
instance KillRange Relevance
instance KillRange Expr
instance KillRange TypedBinding
instance KillRange TypedBindings
instance KillRange LamBinding
instance HasRange LetBinding
instance HasRange RHS
instance HasRange Clause
instance HasRange LHS
instance HasRange (Pattern' e)
instance HasRange Declaration
instance HasRange Expr
instance HasRange TypedBinding
instance HasRange TypedBindings
instance HasRange LamBinding
instance GetDefInfo Declaration

module Agda.Syntax.Abstract.Views
data AppView
Application :: Expr -> [NamedArg Expr] -> AppView
appView :: Expr -> AppView
unAppView :: AppView -> Expr

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>,
--   and <tt>abstract</tt> modifiers have been distributed to the
--   individual declarations.
data NiceDeclaration

-- | Axioms and functions can be declared irrelevant.
Axiom :: Range -> Fixity' -> Access -> Relevance -> Name -> Expr -> NiceDeclaration
NiceField :: Range -> Fixity' -> Access -> IsAbstract -> Name -> (Arg Expr) -> NiceDeclaration
PrimitiveFunction :: Range -> Fixity' -> Access -> IsAbstract -> Name -> Expr -> NiceDeclaration
NiceMutual :: Range -> [NiceDeclaration] -> NiceDeclaration
NiceModule :: Range -> Access -> IsAbstract -> QName -> Telescope -> [Declaration] -> NiceDeclaration
NiceModuleMacro :: Range -> Access -> IsAbstract -> 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 -> Name -> [LamBinding] -> Expr -> NiceDeclaration
NiceDataSig :: Range -> Fixity' -> Access -> Name -> [LamBinding] -> Expr -> NiceDeclaration
FunSig :: Range -> Fixity' -> Access -> Relevance -> Name -> Expr -> NiceDeclaration

-- | block of function clauses (we have seen the type signature before)
FunDef :: Range -> [Declaration] -> Fixity' -> IsAbstract -> Name -> [Clause] -> NiceDeclaration
DataDef :: Range -> Fixity' -> IsAbstract -> Name -> [LamBinding] -> [NiceConstructor] -> NiceDeclaration
RecDef :: Range -> Fixity' -> IsAbstract -> Name -> (Maybe (ThingWithFixity Name)) -> [LamBinding] -> [NiceDeclaration] -> 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 -> LHS -> RHS -> WhereClause -> [Clause] -> Clause

-- | The exception type.
data DeclarationException
MultipleFixityDecls :: [(Name, [Fixity'])] -> DeclarationException
MissingDefinition :: Name -> DeclarationException
MissingWithClauses :: Name -> DeclarationException
MissingTypeSignature :: LHS -> DeclarationException
MissingDataSignature :: Name -> DeclarationException
NotAllowedInMutual :: NiceDeclaration -> DeclarationException
UnknownNamesInFixityDecl :: [Name] -> DeclarationException
Codata :: Range -> DeclarationException
DeclarationPanic :: String -> DeclarationException
UselessPrivate :: Range -> DeclarationException
UselessAbstract :: Range -> DeclarationException

-- | in a mutual block, a clause could belong to any of the <tt>[Name]</tt>
--   type signatures
AmbiguousFunClauses :: LHS -> [Name] -> DeclarationException
type Nice = StateT NiceEnv (Either DeclarationException)
runNice :: Nice a -> Either DeclarationException a
niceDeclarations :: [Declaration] -> Nice [NiceDeclaration]
notSoNiceDeclarations :: [NiceDeclaration] -> [Declaration]
instance Typeable Clause
instance Typeable NiceDeclaration
instance Typeable DeclarationException
instance Data Clause
instance Show Clause
instance Data NiceDeclaration
instance Show NiceDeclaration
instance Eq InMutual
instance Show InMutual
instance Eq DataRecOrFun
instance Ord DataRecOrFun
instance Show DeclarationException
instance Error DeclarationException
instance HasRange NiceDeclaration
instance HasRange DeclarationException

module Agda.Syntax.Strict

-- | <tt>force</tt> is the recursive <tt>const 0</tt> function, to force
--   Haskell to evaluate.
class Strict a
force :: Strict a => a -> Int
($!!) :: Strict a => (a -> b) -> a -> b
strict :: Strict a => a -> a
instance Strict Token
instance Strict a => Strict (Abs a)
instance Strict a => Strict (Maybe a)
instance Strict a => Strict [a]
instance Strict a => Strict (Arg a)
instance (Strict a, Strict b) => Strict (a, b)
instance Strict NiceDeclaration
instance Strict Pragma
instance Strict Declaration
instance Strict Expr
instance Strict ClauseBody
instance Strict LevelAtom
instance Strict PlusLevel
instance Strict Level
instance Strict Sort
instance Strict Type
instance Strict Term


-- | 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 <a>Name</a>).
--   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


-- | 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 :: Integer -> Integer -> Range
from :: Range -> Integer
to :: Range -> Integer

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

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

-- | Converts a range to a list of positions.
toList :: Range -> [Integer]

-- | Calculates a set of ranges associated with a name.
--   
--   For an operator the ranges associated with the NameParts are returned.
--   Otherwise the range associated with the Name is returned.
--   
--   A boolean, indicating operatorness, is also returned.
getRanges :: Name -> ([Range], Bool)

-- | Like <a>getRanges</a>, but for <a>QName</a>s. Note that the module
--   part of the name is thrown away; only the base part is used.
getRangesA :: QName -> ([Range], Bool)

-- | Converts a <a>Range</a> to a list of <a>Range</a>s.
rToR :: Range -> [Range]

-- | All the properties.
tests :: IO Bool
instance Typeable Range
instance Eq Range
instance Ord Range
instance Show Range
instance Data Range
instance CoArbitrary Range
instance Arbitrary Range


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

-- | Various more or less syntactic aspects of the code. (These cannot
--   overlap.)
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
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

-- | Other aspects. (These can overlap with each other and with
--   <a>Aspect</a>s.)
data OtherAspect
Error :: OtherAspect
DottedPattern :: OtherAspect
UnsolvedMeta :: OtherAspect
TerminationProblem :: 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

-- | Meta information which can be associated with a character/character
--   range.
data MetaInfo
MetaInfo :: Maybe Aspect -> [OtherAspect] -> Maybe String -> Maybe (TopLevelModuleName, Integer) -> MetaInfo
aspect :: MetaInfo -> Maybe Aspect
otherAspects :: MetaInfo -> [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 :: MetaInfo -> Maybe String

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

-- | A <a>File</a> is a mapping from file positions to meta information.
--   
--   The first position in the file has number 1.
data File

-- | Syntax highlighting information for a given source file.
type HighlightingInfo = CompressedFile

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

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

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

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

-- | A compressed <a>File</a>, in which consecutive positions with the same
--   <a>MetaInfo</a> are stored together.
type CompressedFile = [(Range, MetaInfo)]

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

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

-- | All the properties.
tests :: IO Bool
instance Typeable NameKind
instance Typeable Aspect
instance Typeable OtherAspect
instance Typeable MetaInfo
instance Typeable File
instance Eq NameKind
instance Show NameKind
instance Data NameKind
instance Eq Aspect
instance Show Aspect
instance Data Aspect
instance Eq OtherAspect
instance Show OtherAspect
instance Enum OtherAspect
instance Bounded OtherAspect
instance Data OtherAspect
instance Eq MetaInfo
instance Show MetaInfo
instance Data MetaInfo
instance Eq File
instance Show File
instance Data File
instance CoArbitrary File
instance Arbitrary File
instance CoArbitrary MetaInfo
instance Arbitrary MetaInfo
instance CoArbitrary OtherAspect
instance Arbitrary OtherAspect
instance CoArbitrary NameKind
instance Arbitrary NameKind
instance CoArbitrary Aspect
instance Arbitrary Aspect
instance Monoid File
instance Monoid MetaInfo


-- | The parser is generated by Happy
--   (<a>http://www.haskell.org/happy</a>).
module Agda.Syntax.Parser.Parser

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

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

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

-- | Test suite.
tests :: IO Bool

module Agda.Syntax.Parser

-- | Wrapped Parser type.
data Parser a
parse :: Strict a => Parser a -> String -> IO a
parseLiterate :: Strict a => Parser a -> String -> IO a
parsePosString :: Strict a => Parser a -> Position -> String -> IO a
parseFile' :: Strict a => Parser a -> AbsolutePath -> IO a

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

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

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

-- | What you get if parsing fails.
data ParseError
ParseError :: Position -> String -> String -> String -> ParseError

-- | where the error occured
errPos :: ParseError -> Position

-- | the remaining input
errInput :: ParseError -> String

-- | the previous token
errPrevToken :: ParseError -> String

-- | hopefully an explanation of what happened
errMsg :: ParseError -> String


-- | This module defines the exception handler.
module Agda.Interaction.Exceptions
handleParseException :: (ParseError -> IO a) -> ParseError -> IO a

-- | Note that <a>failOnException</a> only catches <a>ParseError</a>s.
failOnException :: (Range -> String -> IO a) -> IO a -> IO a

module Agda.TypeChecking.Monad.Base
data TCState
TCSt :: FreshThings -> MetaStore -> InteractionPoints -> Constraints -> Constraints -> Signature -> Signature -> Set ModuleName -> ModuleToSource -> VisitedModules -> Maybe ModuleName -> ScopeInfo -> PragmaOptions -> Statistics -> Map QName (Int, Int) -> Map MutualId (Set QName) -> BuiltinThings PrimFun -> BuiltinThings PrimFun -> Set String -> PersistentTCState -> TCState
stFreshThings :: TCState -> FreshThings
stMetaStore :: TCState -> MetaStore
stInteractionPoints :: TCState -> InteractionPoints
stAwakeConstraints :: TCState -> Constraints
stSleepingConstraints :: TCState -> Constraints
stSignature :: TCState -> Signature
stImports :: TCState -> Signature
stImportedModules :: TCState -> Set ModuleName
stModuleToSource :: TCState -> ModuleToSource
stVisitedModules :: TCState -> VisitedModules

-- | The current module is available after it has been type checked.
stCurrentModule :: TCState -> Maybe ModuleName
stScope :: TCState -> ScopeInfo

-- | Options applying to the current file. <tt>OPTIONS</tt> pragmas only
--   affect this field.
stPragmaOptions :: TCState -> PragmaOptions
stStatistics :: TCState -> Statistics
stExtLambdaTele :: TCState -> Map QName (Int, Int)
stMutualBlocks :: TCState -> Map MutualId (Set QName)
stLocalBuiltins :: TCState -> BuiltinThings PrimFun
stImportedBuiltins :: TCState -> BuiltinThings PrimFun

-- | Imports that should be generated by the compiler (this includes
--   imports from imported modules).
stHaskellImports :: TCState -> Set String
stPersistent :: TCState -> PersistentTCState

-- | A part of the state which is not reverted when an error is thrown or
--   the state is reset.
data PersistentTCState
PersistentTCSt :: DecodedModules -> CommandLineOptions -> PersistentTCState
stDecodedModules :: PersistentTCState -> DecodedModules

-- | Options which apply to all files, unless overridden.
stPersistentOptions :: PersistentTCState -> CommandLineOptions
data FreshThings
Fresh :: MetaId -> InteractionId -> MutualId -> NameId -> CtxId -> ProblemId -> Integer -> FreshThings
fMeta :: FreshThings -> MetaId
fInteraction :: FreshThings -> InteractionId
fMutual :: FreshThings -> MutualId
fName :: FreshThings -> NameId
fCtx :: FreshThings -> CtxId
fProblem :: FreshThings -> ProblemId

-- | Can be used for various things.
fInteger :: FreshThings -> Integer
initState :: TCState
stBuiltinThings :: TCState -> BuiltinThings PrimFun
newtype ProblemId
ProblemId :: Nat -> ProblemId
data ModuleInfo
ModuleInfo :: Interface -> Bool -> ClockTime -> ModuleInfo
miInterface :: ModuleInfo -> Interface

-- | <a>True</a> if warnings were encountered when the module was type
--   checked.
miWarnings :: ModuleInfo -> Bool

-- | The modification time stamp of the interface file when the interface
--   was read or written. Alternatively, if warnings were encountered (in
--   which case there may not be any up-to-date interface file), the time
--   at which the interface was produced (approximately).
miTimeStamp :: ModuleInfo -> ClockTime
type VisitedModules = Map TopLevelModuleName ModuleInfo
type DecodedModules = Map TopLevelModuleName (Interface, ClockTime)
data Interface
Interface :: [ModuleName] -> ModuleName -> Map ModuleName Scope -> ScopeInfo -> Signature -> BuiltinThings String -> Set String -> HighlightingInfo -> [OptionsPragma] -> Interface
iImportedModules :: Interface -> [ModuleName]
iModuleName :: Interface -> ModuleName
iScope :: Interface -> Map ModuleName Scope
iInsideScope :: Interface -> ScopeInfo
iSignature :: Interface -> Signature
iBuiltin :: Interface -> BuiltinThings String

-- | Haskell imports listed in (transitively) imported modules are not
--   included here.
iHaskellImports :: Interface -> Set String
iHighlighting :: Interface -> HighlightingInfo

-- | Pragma options set in the file.
iPragmaOptions :: Interface -> [OptionsPragma]
data Closure a
Closure :: Signature -> TCEnv -> ScopeInfo -> a -> Closure a
clSignature :: Closure a -> Signature
clEnv :: Closure a -> TCEnv
clScope :: Closure a -> ScopeInfo
clValue :: Closure a -> a
buildClosure :: a -> TCM (Closure a)
type Constraints = [ProblemConstraint]
data ProblemConstraint
PConstr :: ProblemId -> Closure Constraint -> ProblemConstraint
constraintProblem :: 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
IsEmpty :: Type -> Constraint
FindInScope :: MetaId -> Constraint
data Comparison
CmpEq :: Comparison
CmpLeq :: Comparison

-- | A thing tagged with the context it came from.
data Open a
OpenThing :: [CtxId] -> a -> Open a
data Judgement t a
HasType :: a -> t -> Judgement t a
jMetaId :: Judgement t a -> a
jMetaType :: Judgement t a -> t
IsSort :: a -> t -> Judgement t a
jMetaId :: Judgement t a -> a
jMetaType :: Judgement t a -> t
data MetaVariable
MetaVar :: MetaInfo -> MetaPriority -> Permutation -> Judgement Type 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 <a>permutation</a> will throw away the ones it does not depend on
mvPermutation :: MetaVariable -> Permutation
mvJudgement :: MetaVariable -> Judgement Type 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
InstV :: Term -> MetaInstantiation

-- | solved by <tt>Lam .. Sort s</tt>
InstS :: Term -> MetaInstantiation

-- | unsolved
Open :: MetaInstantiation

-- | open, to be instantiated as <a>implicit from scope</a>
OpenIFS :: MetaInstantiation

-- | solution blocked by unsolved constraints
BlockedConst :: Term -> MetaInstantiation
PostponedTypeCheckingProblem :: (Closure (Expr, Type, TCM Bool)) -> MetaInstantiation
newtype MetaPriority
MetaPriority :: Int -> MetaPriority

-- | TODO: Not so nice.
type MetaInfo = Closure Range
type MetaStore = Map MetaId MetaVariable
normalMetaPriority :: MetaPriority
lowMetaPriority :: MetaPriority
highMetaPriority :: MetaPriority
getMetaInfo :: MetaVariable -> MetaInfo
getMetaScope :: MetaVariable -> ScopeInfo
getMetaEnv :: MetaVariable -> TCEnv
getMetaSig :: MetaVariable -> Signature
type InteractionPoints = Map InteractionId MetaId
newtype InteractionId
InteractionId :: Nat -> InteractionId
data Signature
Sig :: Sections -> Definitions -> Signature
sigSections :: Signature -> Sections
sigDefinitions :: Signature -> Definitions
type Sections = Map ModuleName Section
type Definitions = Map QName Definition
data Section
Section :: Telescope -> Nat -> Section
secTelescope :: Section -> Telescope

-- | This is the number of parameters when we're inside the section and 0
--   outside. It's used to know how much of the context to apply function
--   from the section to when translating from abstract to internal syntax.
secFreeVars :: Section -> Nat
emptySignature :: Signature
data DisplayForm

-- | The three arguments are:
--   
--   <ul>
--   <li><tt>n</tt>: number of free variables;</li>
--   <li>Patterns for arguments, one extra free var which represents
--   pattern vars. There should <tt>n</tt> of them.</li>
--   <li>Display form. <tt>n</tt> free variables.</li>
--   </ul>
Display :: Nat -> [Term] -> DisplayTerm -> DisplayForm
data DisplayTerm
DWithApp :: [DisplayTerm] -> Args -> DisplayTerm
DCon :: QName -> [Arg DisplayTerm] -> DisplayTerm
DDef :: QName -> [Arg DisplayTerm] -> DisplayTerm
DDot :: Term -> DisplayTerm
DTerm :: Term -> DisplayTerm
defaultDisplayForm :: QName -> [Open DisplayForm]
data Definition
Defn :: Relevance -> QName -> Type -> [Open DisplayForm] -> MutualId -> CompiledRepresentation -> Defn -> Definition

-- | Some defs can be irrelevant (but not hidden).
defRelevance :: Definition -> Relevance
defName :: Definition -> QName

-- | Type of the lifted definition.
defType :: Definition -> Type
defDisplay :: Definition -> [Open DisplayForm]
defMutual :: Definition -> MutualId
defCompiledRep :: Definition -> CompiledRepresentation
theDef :: Definition -> Defn
type HaskellCode = String
type HaskellType = String
type EpicCode = String
type JSCode = Exp
data HaskellRepresentation
HsDefn :: HaskellType -> HaskellCode -> HaskellRepresentation
HsType :: HaskellType -> HaskellRepresentation
data Polarity
Covariant :: Polarity
Contravariant :: Polarity
Invariant :: Polarity
data CompiledRepresentation
CompiledRep :: Maybe HaskellRepresentation -> Maybe EpicCode -> Maybe JSCode -> CompiledRepresentation
compiledHaskell :: CompiledRepresentation -> Maybe HaskellRepresentation
compiledEpic :: CompiledRepresentation -> Maybe EpicCode
compiledJS :: CompiledRepresentation -> Maybe JSCode
noCompiledRep :: CompiledRepresentation

-- | <a>Positive</a> means strictly positive and <a>Negative</a> means not
--   strictly positive.
data Occurrence
Positive :: Occurrence
Negative :: Occurrence
Unused :: Occurrence
data Defn
Axiom :: Defn
Function :: [Clause] -> CompiledClauses -> FunctionInverse -> [Polarity] -> [Occurrence] -> IsAbstract -> Delayed -> Maybe (QName, Int) -> Bool -> Defn
funClauses :: Defn -> [Clause]
funCompiled :: Defn -> CompiledClauses
funInv :: Defn -> FunctionInverse
funPolarity :: Defn -> [Polarity]
funArgOccurrences :: Defn -> [Occurrence]
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 (QName, Int)

-- | Should calls to this function be normalised at compile-time?
funStatic :: Defn -> Bool
Datatype :: Nat -> Nat -> Induction -> (Maybe Clause) -> [QName] -> Sort -> [Polarity] -> [Occurrence] -> IsAbstract -> Defn
dataPars :: Defn -> Nat
dataIxs :: Defn -> Nat
dataInduction :: Defn -> Induction
dataClause :: Defn -> (Maybe Clause)
dataCons :: Defn -> [QName]
dataSort :: Defn -> Sort
dataPolarity :: Defn -> [Polarity]
dataArgOccurrences :: Defn -> [Occurrence]
dataAbstr :: Defn -> IsAbstract
Record :: Nat -> Maybe Clause -> QName -> Bool -> Type -> [Arg QName] -> Telescope -> [Polarity] -> [Occurrence] -> Bool -> IsAbstract -> Defn
recPars :: Defn -> Nat
recClause :: Defn -> Maybe Clause

-- | Constructor name.
recCon :: Defn -> QName
recNamedCon :: Defn -> Bool

-- | The record constructor's type.
recConType :: Defn -> Type
recFields :: Defn -> [Arg QName]

-- | The record field telescope
recTel :: Defn -> Telescope
recPolarity :: Defn -> [Polarity]
recArgOccurrences :: Defn -> [Occurrence]
recEtaEquality :: Defn -> Bool
recAbstr :: Defn -> IsAbstract
Constructor :: Nat -> QName -> QName -> IsAbstract -> Induction -> Defn
conPars :: Defn -> Nat
conSrcCon :: Defn -> QName
conData :: Defn -> QName
conAbstr :: Defn -> IsAbstract

-- | Inductive or coinductive?
conInd :: Defn -> Induction

-- | Primitive or builtin functions.
Primitive :: IsAbstract -> String -> Maybe [Clause] -> Maybe CompiledClauses -> Defn
primAbstr :: Defn -> IsAbstract
primName :: Defn -> String

-- | <a>Nothing</a> for primitive functions, <tt><a>Just</a> something</tt>
--   for builtin functions.
primClauses :: Defn -> Maybe [Clause]

-- | <a>Nothing</a> for primitive functions, <tt><a>Just</a> something</tt>
--   for builtin functions.
primCompiled :: Defn -> Maybe CompiledClauses
defIsRecord :: Defn -> Bool
newtype Fields
Fields :: [(Name, Type)] -> Fields
data Reduced no yes
NoReduction :: no -> Reduced no yes
YesReduction :: yes -> Reduced no yes
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)]
notReduced :: a -> MaybeReduced a
reduced :: Blocked (Arg Term) -> MaybeReduced (Arg Term)
data PrimFun
PrimFun :: QName -> Arity -> ([Arg Term] -> TCM (Reduced MaybeReducedArgs Term)) -> PrimFun
primFunName :: PrimFun -> QName
primFunArity :: PrimFun -> Arity
primFunImplementation :: PrimFun -> [Arg Term] -> TCM (Reduced MaybeReducedArgs Term)
defClauses :: Definition -> [Clause]
defCompiled :: Definition -> Maybe CompiledClauses
defJSDef :: Definition -> Maybe JSCode
defEpicDef :: Definition -> Maybe EpicCode

-- | Used to specify whether something should be delayed.
data Delayed
Delayed :: Delayed
NotDelayed :: Delayed

-- | Are the clauses of this definition delayed?
defDelayed :: Definition -> Delayed
defAbstract :: Definition -> IsAbstract
data FunctionInverse
NotInjective :: FunctionInverse
Inverse :: (Map TermHead Clause) -> FunctionInverse
data TermHead
SortHead :: TermHead
PiHead :: TermHead
ConHead :: QName -> TermHead
newtype MutualId
MutId :: Int32 -> MutualId
type Statistics = Map String Integer
data Call
CheckClause :: Type -> Clause -> (Maybe Clause) -> Call
CheckPattern :: Pattern -> Telescope -> Type -> (Maybe a) -> Call
CheckLetBinding :: LetBinding -> (Maybe ()) -> Call
InferExpr :: Expr -> (Maybe (Term, Type)) -> Call
CheckExpr :: Expr -> Type -> (Maybe Term) -> Call
CheckDotPattern :: Expr -> Term -> (Maybe Constraints) -> Call
CheckPatternShadowing :: Clause -> (Maybe ()) -> Call
IsTypeCall :: Expr -> Sort -> (Maybe Type) -> Call
IsType_ :: Expr -> (Maybe Type) -> Call
InferVar :: Name -> (Maybe (Term, Type)) -> Call
InferDef :: Range -> QName -> (Maybe (Term, Type)) -> Call
CheckArguments :: Range -> [NamedArg Expr] -> Type -> Type -> (Maybe (Args, Type)) -> Call
CheckDataDef :: Range -> Name -> [LamBinding] -> [Constructor] -> (Maybe ()) -> Call
CheckRecDef :: Range -> Name -> [LamBinding] -> [Constructor] -> (Maybe ()) -> Call
CheckConstructor :: QName -> Telescope -> Sort -> Constructor -> (Maybe ()) -> Call
CheckFunDef :: Range -> Name -> [Clause] -> (Maybe ()) -> Call
CheckPragma :: Range -> Pragma -> (Maybe ()) -> Call
CheckPrimitive :: Range -> Name -> Expr -> (Maybe ()) -> Call
CheckIsEmpty :: Type -> (Maybe ()) -> Call
CheckWithFunctionType :: Expr -> (Maybe ()) -> Call
CheckSectionApplication :: Range -> ModuleName -> ModuleApplication -> (Maybe ()) -> Call
ScopeCheckExpr :: Expr -> (Maybe Expr) -> Call
ScopeCheckDeclaration :: NiceDeclaration -> (Maybe [Declaration]) -> Call
ScopeCheckLHS :: Name -> Pattern -> (Maybe LHS) -> Call
TermFunDef :: Range -> Name -> [Clause] -> (Maybe a) -> Call

-- | used by <tt>setCurrentRange</tt> actually, <tt>a</tt> is
--   Agda.Termination.TermCheck.CallGraph but I was to lazy to import the
--   stuff here --Andreas,2007-5-29
SetRange :: Range -> (Maybe a) -> Call
data BuiltinDescriptor
BuiltinData :: (TCM Type) -> [String] -> BuiltinDescriptor
BuiltinDataCons :: (TCM Type) -> BuiltinDescriptor
BuiltinPrim :: String -> (Term -> TCM ()) -> BuiltinDescriptor
BuiltinPostulate :: (TCM Type) -> BuiltinDescriptor
BuiltinUnknown :: (Maybe (TCM Type)) -> (Term -> 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
data TCEnv
TCEnv :: Context -> LetBindings -> ModuleName -> [(ModuleName, Nat)] -> [TopLevelModuleName] -> Maybe MutualId -> Bool -> [ProblemId] -> AbstractMode -> Bool -> Relevance -> Bool -> Bool -> Bool -> Range -> Maybe (Closure Call) -> TCEnv
envContext :: TCEnv -> Context
envLetBindings :: TCEnv -> LetBindings
envCurrentModule :: TCEnv -> ModuleName

-- | 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 currently in the process of solving active constraints?
envSolvingConstraints :: 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 at the top level when checking a declaration? In this case, we
--   will freeze metas afterwards.
envTopLevel :: TCEnv -> Bool

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

-- | should we try to recover interaction points when reifying? disabled
--   when generating types for with functions
envReifyInteractionPoints :: TCEnv -> Bool

-- | it's safe to eta contract implicit lambdas as long as we're not going
--   to reify and retypecheck (like when doing with abstraction)
envEtaContractImplicit :: TCEnv -> Bool
envRange :: TCEnv -> Range

-- | what we're doing at the moment
envCall :: TCEnv -> Maybe (Closure Call)
initEnv :: TCEnv
type Context = [ContextEntry]
data ContextEntry
Ctx :: CtxId -> Arg (Name, Type) -> ContextEntry
ctxId :: ContextEntry -> CtxId
ctxEntry :: ContextEntry -> Arg (Name, Type)
newtype CtxId
CtxId :: Nat -> CtxId
type LetBindings = Map Name (Open (Term, Arg 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
data Occ
OccCon :: QName -> QName -> OccPos -> Occ
occDatatype :: Occ -> QName
occConstructor :: Occ -> QName
occPosition :: Occ -> OccPos
OccClause :: QName -> Int -> OccPos -> Occ
occFunction :: Occ -> QName
occClause :: Occ -> Int
occPosition :: Occ -> OccPos
data OccPos
NonPositively :: OccPos
ArgumentTo :: Nat -> QName -> OccPos

-- | Information about a call.
data CallInfo
CallInfo :: Range -> String -> CallInfo

-- | Range of the head identifier.
callInfoRange :: CallInfo -> Range

-- | Formatted representation of the call.
--   
--   (<a>Doc</a> would perhaps be better here, but <a>Doc</a> doesn't come
--   with an <a>Ord</a> instance.)
callInfoCall :: CallInfo -> String

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

-- | Indices.
IndexVariablesNotDistinct :: [Arg Term] -> TypeError

-- | Index (a variable), parameters.
IndexFreeInParameter :: Nat -> [Arg Term] -> TypeError

-- | constructor, type
DoesNotConstructAnElementOf :: QName -> Term -> 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 :: Type -> 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

-- | Expected a relevant function and found an irrelevant lambda.
WrongIrrelevanceInLambda :: Type -> TypeError

-- | The term does not correspond to an inductive data type.
NotInductive :: Term -> TypeError
UninstantiatedDotPattern :: Expr -> TypeError
IlltypedPattern :: Pattern -> Type -> TypeError
TooManyArgumentsInLHS :: Nat -> Type -> TypeError
WrongNumberOfConstructorArguments :: QName -> Nat -> Nat -> TypeError
ShouldBeEmpty :: Type -> [Pattern] -> 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
NotAProperTerm :: TypeError
SplitOnIrrelevant :: Pattern -> (Arg Type) -> TypeError
DefinitionIsIrrelevant :: QName -> TypeError
VariableIsIrrelevant :: Name -> TypeError
UnequalLevel :: Comparison -> Term -> Term -> TypeError
UnequalTerms :: Comparison -> Term -> Term -> Type -> TypeError
UnequalTypes :: Comparison -> Type -> Type -> TypeError
UnequalTelescopes :: Comparison -> Telescope -> Telescope -> TypeError

-- | The two function types have different relevance.
UnequalRelevance :: Type -> Type -> TypeError

-- | The two function types have different hiding.
UnequalHiding :: Type -> Type -> TypeError
UnequalSorts :: Sort -> Sort -> 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
BuiltinMustBeConstructor :: String -> Expr -> TypeError
NoSuchBuiltinName :: String -> TypeError
DuplicateBuiltinBinding :: String -> Term -> Term -> TypeError
NoBindingForBuiltin :: String -> TypeError
NoSuchPrimitiveFunction :: String -> TypeError
ShadowedModule :: [ModuleName] -> TypeError
BuiltinInParameterisedModule :: String -> TypeError
NoRHSRequiresAbsurdPattern :: [NamedArg Pattern] -> TypeError
AbsurdPatternRequiresNoRHS :: [NamedArg Pattern] -> TypeError
TooFewFields :: QName -> [Name] -> TypeError
TooManyFields :: QName -> [Name] -> TypeError
DuplicateFields :: [Name] -> TypeError
DuplicateConstructors :: [Name] -> TypeError
UnexpectedWithPatterns :: [Pattern] -> TypeError
WithClausePatternMismatch :: Pattern -> Pattern -> TypeError
FieldOutsideRecord :: TypeError
ModuleArityMismatch :: ModuleName -> Telescope -> [NamedArg Expr] -> TypeError
IncompletePatternMatching :: Term -> Args -> TypeError
CoverageFailure :: QName -> [[Arg Pattern]] -> TypeError
UnreachableClauses :: QName -> [[Arg Pattern]] -> TypeError
CoverageCantSplitOn :: QName -> Telescope -> Args -> Args -> TypeError
CoverageCantSplitIrrelevantType :: Type -> TypeError
CoverageCantSplitType :: Type -> TypeError
NotStrictlyPositive :: QName -> [Occ] -> TypeError
LocalVsImportedModuleClash :: ModuleName -> TypeError
UnsolvedMetas :: [Range] -> TypeError
UnsolvedConstraints :: Constraints -> TypeError
CyclicModuleDependency :: [TopLevelModuleName] -> TypeError
FileNotFound :: TopLevelModuleName -> [AbsolutePath] -> TypeError
OverlappingProjects :: AbsolutePath -> TopLevelModuleName -> TopLevelModuleName -> TypeError
AmbiguousTopLevelModuleName :: TopLevelModuleName -> [AbsolutePath] -> 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
NothingAppliedToHiddenArg :: Expr -> TypeError
NothingAppliedToInstanceArg :: Expr -> TypeError
NoParseForApplication :: [Expr] -> TypeError
AmbiguousParseForApplication :: [Expr] -> [Expr] -> TypeError
NoParseForLHS :: Pattern -> TypeError
AmbiguousParseForLHS :: Pattern -> [Pattern] -> TypeError
IFSNoCandidateInScope :: Type -> TypeError
SafeFlagPostulate :: Name -> TypeError
SafeFlagPragma :: [String] -> TypeError
SafeFlagPrimTrustMe :: TypeError

-- | Type-checking errors.
data TCErr'
TypeError :: TCState -> (Closure TypeError) -> TCErr'
Exception :: Range -> String -> TCErr'
IOException :: Range -> IOException -> TCErr'

-- | for pattern violations
PatternErr :: TCState -> TCErr'

-- | Type-checking errors, potentially paired with relevant syntax
--   highlighting information.
data TCErr
TCErr :: Maybe (HighlightingInfo, ModuleToSource) -> TCErr' -> TCErr

-- | The <a>ModuleToSource</a> can be used to map the module names in the
--   <a>HighlightingInfo</a> to file names.
errHighlighting :: TCErr -> Maybe (HighlightingInfo, ModuleToSource)
errError :: TCErr -> TCErr'
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

-- | Preserve the state of the failing computation.
catchError_ :: TCM a -> (TCErr -> TCM a) -> TCM a
mapTCMT :: (forall a. m a -> n a) -> TCMT m a -> TCMT n a
pureTCM :: MonadIO m => (TCState -> TCEnv -> a) -> TCMT m a
patternViolation :: TCM a
internalError :: MonadTCM tcm => String -> tcm a
typeError :: MonadTCM tcm => TypeError -> tcm a

-- | Running the type checking monad
runTCM :: TCMT IO a -> IO (Either TCErr a)
runTCM' :: MonadIO m => TCMT m a -> m a

-- | Base name for extended lambda patterns
extendlambdaname :: [Char]
instance Typeable ProblemId
instance Typeable Comparison
instance Typeable2 Judgement
instance Typeable Section
instance Typeable DisplayTerm
instance Typeable DisplayForm
instance Typeable HaskellRepresentation
instance Typeable Polarity
instance Typeable Constraint
instance Typeable CompiledRepresentation
instance Typeable Occurrence
instance Typeable Fields
instance Typeable2 Reduced
instance Typeable Delayed
instance Typeable TermHead
instance Typeable FunctionInverse
instance Typeable Defn
instance Typeable MutualId
instance Typeable1 Builtin
instance Typeable CtxId
instance Typeable ContextEntry
instance Typeable1 Open
instance Typeable Definition
instance Typeable Signature
instance Typeable Interface
instance Typeable AbstractMode
instance Typeable TCEnv
instance Typeable Call
instance Typeable ProblemConstraint
instance Typeable1 Closure
instance Typeable Listener
instance Typeable CallInfo
instance Typeable TerminationError
instance Typeable TypeError
instance Typeable PrimFun
instance Typeable MetaVariable
instance Typeable MetaInstantiation
instance Typeable TCErr'
instance Typeable TCErr
instance Data ProblemId
instance Eq ProblemId
instance Ord ProblemId
instance Enum ProblemId
instance Real ProblemId
instance Integral ProblemId
instance Num ProblemId
instance Eq Comparison
instance Show Comparison
instance (Data t, Data a) => Data (Judgement t a)
instance Functor (Judgement t)
instance Foldable (Judgement t)
instance Traversable (Judgement t)
instance Eq Frozen
instance Show Frozen
instance Eq MetaPriority
instance Ord MetaPriority
instance Show MetaPriority
instance Eq InteractionId
instance Ord InteractionId
instance Num InteractionId
instance Integral InteractionId
instance Real InteractionId
instance Enum InteractionId
instance Data Section
instance Show Section
instance Data DisplayTerm
instance Show DisplayTerm
instance Data DisplayForm
instance Show DisplayForm
instance Data HaskellRepresentation
instance Show HaskellRepresentation
instance Data Polarity
instance Show Polarity
instance Eq Polarity
instance Show Constraint
instance Data CompiledRepresentation
instance Show CompiledRepresentation
instance Data Occurrence
instance Show Occurrence
instance Eq Occurrence
instance Ord Occurrence
instance Data Fields
instance Functor (Reduced no)
instance Functor MaybeReduced
instance Data Delayed
instance Show Delayed
instance Eq Delayed
instance Data TermHead
instance Eq TermHead
instance Ord TermHead
instance Show TermHead
instance Data FunctionInverse
instance Show FunctionInverse
instance Data Defn
instance Show Defn
instance Data MutualId
instance Eq MutualId
instance Ord MutualId
instance Show MutualId
instance Num MutualId
instance Data pf => Data (Builtin pf)
instance Show pf => Show (Builtin pf)
instance Functor Builtin
instance Foldable Builtin
instance Traversable Builtin
instance Data CtxId
instance Eq CtxId
instance Ord CtxId
instance Show CtxId
instance Enum CtxId
instance Real CtxId
instance Integral CtxId
instance Num CtxId
instance Data ContextEntry
instance Data a => Data (Open a)
instance Show a => Show (Open a)
instance Functor Open
instance Data Definition
instance Show Definition
instance Data Signature
instance Show Signature
instance Data Interface
instance Show Interface
instance Show FreshThings
instance Data AbstractMode
instance Data TCEnv
instance Show ProblemConstraint
instance Data a => Data (Closure a)
instance Show OccPos
instance Show Occ
instance Eq CallInfo
instance Ord CallInfo
instance Show CallInfo
instance Show TerminationError
instance Show TypeError
instance MonadIO m => MonadIO (TCMT m)
instance MonadIO m => Applicative (TCMT m)
instance MonadIO m => Functor (TCMT m)
instance MonadIO m => Monad (TCMT m)
instance MonadTrans TCMT
instance (Error err, MonadTCM tcm) => MonadTCM (ErrorT err tcm)
instance MonadIO m => MonadTCM (TCMT m)
instance MonadError TCErr (TCMT IO)
instance MonadIO m => MonadState TCState (TCMT m)
instance MonadIO m => MonadReader TCEnv (TCMT m)
instance Exception TCErr
instance HasRange TCErr
instance HasRange TCErr'
instance Show TCErr'
instance Show TCErr
instance Error TCErr
instance Error TypeError
instance HasRange Call
instance Data Call
instance Show InteractionId
instance SetRange MetaVariable
instance HasRange MetaVariable
instance Show MetaInstantiation
instance Ord Listener
instance Eq Listener
instance (Show t, Show a) => Show (Judgement t a)
instance HasRange a => HasRange (Closure a)
instance Show a => Show (Closure a)
instance HasFresh i FreshThings => HasFresh i TCState
instance HasFresh ProblemId FreshThings
instance Show ProblemId
instance HasFresh Integer FreshThings
instance HasFresh CtxId FreshThings
instance HasFresh NameId FreshThings
instance HasFresh InteractionId FreshThings
instance HasFresh MutualId FreshThings
instance HasFresh MetaId FreshThings

module Agda.TypeChecking.Substitute

-- | Apply something to a bunch of arguments. Preserves blocking tags
--   (application can never resolve blocking).
class Apply t
apply :: Apply t => t -> Args -> t

-- | The type must contain the right number of pis without have to perform
--   any reduction.
piApply :: Type -> Args -> Type

-- | <tt>(abstract args v) args --&gt; v[args]</tt>.
class Abstract t
abstract :: Abstract t => Telescope -> t -> t
telVars :: Functor f => Tele (f a) -> [f Pattern]
abstractArgs :: Abstract a => Args -> a -> a

-- | Substitutions.
type Substitution = [Term]

-- | Substitute a term for the nth free variable.
class Subst t
substs :: Subst t => Substitution -> t -> t
substUnder :: Subst t => Nat -> Term -> t -> t
idSub :: Telescope -> Substitution
subst :: Subst t => Term -> t -> t

-- | Add <tt>k</tt> to index of each open variable in <tt>x</tt>.
class Raise t
raiseFrom :: Raise t => Nat -> Nat -> t -> t
renameFrom :: Raise t => Nat -> (Nat -> Nat) -> t -> t
raise :: Raise t => Nat -> t -> t
rename :: Raise t => (Nat -> Nat) -> t -> t
data TelV a
TelV :: (Tele (Arg a)) -> a -> TelV a
type TelView = TelV Type
telFromList :: [Arg (String, Type)] -> Telescope
telToList :: Telescope -> [Arg (String, Type)]
telView' :: Type -> TelView
telePi :: Telescope -> Type -> Type

-- | Everything will be a pi.
telePi_ :: Telescope -> Type -> Type
teleLam :: Telescope -> Term -> Term

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

-- | Instantiate an abstraction
absApp :: Subst t => Abs t -> Term -> t
absBody :: Raise t => Abs t -> t
mkAbs :: (Raise a, Free a) => String -> a -> Abs a
reAbs :: (Raise a, Free a) => Abs a -> Abs a
sLub :: Sort -> Sort -> Sort
lvlView :: Term -> Level
levelMax :: [PlusLevel] -> Level
sortTm :: Sort -> Term
levelSort :: Level -> Sort
levelTm :: Level -> Term
unLevelAtom :: LevelAtom -> Term
instance Typeable1 TelV
instance Eq Constraint
instance Ord Elim
instance Eq Elim
instance Ord LevelAtom
instance Eq PlusLevel
instance Ord Level
instance Eq Level
instance Ord Term
instance Ord Type
instance Eq Type
instance Ord Sort
instance Eq Sort
instance (Raise a, Ord a) => Ord (Tele a)
instance (Raise a, Eq a) => Eq (Tele a)
instance Data a => Data (TelV a)
instance Show a => Show (TelV a)
instance (Eq a, Raise a) => Eq (TelV a)
instance (Ord a, Raise a) => Ord (TelV a)
instance Functor TelV
instance (Raise a, Ord a) => Ord (Abs a)
instance (Raise a, Eq a) => Eq (Abs a)
instance Eq Term
instance Eq LevelAtom
instance Ord PlusLevel
instance (Raise a, Raise b) => Raise (a, b)
instance Raise v => Raise (Map k v)
instance Raise t => Raise (Maybe t)
instance Raise t => Raise [t]
instance Raise t => Raise (Blocked t)
instance Raise t => Raise (Arg t)
instance Raise t => Raise (Abs t)
instance Raise DisplayTerm
instance Raise DisplayForm
instance Raise a => Raise (Tele a)
instance Raise Pattern
instance Raise ClauseBody
instance Raise Elim
instance Raise Constraint
instance Raise LevelAtom
instance Raise PlusLevel
instance Raise Level
instance Raise Sort
instance Raise Type
instance Raise Term
instance Raise ()
instance Subst ClauseBody
instance (Subst a, Subst b) => Subst (a, b)
instance Subst a => Subst [a]
instance Subst a => Subst (Maybe a)
instance Subst a => Subst (Arg a)
instance Subst a => Subst (Abs a)
instance Subst a => Subst (Tele a)
instance Subst DisplayTerm
instance Subst t => Subst (Blocked t)
instance Subst Pattern
instance Subst LevelAtom
instance Subst PlusLevel
instance Subst Level
instance Subst Sort
instance Subst Type
instance Subst Term
instance Abstract v => Abstract (Map k v)
instance Abstract t => Abstract (Maybe t)
instance Abstract t => Abstract [t]
instance Abstract ClauseBody
instance Abstract FunctionInverse
instance Abstract a => Abstract (Case a)
instance Abstract CompiledClauses
instance Abstract Clause
instance Abstract PrimFun
instance Abstract Defn
instance Abstract Definition
instance Abstract Telescope
instance Abstract Sort
instance Abstract Type
instance Abstract Term
instance Abstract Permutation
instance Apply Permutation
instance (Apply a, Apply b, Apply c) => Apply (a, b, c)
instance (Apply a, Apply b) => Apply (a, b)
instance Apply v => Apply (Map k v)
instance Apply t => Apply (Maybe t)
instance Apply t => Apply (Blocked t)
instance Apply t => Apply [t]
instance Apply DisplayTerm
instance Apply ClauseBody
instance Apply FunctionInverse
instance Apply a => Apply (Case a)
instance Apply CompiledClauses
instance Apply Clause
instance Apply PrimFun
instance Apply Defn
instance Apply Definition
instance Subst a => Apply (Tele a)
instance Apply Sort
instance Apply Type
instance Apply Term


-- | Functions for abstracting terms over other terms.
module Agda.TypeChecking.Abstract
piAbstractTerm :: Term -> Type -> Type -> Type
class AbstractTerm a
abstractTerm :: AbstractTerm a => Term -> a -> a
instance (AbstractTerm a, AbstractTerm b) => AbstractTerm (a, b)
instance (Raise a, AbstractTerm a) => AbstractTerm (Abs a)
instance AbstractTerm a => AbstractTerm (Maybe a)
instance AbstractTerm a => AbstractTerm [a]
instance AbstractTerm a => AbstractTerm (Arg a)
instance AbstractTerm LevelAtom
instance AbstractTerm PlusLevel
instance AbstractTerm Level
instance AbstractTerm Sort
instance AbstractTerm Type
instance AbstractTerm Term

module Agda.TypeChecking.Rules.LHS.Problem
type Substitution = [Maybe Term]
type FlexibleVars = [Nat]
data Problem' p
Problem :: [NamedArg Pattern] -> p -> Telescope -> Problem' p
problemInPat :: Problem' p -> [NamedArg Pattern]
problemOutPat :: Problem' p -> p
problemTel :: Problem' p -> Telescope
data Focus
Focus :: QName -> [NamedArg Pattern] -> Range -> OneHolePatterns -> Int -> QName -> [Arg Term] -> [Arg Term] -> Type -> Focus
focusCon :: Focus -> QName
focusConArgs :: Focus -> [NamedArg Pattern]
focusRange :: Focus -> Range
focusOutPat :: Focus -> OneHolePatterns

-- | index of focused variable in the out patterns
focusHoleIx :: Focus -> Int
focusDatatype :: Focus -> QName
focusParams :: Focus -> [Arg Term]
focusIndices :: Focus -> [Arg Term]
focusType :: Focus -> Type
LitFocus :: Literal -> OneHolePatterns -> Int -> Type -> Focus
data SplitProblem

-- | the [Name]s give the as-bindings for the focus
Split :: ProblemPart -> [Name] -> (Arg Focus) -> (Abs ProblemPart) -> SplitProblem
data SplitError
NothingToSplit :: SplitError
SplitPanic :: String -> SplitError
type ProblemPart = Problem' ()

-- | The permutation should permute <tt>allHoles</tt> of the patterns to
--   correspond to the abstract patterns in the problem.
type Problem = Problem' (Permutation, [Arg Pattern])
instance Monoid p => Monoid (Problem' p)
instance Error SplitError
instance Raise (Problem' p)

module Agda.TypeChecking.Monad.Builtin
getBuiltinThing :: String -> TCM (Maybe (Builtin PrimFun))
setBuiltinThings :: BuiltinThings PrimFun -> TCM ()
bindBuiltinName :: String -> Term -> TCM ()
bindPrimitive :: String -> PrimFun -> TCM ()
getBuiltin :: String -> TCM Term
getBuiltin' :: String -> TCM (Maybe Term)
getPrimitive :: String -> TCM PrimFun
primInteger :: TCM Term
primAgdaRecordDef :: TCM Term
primAgdaDataDef :: TCM Term
primAgdaFunDef :: TCM Term
primAgdaDefinitionDataConstructor :: TCM Term
primAgdaDefinitionPrimitive :: TCM Term
primAgdaDefinitionPostulate :: TCM Term
primAgdaDefinitionRecordDef :: TCM Term
primAgdaDefinitionDataDef :: TCM Term
primAgdaDefinitionFunDef :: TCM Term
primAgdaDefinition :: TCM Term
primAgdaSortUnsupported :: TCM Term
primAgdaSortLit :: TCM Term
primAgdaSortSet :: TCM Term
primAgdaSort :: TCM Term
primIrrelevant :: TCM Term
primRelevant :: TCM Term
primRelvance :: TCM Term
primVisible :: TCM Term
primInstance :: TCM Term
primHidden :: TCM Term
primHiding :: TCM Term
primAgdaTypeEl :: TCM Term
primAgdaType :: TCM Term
primAgdaTermUnsupported :: TCM Term
primAgdaTermSort :: TCM Term
primAgdaTermPi :: TCM Term
primAgdaTermCon :: TCM Term
primAgdaTermDef :: TCM Term
primAgdaTermLam :: TCM Term
primAgdaTermVar :: TCM Term
primAgdaTerm :: TCM Term
primArgArg :: TCM Term
primArg :: TCM Term
primQName :: TCM Term
primLevelMax :: TCM Term
primLevelSuc :: TCM Term
primLevelZero :: TCM Term
primLevel :: TCM Term
primRefl :: TCM Term
primEquality :: TCM Term
primFlat :: TCM Term
primSharp :: TCM Term
primInf :: TCM Term
primSizeInf :: TCM Term
primSizeSuc :: TCM Term
primSize :: TCM Term
primNatLess :: TCM Term
primNatEquality :: TCM Term
primNatModSucAux :: TCM Term
primNatDivSucAux :: TCM Term
primNatTimes :: TCM Term
primNatMinus :: TCM Term
primNatPlus :: TCM Term
primZero :: TCM Term
primSuc :: TCM Term
primNat :: TCM Term
primIO :: TCM Term
primCons :: TCM Term
primNil :: TCM Term
primList :: TCM Term
primFalse :: TCM Term
primTrue :: TCM Term
primBool :: TCM Term
primString :: TCM Term
primChar :: TCM Term
primFloat :: TCM Term
builtinNat :: [Char]
builtinSuc :: [Char]
builtinZero :: [Char]
builtinNatPlus :: [Char]
builtinNatMinus :: [Char]
builtinNatTimes :: [Char]
builtinNatDivSucAux :: [Char]
builtinNatModSucAux :: [Char]
builtinNatEquals :: [Char]
builtinNatLess :: [Char]
builtinInteger :: [Char]
builtinFloat :: [Char]
builtinChar :: [Char]
builtinString :: [Char]
builtinBool :: [Char]
builtinTrue :: [Char]
builtinFalse :: [Char]
builtinList :: [Char]
builtinNil :: [Char]
builtinCons :: [Char]
builtinIO :: [Char]
builtinSize :: [Char]
builtinSizeSuc :: [Char]
builtinSizeInf :: [Char]
builtinInf :: [Char]
builtinSharp :: [Char]
builtinFlat :: [Char]
builtinEquality :: [Char]
builtinRefl :: [Char]
builtinLevelMax :: [Char]
builtinLevel :: [Char]
builtinLevelZero :: [Char]
builtinLevelSuc :: [Char]
builtinQName :: [Char]
builtinAgdaSort :: [Char]
builtinAgdaSortSet :: [Char]
builtinAgdaSortLit :: [Char]
builtinAgdaSortUnsupported :: [Char]
builtinAgdaType :: [Char]
builtinAgdaTypeEl :: [Char]
builtinHiding :: [Char]
builtinHidden :: [Char]
builtinInstance :: [Char]
builtinVisible :: [Char]
builtinRelevance :: [Char]
builtinRelevant :: [Char]
builtinIrrelevant :: [Char]
builtinArg :: [Char]
builtinArgArg :: [Char]
builtinAgdaTerm :: [Char]
builtinAgdaTermVar :: [Char]
builtinAgdaTermLam :: [Char]
builtinAgdaTermDef :: [Char]
builtinAgdaTermCon :: [Char]
builtinAgdaTermPi :: [Char]
builtinAgdaTermSort :: [Char]
builtinAgdaTermUnsupported :: [Char]
builtinAgdaFunDef :: [Char]
builtinAgdaDataDef :: [Char]
builtinAgdaRecordDef :: [Char]
builtinAgdaDefinitionFunDef :: [Char]
builtinAgdaDefinitionDataDef :: [Char]
builtinAgdaDefinitionRecordDef :: [Char]
builtinAgdaDefinitionDataConstructor :: [Char]
builtinAgdaDefinitionPostulate :: [Char]
builtinAgdaDefinitionPrimitive :: [Char]
builtinAgdaDefinition :: [Char]

module Agda.TypeChecking.Monad.State

-- | Resets the non-persistent part of the type checking state.
resetState :: TCM ()

-- | Resets all of the type checking state.
resetAllState :: TCM ()

-- | Set the current scope.
setScope :: ScopeInfo -> TCM ()

-- | Get the current scope.
getScope :: TCM ScopeInfo

-- | Sets stExtLambdaTele .
setExtLambdaTele :: Map QName (Int, Int) -> TCM ()

-- | Get stExtLambdaTele.
getExtLambdaTele :: TCM (Map QName (Int, Int))
addExtLambdaTele :: QName -> (Int, Int) -> 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

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


-- | 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
runAbsToCon :: AbsToCon a -> TCM a
data RangeAndPragma
RangeAndPragma :: Range -> Pragma -> RangeAndPragma
abstractToConcreteCtx :: ToConcrete a c => Precedence -> a -> TCM c
withScope :: ScopeInfo -> AbsToCon a -> AbsToCon a
makeEnv :: ScopeInfo -> Env
abstractToConcrete :: ToConcrete a c => Env -> a -> c

-- | We make the translation monadic for modularity purposes.
type AbsToCon = Reader Env
data DontTouchMe a
data Env
noTakenNames :: AbsToCon a -> AbsToCon a
instance ToConcrete Pattern Pattern
instance ToConcrete LHS LHS
instance ToConcrete RangeAndPragma Pragma
instance ToConcrete Declaration [Declaration]
instance ToConcrete ModuleApplication ModuleApplication
instance ToConcrete Clause [Declaration]
instance ToConcrete (Constr Constructor) Declaration
instance ToConcrete (Maybe QName) (Maybe Name)
instance ToConcrete RHS (RHS, [Expr], [Expr], [Declaration])
instance ToConcrete AsWhereDecls WhereClause
instance ToConcrete LetBinding [Declaration]
instance ToConcrete TypedBinding TypedBinding
instance ToConcrete TypedBindings TypedBindings
instance ToConcrete LamBinding LamBinding
instance ToConcrete Expr Expr
instance ToConcrete ModuleName QName
instance ToConcrete QName QName
instance ToConcrete Name Name
instance ToConcrete (DontTouchMe a) a
instance ToConcrete a c => ToConcrete (Named name a) (Named name c)
instance ToConcrete a c => ToConcrete (Arg a) (Arg c)
instance (ToConcrete a1 c1, ToConcrete a2 c2, ToConcrete a3 c3) => ToConcrete (a1, a2, a3) (c1, c2, c3)
instance (ToConcrete a1 c1, ToConcrete a2 c2) => ToConcrete (a1, a2) (c1, c2)
instance ToConcrete a c => ToConcrete [a] [c]

module Agda.TypeChecking.Monad.Statistics
tick :: String -> TCM ()
tickN :: String -> Integer -> TCM ()
tickMax :: String -> Integer -> TCM ()
getStatistics :: TCM Statistics

module Agda.TypeChecking.Monad.Trace
interestingCall :: Closure Call -> Bool

-- | Record a function call in the trace.
traceCall :: MonadTCM tcm => (Maybe r -> Call) -> tcm a -> tcm a
traceCall_ :: MonadTCM tcm => (Maybe () -> Call) -> tcm r -> tcm r
traceCallCPS :: MonadTCM tcm => (Maybe r -> Call) -> (r -> tcm a) -> ((r -> tcm a) -> tcm b) -> tcm b
traceCallCPS_ :: MonadTCM tcm => (Maybe () -> Call) -> tcm a -> (tcm a -> tcm b) -> tcm b
getCurrentRange :: TCM Range
setCurrentRange :: Range -> TCM a -> TCM a

module Agda.TypeChecking.LevelConstraints
simplifyLevelConstraint :: Integer -> Constraint -> Constraints -> Constraint
instance Show Leq
instance Eq Leq


-- | 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).
--   Also, it does not require the silly Error instance for the err type.
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 (Error err, MonadTCM tcm) => MonadTCM (ExceptionT err tcm)
instance (Error err, MonadIO m) => MonadIO (ExceptionT err m)
instance (Error err, MonadError err' m) => MonadError err' (ExceptionT err m)
instance (Error err, MonadReader r m) => MonadReader r (ExceptionT err m)
instance (Error err, MonadState s m) => MonadState s (ExceptionT err m)
instance (Error err, Applicative m, Monad m) => Applicative (ExceptionT err m)
instance Functor f => Functor (ExceptionT err f)
instance MonadTrans (ExceptionT err)
instance (Monad m, MonadException err m, Monoid w) => MonadException err (WriterT w m)
instance (Monad m, MonadException err m) => MonadException err (ReaderT r m)
instance (Monad m, Error err) => MonadException err (ExceptionT err m)
instance (Monad m, Error err) => Monad (ExceptionT err m)

module Agda.TypeChecking.Monad.Env

-- | Get the name of the current module, if any.
currentModule :: TCM ModuleName

-- | Set the name of the current module.
withCurrentModule :: ModuleName -> TCM a -> TCM a

-- | Get the number of variables bound by anonymous modules.
getAnonymousVariables :: ModuleName -> TCM 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 environmnet
getEnv :: TCM TCEnv

-- | Leave the top level to type check local things.
leaveTopLevel :: TCM a -> TCM a
onTopLevel :: TCM Bool

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

-- | Extract the value from an open term. Must be done in an extension of
--   the context in which the term was created.
getOpen :: Raise a => Open a -> TCM a
tryOpen :: Raise a => Open a -> TCM (Maybe a)

module Agda.TypeChecking.Monad.Context

-- | Modify the <a>ctxEntry</a> field of a <a>ContextEntry</a>.
modifyContextEntry :: (Arg (Name, Type) -> Arg (Name, Type)) -> ContextEntry -> ContextEntry

-- | Modify all <a>ContextEntry</a>s.
modifyContextEntries :: (Arg (Name, Type) -> Arg (Name, Type)) -> Context -> Context

-- | Modify a <a>Context</a> in a computation.
modifyContext :: MonadTCM tcm => (Context -> Context) -> tcm a -> tcm a
mkContextEntry :: MonadTCM tcm => Arg (Name, Type) -> tcm ContextEntry

-- | <tt>addCtx x arg cont</tt> add a variable to the context.
--   
--   Chooses an unused <a>Name</a>.
addCtx :: MonadTCM tcm => Name -> Arg Type -> tcm a -> tcm a

-- | N-ary variant of <tt>addCtx</tt>.
addContext :: MonadTCM tcm => [Arg (Name, Type)] -> tcm a -> tcm a

-- | Turns the string into a name and adds it to the context.
addCtxString :: MonadTCM tcm => String -> Arg Type -> tcm a -> tcm a

-- | Change the context
inContext :: MonadTCM tcm => [Arg (Name, Type)] -> tcm a -> tcm a

-- | Go under an abstraction.
underAbstraction :: (Raise a, MonadTCM tcm) => Arg Type -> Abs a -> (a -> tcm b) -> tcm b

-- | Go under an abstract without worrying about the type to add to the
--   context.
underAbstraction_ :: (Raise a, MonadTCM tcm) => Abs a -> (a -> tcm b) -> tcm b

-- | Add a telescope to the context.
addCtxTel :: MonadTCM tcm => Telescope -> tcm a -> tcm a

-- | Get the current context.
getContext :: MonadTCM tcm => tcm [Arg (Name, Type)]

-- | Generate [Var n - 1, .., Var 0] for all declarations in the context.
getContextArgs :: MonadTCM tcm => tcm Args
getContextTerms :: MonadTCM tcm => tcm [Term]

-- | Get the current context as a <a>Telescope</a> with the specified
--   <a>Hiding</a>.
getContextTelescope :: MonadTCM tcm => tcm Telescope

-- | add a bunch of variables with the same type to the context
addCtxs :: MonadTCM tcm => [Name] -> Arg Type -> tcm a -> tcm a

-- | Check if we are in a compatible context, i.e. an extension of the
--   given context.
getContextId :: MonadTCM tcm => tcm [CtxId]

-- | Add a let bound variable
addLetBinding :: MonadTCM tcm => Relevance -> Name -> Term -> Type -> tcm a -> tcm a

-- | get type of bound variable (i.e. deBruijn index)
typeOfBV' :: MonadTCM tcm => Nat -> tcm (Arg Type)
typeOfBV :: MonadTCM tcm => Nat -> tcm Type
nameOfBV :: MonadTCM tcm => Nat -> tcm Name

-- | TODO: move(?)
(!!!) :: (Eq a, Num a, Show a, MonadTCM m) => [b] -> a -> m b

-- | 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 :: MonadTCM tcm => Name -> tcm (Term, Arg Type)
escapeContext :: MonadTCM tcm => Int -> tcm a -> tcm a

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, ClockTime))
storeDecodedModule :: Interface -> ClockTime -> 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.Monad.Mutual
noMutualBlock :: TCM a -> TCM a
inMutualBlock :: TCM a -> TCM a

-- | Set the mutual block for a definition
setMutualBlock :: MutualId -> QName -> TCM ()

-- | Get all mutual blocks
getMutualBlocks :: TCM [Set QName]

-- | Get the current mutual block.
currentMutualBlock :: TCM MutualId
lookupMutualBlock :: MutualId -> TCM (Set QName)
findMutualBlock :: QName -> TCM (Set QName)


-- | 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.
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 -> TCM ()

-- | Computes the module name of the top-level module in the given file.
moduleName' :: AbsolutePath -> TCM 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

-- | 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>.
sourceToModule :: TCM SourceToModule
tests :: IO Bool

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
--   (and were previously <tt><a>Right</a> something</tt>), then the state
--   is reset (completely) .
--   
--   An empty list of relative include directories (<tt><a>Left</a>
--   []</tt>) is interpreted as <tt>[<a>.</a>]</tt>.
setCommandLineOptions :: CommandLineOptions -> TCM ()

-- | Returns the pragma options which are currently in effect.
pragmaOptions :: TCM PragmaOptions

-- | Returns the command line options which are currently in effect.
commandLineOptions :: TCM CommandLineOptions
setOptionsFromPragma :: OptionsPragma -> TCM ()

-- | Disable display forms.
enableDisplayForms :: TCM a -> TCM a

-- | Disable display forms.
disableDisplayForms :: TCM a -> TCM a

-- | Check if display forms are enabled.
displayFormsEnabled :: TCM Bool

-- | Don't eta contract implicit
dontEtaContractImplicit :: TCM a -> TCM a

-- | Do eta contract implicit
doEtaContractImplicit :: MonadTCM tcm => tcm a -> tcm a
shouldEtaContractImplicit :: TCM Bool

-- | Don't reify interaction points
dontReifyInteractionPoints :: TCM a -> TCM a
shouldReifyInteractionPoints :: TCM Bool

-- | Gets the include directories.
--   
--   Precondition: <a>optIncludeDirs</a> must be <tt><a>Right</a>
--   something</tt>.
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

-- | Makes the given directories absolute and stores them as include
--   directories.
--   
--   If the include directories change (and they were previously
--   <tt><a>Right</a> something</tt>), then the state is reset (completely,
--   except for the include directories).
--   
--   An empty list is interpreted as <tt>[<a>.</a>]</tt>.
setIncludeDirs :: [FilePath] -> RelativeTo -> TCM ()
setInputFile :: FilePath -> TCM ()

-- | Should only be run if <a>hasInputFile</a>.
getInputFile :: TCM AbsolutePath
hasInputFile :: TCM Bool
proofIrrelevance :: TCM Bool
hasUniversePolymorphism :: TCM Bool
showImplicitArguments :: TCM Bool
setShowImplicitArguments :: Bool -> TCM a -> TCM a
ignoreInterfaces :: TCM Bool
positivityCheckEnabled :: TCM Bool
typeInType :: TCM Bool
getVerbosity :: TCM (Trie String Int)
type VerboseKey = String
hasVerbosity :: VerboseKey -> Int -> TCM Bool

-- | Precondition: The level must be non-negative.
verboseS :: VerboseKey -> Int -> TCM () -> TCM ()
reportS :: VerboseKey -> Int -> String -> TCM ()
reportSLn :: VerboseKey -> Int -> String -> TCM ()
reportSDoc :: VerboseKey -> Int -> TCM Doc -> TCM ()
verboseBracket :: VerboseKey -> Int -> String -> TCM a -> TCM a


-- | 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
notInScope :: QName -> ScopeM a
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
createModule :: ModuleName -> ScopeM ()

-- | Apply a function to the scope info.
modifyScopeInfo :: (ScopeInfo -> ScopeInfo) -> 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 ()

-- | Apply a function to the current scope.
modifyCurrentScope :: (Scope -> Scope) -> ScopeM ()

-- | Apply a monadic function to the top scope.
modifyNamedScopeM :: ModuleName -> (Scope -> ScopeM Scope) -> ScopeM ()
modifyCurrentScopeM :: (Scope -> ScopeM Scope) -> ScopeM ()

-- | 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
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.
freshAbstractName :: Fixity' -> Name -> ScopeM Name

-- | <pre>
--   freshAbstractName_ = freshAbstractName defaultFixity
--   </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
ConstructorName :: [AbstractName] -> ResolvedName
UnknownName :: ResolvedName

-- | Look up the abstract name referred to by a given concrete name.
resolveName :: QName -> ScopeM ResolvedName

-- | Look up a module in the scope.
resolveModule :: QName -> ScopeM AbstractModule

-- | Get the fixity of a name. The name is assumed to be in scope.
getFixity :: QName -> ScopeM Fixity'

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

-- | 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 Ren a = Map a a
type Out = (Ren ModuleName, Ren QName)
type WSM = StateT Out ScopeM

-- | Create a new scope with the given name from an old scope. Renames
--   public names in the old scope to match the new name and returns the
--   renamings.
copyScope :: ModuleName -> Scope -> ScopeM (Scope, (Ren ModuleName, Ren QName))

-- | Apply an importdirective and check that all the names mentioned
--   actually exist.
applyImportDirectiveM :: QName -> ImportDirective -> Scope -> ScopeM Scope

-- | Open a module.
openModule_ :: QName -> ImportDirective -> ScopeM ()
instance Show ResolvedName


-- | 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</tt>.
--   
--   It also contains the function that puts parenthesis back given the
--   precedence of the context.
module Agda.Syntax.Concrete.Operators
parseApplication :: [Expr] -> ScopeM Expr

-- | Parses a left-hand side, and makes sure that it defined the expected
--   name. TODO: check the arities of constructors. There is a possible
--   ambiguity with postfix constructors: Assume _ * is a constructor. Then
--   'true *' can be parsed as either the intended _* applied to true, or
--   as true applied to a variable *. If we check arities this problem
--   won't appear.
parseLHS :: Maybe Name -> Pattern -> ScopeM Pattern
paren :: Monad m => (Name -> m Fixity) -> Expr -> m (Precedence -> Expr)
mparen :: Bool -> Expr -> Expr
instance Eq NotationStyle
instance IsExpr Pattern
instance IsExpr Expr

module Agda.TypeChecking.Monad.SizedTypes

-- | Check if a type is the <a>primSize</a> type. The argument should be
--   <tt>reduce</tt>d.
isSizeType :: Type -> TCM Bool
isSizeNameTest :: TCM (QName -> Bool)
isSizeTypeTest :: TCM (Type -> Bool)
sizeType :: TCM Type
sizeSuc :: TCM (Maybe QName)

-- | A useful view on sizes.
data SizeView
SizeInf :: SizeView
SizeSuc :: Term -> SizeView
OtherSize :: Term -> SizeView

-- | Compute the size view of a term. The argument should be
--   <tt>reduce</tt>d. Precondition: sized types are enabled.
sizeView :: Term -> TCM SizeView

-- | Turn a size view into a term.
unSizeView :: SizeView -> TCM Term


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

-- | SemiRing type class. Additive monoid with multiplication operation.
--   Inherit addition and zero from Monoid.
class (Eq a, Monoid a) => SemiRing a
multiply :: SemiRing a => a -> a -> a

-- | Semirings.
data Semiring a
Semiring :: (a -> a -> a) -> (a -> a -> a) -> a -> Semiring a

-- | Addition.
add :: Semiring a -> a -> a -> a

-- | Multiplication.
mul :: Semiring a -> a -> a -> a

-- | Zero. The one is never used in matrix multiplication , one :: a -- ^
--   One.
zero :: Semiring a -> a

-- | Semiring invariant.
semiringInvariant :: (Arbitrary a, Eq a, Show a) => Semiring a -> a -> a -> a -> Bool
integerSemiring :: Semiring Integer

-- | The standard semiring on <a>Bool</a>s.
boolSemiring :: Semiring Bool
tests :: IO Bool
instance SemiRing Integer
instance Monoid Integer
instance HasZero Integer


-- | Sparse matrices.
--   
--   We assume the matrices to be very sparse, so we just implement them as
--   sorted association lists.
module Agda.Termination.SparseMatrix

-- | Type of matrices, parameterised on the type of values.
data Matrix i b
matrixInvariant :: (Num i, Ix i) => Matrix i b -> Bool

-- | Size of a matrix.
data Size i
Size :: i -> i -> Size i
rows :: Size i -> i
cols :: Size i -> i
sizeInvariant :: (Ord i, Num i) => Size i -> Bool

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

-- | No nonpositive indices are allowed.
mIxInvariant :: (Ord i, Num i) => MIx i -> Bool

-- | <tt><a>fromLists</a> sz rs</tt> constructs a matrix from a list of
--   lists of values (a list of rows).
--   
--   Precondition: <tt><a>length</a> rs <a>==</a> <a>rows</a> sz
--   <a>&amp;&amp;</a> <a>all</a> ((<a>==</a> <a>cols</a> sz) .
--   <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 (index, value)-pairs.
fromIndexList :: (Ord i, HasZero b) => Size i -> [(MIx i, b)] -> Matrix i b

-- | Converts a matrix to a list of row lists.
toLists :: (Show i, Ord i, Integral i, Enum i, HasZero b) => Matrix i b -> [[b]]

-- | Generates a matrix of the given size.
matrix :: (Arbitrary i, Integral i, Arbitrary b, HasZero b) => Size i -> Gen (Matrix i b)

-- | Generates a matrix of the given size, using the given generator to
--   generate the rows.
matrixUsingRowGen :: (Arbitrary i, Integral i, Arbitrary b, HasZero b) => Size i -> (i -> Gen [b]) -> Gen (Matrix i b)
size :: Matrix i b -> Size i

-- | <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>.
isSingleton :: (Num i, Ix i) => Matrix i b -> Maybe b

-- | <tt><a>add</a> (+) m1 m2</tt> adds <tt>m1</tt> and <tt>m2</tt>. Uses
--   <tt>(+)</tt> to add values.
--   
--   Precondition: <tt><a>size</a> m1 == <a>size</a> m2</tt>.
add :: Ord i => (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.
--   
--   Precondition: <tt><a>size</a> m1 == <a>size</a> m2</tt>.
intersectWith :: Ord i => (a -> a -> a) -> Matrix i a -> Matrix i a -> Matrix i a

-- | <tt><a>mul</a> semiring m1 m2</tt> multiplies <tt>m1</tt> and
--   <tt>m2</tt>. Uses the operations of the semiring <tt>semiring</tt> to
--   perform the multiplication.
--   
--   Precondition: <tt><a>cols</a> (<a>size</a> m1) == rows (<a>size</a>
--   m2)</tt>.
mul :: (Enum i, Num i, Ix i, Eq a) => Semiring a -> Matrix i a -> Matrix i a -> Matrix i a
transpose :: Ord i => Matrix i b -> Matrix i b

-- | <tt><a>diagonal</a> m</tt> extracts the diagonal of <tt>m</tt>.
--   
--   Precondition: <tt><a>square</a> m</tt>.
diagonal :: (Show i, Enum i, Num i, Ix i, HasZero b) => Matrix i b -> Array i b

-- | <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
tests :: IO Bool
instance Eq i => Eq (Size i)
instance Ord i => Ord (Size i)
instance Show i => Show (Size i)
instance Eq i => Eq (MIx i)
instance Show i => Show (MIx i)
instance Ix i => Ix (MIx i)
instance Ord i => Ord (MIx i)
instance (Eq i, Eq b) => Eq (Matrix i b)
instance (Ord i, Ord b) => Ord (Matrix i b)
instance (Show i, Ord i, Integral i, Enum i, CoArbitrary b, HasZero b) => CoArbitrary (Matrix i b)
instance (Arbitrary i, Num i, Integral i, Arbitrary b, HasZero b) => Arbitrary (Matrix i b)
instance (Show i, Integral i, HasZero b, Pretty b) => Pretty (Matrix i b)
instance (Ord i, Integral i, Enum i, Show i, Show b, HasZero b) => Show (Matrix i b)
instance CoArbitrary i => CoArbitrary (MIx i)
instance (Arbitrary i, Integral i) => Arbitrary (MIx i)
instance CoArbitrary i => CoArbitrary (Size i)
instance (Arbitrary i, Integral i) => Arbitrary (Size i)


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

-- | 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 <a>Call</a> for more information.
--   
--   TODO: document orders which are call-matrices themselves.
data Order
Mat :: (Matrix Integer 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 :: Int => Int -> Order

-- | Multiplication of <a>Order</a>s. (Corresponds to sequential
--   composition.)
(.*.) :: ?cutoff :: Int => Order -> Order -> Order

-- | The supremum of a (possibly empty) list of <a>Order</a>s.
supremum :: ?cutoff :: Int => [Order] -> Order

-- | <tt>(<a>Order</a>, <a>max</a>, <a>.*.</a>)</tt> forms a semiring, with
--   <a>Unknown</a> as zero and <tt>Le</tt> as one.
--   
--   The infimum of a (non empty) list of <a>Order</a>s.
infimum :: ?cutoff :: Int => [Order] -> Order
decreasing :: Order -> Bool

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

-- | Call matrix indices.
type Index = Integer

-- | Call matrices. Note the call matrix invariant
--   (<a>callMatrixInvariant</a>).
newtype CallMatrix
CallMatrix :: Matrix Index Order -> CallMatrix
mat :: CallMatrix -> Matrix Index Order

-- | <a>Call</a> combination.
--   
--   Precondition: see <a>&lt;*&gt;</a>; furthermore the <a>source</a> of
--   the first argument should be equal to the <a>target</a> of the second
--   one.
(>*<) :: ?cutoff :: Int => Call -> Call -> Call

-- | In a call matrix at most one element per row may be different from
--   <a>Unknown</a>.
callMatrixInvariant :: CallMatrix -> Bool

-- | This datatype encodes information about a single recursive function
--   application. The columns of the call matrix stand for <a>source</a>
--   function arguments (patterns); the first argument has index 0, the
--   second 1, and so on. The rows of the matrix stand for <a>target</a>
--   function arguments. Element <tt>(i, j)</tt> in the matrix should be
--   computed as follows:
--   
--   <ul>
--   <li><tt>Lt</tt> (less than) if the <tt>j</tt>-th argument to the
--   <a>target</a> function is structurally strictly smaller than the
--   <tt>i</tt>-th pattern.</li>
--   <li><tt>Le</tt> (less than or equal) if the <tt>j</tt>-th argument to
--   the <a>target</a> function is structurally smaller than the
--   <tt>i</tt>-th pattern.</li>
--   <li><a>Unknown</a> otherwise.</li>
--   </ul>
--   
--   The structural ordering used is defined in the paper referred to
--   above.
data Call
Call :: Index -> Index -> CallMatrix -> Call

-- | The function making the call.
source :: Call -> Index

-- | The function being called.
target :: Call -> Index

-- | The call matrix describing the call.
cm :: Call -> CallMatrix

-- | <a>Call</a> invariant.
callInvariant :: Call -> Bool

-- | 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.
data CallGraph meta

-- | <a>CallGraph</a> invariant.
callGraphInvariant :: CallGraph meta -> Bool

-- | Converts a list of calls with associated meta information to a call
--   graph.
fromList :: Monoid meta => [(Call, meta)] -> CallGraph meta

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

-- | Creates an empty call graph.
empty :: CallGraph meta

-- | Takes the union of two call graphs.
union :: Monoid meta => CallGraph meta -> CallGraph meta -> CallGraph meta

-- | Inserts a call into a call graph.
insert :: Monoid meta => Call -> meta -> CallGraph meta -> CallGraph meta

-- | <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 :: Int => Monoid meta => CallGraph meta -> CallGraph meta

-- | Displays the recursion behaviour corresponding to a call graph.
prettyBehaviour :: Show meta => CallGraph meta -> Doc
tests :: IO Bool
instance Eq Order
instance Ord Order
instance Eq CallMatrix
instance Ord CallMatrix
instance Show CallMatrix
instance Eq Call
instance Ord Call
instance Show Call
instance Eq meta => Eq (CallGraph meta)
instance Show meta => Show (CallGraph meta)
instance Show meta => Pretty (CallGraph meta)
instance CoArbitrary Call
instance Arbitrary Call
instance CoArbitrary CallMatrix
instance Arbitrary CallMatrix
instance CoArbitrary Order
instance Arbitrary Order
instance Pretty Order
instance HasZero Order
instance Show Order


-- | Naive implementation of simple matrix library.
module Agda.Termination.Matrix

-- | Type of matrices, parameterised on the type of values.
data Matrix i b
matrixInvariant :: (Num i, Ix i) => Matrix i b -> Bool

-- | Size of a matrix.
data Size i
Size :: i -> i -> Size i
rows :: Size i -> i
cols :: Size i -> i
sizeInvariant :: (Ord i, Num i) => Size i -> Bool

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

-- | No nonpositive indices are allowed.
mIxInvariant :: (Ord i, Num i) => MIx i -> Bool

-- | <tt><a>fromLists</a> sz rs</tt> constructs a matrix from a list of
--   lists of values (a list of rows).
--   
--   Precondition: <tt><a>length</a> rs <a>==</a> <a>rows</a> sz
--   <a>&amp;&amp;</a> <a>all</a> ((<a>==</a> <a>cols</a> sz) .
--   <a>length</a>) rs</tt>.
fromLists :: (Num i, Ix i) => Size i -> [[b]] -> Matrix i b

-- | Constructs a matrix from a list of (index, value)-pairs.
fromIndexList :: (Num i, Ix i) => Size i -> [(MIx i, b)] -> Matrix i b

-- | Converts a matrix to a list of row lists.
toLists :: (Ix i, Num i, Enum i) => Matrix i b -> [[b]]
zipWith :: (a -> b -> c) -> Matrix Integer a -> Matrix Integer b -> Matrix Integer c

-- | Generates a matrix of the given size.
matrix :: (Arbitrary i, Integral i, Ix i, Arbitrary b) => Size i -> Gen (Matrix i b)

-- | Generates a matrix of the given size, using the given generator to
--   generate the rows.
matrixUsingRowGen :: (Arbitrary i, Integral i, Ix i, Arbitrary b) => Size i -> (i -> Gen [b]) -> Gen (Matrix i b)

-- | The size of a matrix.
size :: Ix i => Matrix i b -> Size i

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

-- | <tt><a>add</a> (+) m1 m2</tt> adds <tt>m1</tt> and <tt>m2</tt>. Uses
--   <tt>(+)</tt> to add values.
--   
--   Precondition: <tt><a>size</a> m1 == <a>size</a> m2</tt>.
add :: (Ix i, Num i) => (a -> b -> c) -> Matrix i a -> Matrix i b -> Matrix i c

-- | <tt><a>mul</a> m1 m2</tt> multiplies <tt>m1</tt> and <tt>m2</tt>. Uses
--   the operations of the semiring to perform the multiplication.
--   
--   Precondition: <tt><a>cols</a> (<a>size</a> m1) == rows (<a>size</a>
--   m2)</tt>.
mul :: (Enum i, Num i, Ix i) => Semiring a -> Matrix i a -> Matrix i a -> Matrix i a

-- | <tt><a>diagonal</a> m</tt> extracts the diagonal of <tt>m</tt>.
--   
--   Precondition: <tt><a>square</a> m</tt>.
diagonal :: (Enum i, Num i, Ix i) => Matrix i b -> Array i b

-- | <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 :: (Ix i, Integral i) => 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 :: (Ix i, Num i, Enum i) => b -> Matrix i b -> Matrix i b
tests :: IO Bool
instance Eq i => Eq (Size i)
instance Show i => Show (Size i)
instance Eq i => Eq (MIx i)
instance Show i => Show (MIx i)
instance Ix i => Ix (MIx i)
instance Ord i => Ord (MIx i)
instance (Eq b, Ix i) => Eq (Matrix i b)
instance (Ord b, Ix i) => Ord (Matrix i b)
instance (Ix i, Num i, Enum i, CoArbitrary b) => CoArbitrary (Matrix i b)
instance (Arbitrary i, Num i, Integral i, Ix i, Arbitrary b) => Arbitrary (Matrix i b)
instance (Ix i, Num i, Enum i, Show i, Show b) => Show (Matrix i b)
instance CoArbitrary i => CoArbitrary (MIx i)
instance (Arbitrary i, Integral i) => Arbitrary (MIx i)
instance CoArbitrary i => CoArbitrary (Size i)
instance (Arbitrary i, Integral i) => Arbitrary (Size i)


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

-- | Returns <a>True</a> iff the argument is <tt><a>Left</a> x</tt> for
--   some <tt>x</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>.
isRight :: Either a b -> Bool

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


-- | Lexicographic order search, more or less as defined in "A Predicative
--   Analysis of Structural Recursion" by Andreas Abel and Thorsten
--   Altenkirch.
module Agda.Termination.Lexicographic

-- | A lexicographic ordering for the recursion behaviour of a given
--   function is a permutation of the argument indices which can be used to
--   show that the function terminates. See the paper referred to above for
--   more details.
type LexOrder arg = [arg]

-- | A recursion behaviour expresses how a certain function calls itself
--   (transitively). For every argument position there is a value
--   (<a>Column</a>) describing how the function calls itself for that
--   particular argument. See also <a>recBehaviourInvariant</a>.
data RecBehaviour arg call
RB :: Map arg (Column call) -> Set call -> Size Integer -> RecBehaviour arg call
columns :: RecBehaviour arg call -> Map arg (Column call)

-- | The indices to the columns.
calls :: RecBehaviour arg call -> Set call
size :: RecBehaviour arg call -> Size Integer

-- | A column expresses how the size of a certain argument changes in the
--   various recursive calls a function makes to itself (transitively).
type Column call = Map call Order

-- | <a>RecBehaviour</a> invariant: the size must match the real size of
--   the recursion behaviour, and all columns must have the same indices.
recBehaviourInvariant :: Eq call => RecBehaviour arg call -> Bool

-- | Constructs a recursion behaviour from a list of matrix diagonals
--   ("rows"). Note that the <tt>call</tt> indices do not need to be
--   distinct, since they are paired up with unique <a>Integer</a>s.
--   
--   Precondition: all arrays should have the same bounds.
fromDiagonals :: (Ord call, Ix arg) => [(call, Array arg Order)] -> RecBehaviour arg (Integer, call)

-- | Tries to compute a lexicographic ordering for the given recursion
--   behaviour. This algorithm should be complete.
--   
--   If no lexicographic ordering can be found, then two sets are returned:
--   
--   <ul>
--   <li>A set of argument positions which are not properly decreasing,
--   and</li>
--   <li>the calls where these problems show up.</li>
--   </ul>
lexOrder :: (Ord arg, Ord call) => RecBehaviour arg call -> Either (Set arg, Set call) (LexOrder arg)
tests :: IO Bool
instance (Show arg, Show call) => Show (RecBehaviour arg call)
instance (CoArbitrary call, CoArbitrary arg) => CoArbitrary (RecBehaviour call arg)
instance (Arbitrary call, Arbitrary arg, Ord arg, Ord call) => Arbitrary (RecBehaviour call arg)


-- | 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
--   <a>lexOrder</a> 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 :: (Ord meta, Monoid meta, ?cutoff :: Int) => CallGraph meta -> Either meta ()
tests :: IO Bool

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)]
warshallG :: (SemiRing edge, Ord node) => AdjList node edge -> AdjList node edge
data Weight
Finite :: Int -> Weight
Infinite :: Weight
inc :: Weight -> Int -> Weight
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
type Scope = RigidId -> Bool
infinite :: Rigid -> Bool
isBelow :: Rigid -> Weight -> Rigid -> Bool
data Constraint
NewFlex :: FlexId -> Scope -> Constraint
Arc :: Node -> Int -> Node -> Constraint
type Constraints = [Constraint]
emptyConstraints :: [a]
data Graph
Graph :: Map FlexId Scope -> Map Node NodeId -> Map NodeId Node -> NodeId -> (NodeId -> NodeId -> Weight) -> Graph
flexScope :: Graph -> Map FlexId Scope
nodeMap :: Graph -> Map Node NodeId
intMap :: Graph -> Map NodeId Node
nextNode :: Graph -> NodeId
graph :: Graph -> NodeId -> NodeId -> Weight
initGraph :: Graph
type GM = State Graph
addFlex :: FlexId -> Scope -> GM ()
addNode :: Node -> GM Int
addEdge :: Node -> Int -> Node -> GM ()
addConstraint :: Constraint -> GM ()
buildGraph :: Constraints -> Graph
mkMatrix :: Int -> (Int -> Int -> Weight) -> Matrix Weight
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
type Solution = Map Int SizeExpr
emptySolution :: Map k a
extendSolution :: Ord k => Map k a -> k -> a -> Map k a
data SizeExpr
SizeVar :: RigidId -> Int -> SizeExpr
SizeConst :: Weight -> SizeExpr
sizeRigid :: Rigid -> Int -> SizeExpr
solve :: Constraints -> Maybe Solution
genGraph :: Ord node => Float -> Gen edge -> [node] -> Gen (AdjList node edge)
newtype Distance
Dist :: Nat -> Distance
genGraph_ :: Nat -> Gen (AdjList Nat Distance)
lookupEdge :: Ord n => n -> n -> AdjList n e -> Maybe e
edges :: Ord n => AdjList n e -> [(n, n, e)]

-- | Check that no edges get longer when completing a graph.
prop_smaller :: Nat -> Property
newEdge :: Ord k => k -> t -> t1 -> Map k [(t, t1)] -> Map k [(t, t1)]
genPath :: Nat -> Nat -> Nat -> AdjList Nat Distance -> Gen (AdjList Nat Distance)

-- | Check that all transitive edges are added.
prop_path :: Nat -> Property
mapNodes :: (Ord node, Ord node') => (node -> node') -> AdjList node edge -> AdjList node' edge

-- | Check that no edges are added between components.
prop_disjoint :: Nat -> Property
prop_stable :: Nat -> Property
tests :: IO Bool
instance Eq Weight
instance Eq Rigid
instance Ord Rigid
instance Show Rigid
instance Eq Node
instance Ord Node
instance Eq Distance
instance Ord Distance
instance Num Distance
instance Integral Distance
instance Show Distance
instance Enum Distance
instance Real Distance
instance SemiRing Distance
instance Show SizeExpr
instance (Show a, Show b, Show c) => Show (LegendMatrix a b c)
instance Show Constraint
instance Show Node
instance SemiRing Weight
instance Ord Weight
instance Show Weight

module Agda.TypeChecking.Test.Generators
data TermConfiguration
TermConf :: [QName] -> [QName] -> [Nat] -> UseLiterals -> Frequencies -> Maybe Int -> Bool -> TermConfiguration
tcDefinedNames :: TermConfiguration -> [QName]
tcConstructorNames :: TermConfiguration -> [QName]
tcFreeVariables :: TermConfiguration -> [Nat]
tcLiterals :: TermConfiguration -> UseLiterals
tcFrequencies :: TermConfiguration -> Frequencies

-- | Maximum size of the generated element. When <tt>Nothing</tt> this
--   value is initialized from the <a>size</a> parameter.
tcFixSize :: TermConfiguration -> Maybe Int

-- | When this is true no lambdas, literals, or constructors are generated
tcIsType :: TermConfiguration -> Bool
data Frequencies
Freqs :: HiddenFreqs -> NameFreqs -> SortFreqs -> TermFreqs -> Frequencies
hiddenFreqs :: Frequencies -> HiddenFreqs
nameFreqs :: Frequencies -> NameFreqs
sortFreqs :: Frequencies -> SortFreqs
termFreqs :: Frequencies -> TermFreqs
data TermFreqs
TermFreqs :: Int -> Int -> Int -> Int -> Int -> Int -> TermFreqs
nameFreq :: TermFreqs -> Int
litFreq :: TermFreqs -> Int
sortFreq :: TermFreqs -> Int
lamFreq :: TermFreqs -> Int
piFreq :: TermFreqs -> Int
funFreq :: TermFreqs -> Int
data NameFreqs
NameFreqs :: Int -> Int -> Int -> NameFreqs
varFreq :: NameFreqs -> Int
defFreq :: NameFreqs -> Int
conFreq :: NameFreqs -> Int
data HiddenFreqs
HiddenFreqs :: Int -> Int -> HiddenFreqs
hiddenFreq :: HiddenFreqs -> Int
notHiddenFreq :: HiddenFreqs -> Int
data SortFreqs
SortFreqs :: [Int] -> Int -> SortFreqs
setFreqs :: SortFreqs -> [Int]
propFreq :: SortFreqs -> Int
defaultFrequencies :: Frequencies
noProp :: TermConfiguration -> TermConfiguration
data UseLiterals
UseLit :: Bool -> Bool -> Bool -> Bool -> UseLiterals
useLitInt :: UseLiterals -> Bool
useLitFloat :: UseLiterals -> Bool
useLitString :: UseLiterals -> Bool
useLitChar :: UseLiterals -> Bool
noLiterals :: UseLiterals
fixSizeConf :: Int -> TermConfiguration -> TermConfiguration
resizeConf :: (Int -> Int) -> TermConfiguration -> TermConfiguration
decrConf :: TermConfiguration -> TermConfiguration
divConf :: TermConfiguration -> Int -> TermConfiguration
isTypeConf :: TermConfiguration -> TermConfiguration
isntTypeConf :: TermConfiguration -> TermConfiguration
extendConf :: TermConfiguration -> TermConfiguration
extendWithTelConf :: Telescope -> TermConfiguration -> TermConfiguration
makeConfiguration :: [String] -> [String] -> [Nat] -> TermConfiguration
class GenC a
genC :: GenC a => TermConfiguration -> Gen a
newtype YesType a
YesType :: a -> YesType a
unYesType :: YesType a -> a
newtype NoType a
NoType :: a -> NoType a
unNoType :: NoType a -> a
newtype VarName
VarName :: Nat -> VarName
unVarName :: VarName -> Nat
newtype DefName
DefName :: QName -> DefName
unDefName :: DefName -> QName
newtype ConName
ConName :: QName -> ConName
unConName :: ConName -> QName
newtype SizedList a
SizedList :: [a] -> SizedList a
unSizedList :: SizedList a -> [a]
fixSize :: TermConfiguration -> Gen a -> Gen a
genArgs :: TermConfiguration -> Gen Args

-- | Only generates default configurations. Names and free variables
--   varies.
genConf :: Gen TermConfiguration
class ShrinkC a b | a -> b
shrinkC :: ShrinkC a b => TermConfiguration -> a -> [b]
noShrink :: ShrinkC a b => a -> b
killAbs :: KillVar a => Abs a -> a
class KillVar a
killVar :: KillVar a => Nat -> a -> a
isWellScoped :: Free a => TermConfiguration -> a -> Bool

-- | Check that the generated terms don't have any out of scope variables.
prop_wellScopedVars :: TermConfiguration -> Property
instance Show TermFreqs
instance Show NameFreqs
instance Show HiddenFreqs
instance Show SortFreqs
instance Show Frequencies
instance Show UseLiterals
instance Show TermConfiguration
instance (KillVar a, KillVar b) => KillVar (a, b)
instance KillVar a => KillVar (Maybe a)
instance KillVar a => KillVar [a]
instance KillVar a => KillVar (Abs a)
instance KillVar a => KillVar (Arg a)
instance KillVar Telescope
instance KillVar Type
instance KillVar Term
instance ShrinkC Term Term
instance ShrinkC Type Type
instance ShrinkC Telescope Telescope
instance ShrinkC Sort Sort
instance ShrinkC a b => ShrinkC (Blocked a) (Blocked b)
instance ShrinkC a b => ShrinkC (Arg a) (Arg b)
instance ShrinkC a b => ShrinkC (Abs a) (Abs b)
instance ShrinkC Hiding Hiding
instance ShrinkC Char Char
instance ShrinkC Literal Literal
instance ShrinkC ConName QName
instance ShrinkC DefName QName
instance ShrinkC VarName Nat
instance (ShrinkC a a', ShrinkC b b') => ShrinkC (a, b) (a', b')
instance ShrinkC a b => ShrinkC [a] [b]
instance ShrinkC a b => ShrinkC (NoType a) b
instance ShrinkC a b => ShrinkC (YesType a) b
instance Arbitrary TermConfiguration
instance GenC Term
instance GenC Type
instance GenC Telescope
instance GenC Literal
instance GenC Integer
instance GenC Double
instance GenC Char
instance GenC Sort
instance GenC a => GenC (Abs a)
instance GenC a => GenC (Arg a)
instance GenC Hiding
instance GenC Range
instance (GenC a, GenC b) => GenC (a, b)
instance GenC a => GenC [a]
instance GenC a => GenC (SizedList a)

module Agda.TypeChecking.Monad.Signature
modifySignature :: (Signature -> Signature) -> TCM ()
modifyImportedSignature :: (Signature -> Signature) -> TCM ()
getSignature :: TCM Signature
getImportedSignature :: TCM Signature
setSignature :: Signature -> TCM ()
setImportedSignature :: Signature -> TCM ()
withSignature :: Signature -> TCM a -> TCM a

-- | Add a constant to the signature. Lifts the definition to top level.
addConstant :: QName -> Definition -> TCM ()

-- | Turn a definition into a projection if it looks like a projection.
makeProjection :: QName -> TCM ()
addHaskellCode :: QName -> HaskellType -> HaskellCode -> TCM ()
addHaskellType :: QName -> HaskellType -> TCM ()
addEpicCode :: QName -> EpicCode -> TCM ()
addJSCode :: QName -> String -> TCM ()
markStatic :: QName -> TCM ()
unionSignatures :: [Signature] -> Signature

-- | Add a section to the signature.
addSection :: ModuleName -> Nat -> TCM ()

-- | Lookup a section. If it doesn't exist that just means that the module
--   wasn't parameterised.
lookupSection :: ModuleName -> TCM Telescope
addDisplayForms :: QName -> TCM ()
applySection :: ModuleName -> Telescope -> ModuleName -> Args -> Map QName QName -> Map ModuleName ModuleName -> TCM ()
addDisplayForm :: QName -> DisplayForm -> TCM ()
canonicalName :: QName -> TCM 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

-- | Lookup the definition of a name. The result is a closed thing, all
--   free variables have been abstracted over.
getConstInfo :: MonadTCM tcm => QName -> tcm Definition

-- | Look up the polarity of a definition.
getPolarity :: QName -> TCM [Polarity]
getPolarity' :: Comparison -> QName -> TCM [Polarity]

-- | Set the polarity of a definition.
setPolarity :: QName -> [Polarity] -> TCM ()
getArgOccurrence :: QName -> Nat -> TCM Occurrence
setArgOccurrences :: QName -> [Occurrence] -> TCM ()

-- | Look up the number of free variables of a section. This is equal to
--   the number of parameters if we're currently inside the section and 0
--   otherwise.
getSecFreeVars :: ModuleName -> TCM Nat

-- | Compute the number of free variables of a module. This is the sum of
--   the free variables of its sections.
getModuleFreeVars :: ModuleName -> TCM Nat

-- | Compute the number of free variables of a defined name. This is the
--   sum of the free variables of the sections it's contained in.
getDefFreeVars :: QName -> TCM Nat

-- | Compute the context variables to apply a definition to.
freeVarsToApply :: QName -> TCM Args

-- | Instantiate a closed definition with the correct part of the current
--   context.
instantiateDef :: Definition -> TCM Definition

-- | Give the abstract view of a definition.
makeAbstract :: Definition -> Maybe Definition

-- | Enter abstract mode. Abstract definition in the current module are
--   transparent.
inAbstractMode :: TCM a -> TCM a

-- | Not in abstract mode. All abstract definitions are opaque.
inConcreteMode :: TCM a -> TCM a

-- | Ignore abstract mode. All abstract definitions are transparent.
ignoreAbstractMode :: TCM a -> TCM 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 :: QName -> TCM Bool
treatAbstractly' :: QName -> TCEnv -> Bool

-- | get type of a constant
typeOfConst :: QName -> TCM Type

-- | get relevance of a constant
relOfConst :: QName -> TCM Relevance

-- | The name must be a datatype.
sortOfConst :: QName -> TCM Sort

-- | Is it the name of a record projection?
isProjection :: QName -> TCM (Maybe (QName, Int))

module Agda.TypeChecking.Monad.Closure
enterClosure :: Closure a -> (a -> TCM b) -> TCM 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
isProblemSolved :: ProblemId -> TCM Bool
getConstraintsForProblem :: ProblemId -> TCM Constraints

-- | Get the awake constraints
getAwakeConstraints :: TCM Constraints
wakeConstraints :: (ProblemConstraint -> Bool) -> TCM ()
takeAwakeConstraint :: TCM (Maybe ProblemConstraint)
getAllConstraints :: TCM Constraints
withConstraint :: (Constraint -> TCM a) -> ProblemConstraint -> TCM a
buildProblemConstraint :: ProblemId -> Constraint -> TCM ProblemConstraint
buildConstraint :: Constraint -> TCM ProblemConstraint

-- | Add new a constraint
addConstraint' :: Constraint -> TCM ()

-- | Add already awake constraints
addAwakeConstraints :: Constraints -> TCM ()

-- | Start solving constraints
nowSolvingConstraints :: TCM a -> TCM a
isSolvingConstraints :: TCM Bool

module Agda.TypeChecking.Monad.MetaVars

-- | Get the meta store.
getMetaStore :: TCM MetaStore
modifyMetaStore :: (MetaStore -> MetaStore) -> TCM ()

-- | Lookup a meta variable
lookupMeta :: MetaId -> TCM MetaVariable
updateMetaVar :: MetaId -> (MetaVariable -> MetaVariable) -> TCM ()
getMetaPriority :: MetaId -> TCM MetaPriority
isSortMeta :: MetaId -> TCM Bool
isInstantiatedMeta :: MetaId -> TCM Bool
createMetaInfo :: TCM MetaInfo
updateMetaVarRange :: MetaId -> Range -> TCM ()
addInteractionPoint :: InteractionId -> MetaId -> TCM ()
removeInteractionPoint :: InteractionId -> TCM ()
getInteractionPoints :: TCM [InteractionId]
getInteractionMetas :: TCM [MetaId]

-- | Does the meta variable correspond to an interaction point?
isInteractionMeta :: MetaId -> TCM Bool
lookupInteractionId :: InteractionId -> TCM MetaId
judgementInteractionId :: InteractionId -> TCM (Judgement Type MetaId)

-- | Generate new meta variable.
newMeta :: MetaInfo -> MetaPriority -> Permutation -> Judgement Type 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 Type a -> TCM MetaId
getInteractionRange :: InteractionId -> TCM Range
getMetaRange :: MetaId -> TCM Range
getInteractionScope :: InteractionId -> TCM ScopeInfo
withMetaInfo :: MetaInfo -> TCM a -> TCM a
getInstantiatedMetas :: TCM [MetaId]
getOpenMetas :: TCM [MetaId]

-- | <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 meta variables.
freezeMetas :: TCM ()
unfreezeMetas :: TCM ()
isFrozen :: MetaId -> TCM Bool

module Agda.TypeChecking.Monad.Debug
debug :: MonadIO m => String -> m ()

module Agda.TypeChecking.Monad

module Agda.Syntax.Abstract.Pretty
showA :: (Show c, ToConcrete a c) => a -> TCM String
prettyA :: (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


-- | 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
OldName :: Name -> OldName
newtype TopLevel a
TopLevel :: a -> TopLevel a
data TopLevelInfo
TopLevelInfo :: [Declaration] -> ScopeInfo -> ScopeInfo -> TopLevelInfo
topLevelDecls :: TopLevelInfo -> [Declaration]
outsideScope :: TopLevelInfo -> ScopeInfo
insideScope :: 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 [overlap ok] ToAbstract Pattern (Pattern' Expr)
instance [overlap ok] ToAbstract c a => ToAbstract (Pattern' c) (Pattern' a)
instance [overlap ok] ToAbstract c a => ToAbstract (Named name c) (Named name a)
instance [overlap ok] ToAbstract c a => ToAbstract (Arg c) (Arg a)
instance [overlap ok] ToAbstract LeftHandSide LHS
instance [overlap ok] ToAbstract RHS AbstractRHS
instance [overlap ok] ToAbstract RightHandSide AbstractRHS
instance [overlap ok] ToAbstract AbstractRHS RHS
instance [overlap ok] ToAbstract Clause Clause
instance [overlap ok] ToAbstract Pragma [Pragma]
instance [overlap ok] ToAbstract ConstrDecl Declaration
instance [overlap ok] ToAbstract NiceDeclaration Declaration
instance [overlap ok] ToAbstract LetDef [LetBinding]
instance [overlap ok] ToAbstract LetDefs [LetBinding]
instance [overlap ok] ToAbstract [Declaration] [Declaration]
instance [overlap ok] ToAbstract (TopLevel [Declaration]) TopLevelInfo
instance [overlap ok] ToAbstract TypedBinding TypedBinding
instance [overlap ok] ToAbstract TypedBindings TypedBindings
instance [overlap ok] ToAbstract LamBinding LamBinding
instance [overlap ok] ToAbstract Expr Expr
instance [overlap ok] ToAbstract OldModuleName ModuleName
instance [overlap ok] ToAbstract NewModuleQName ModuleName
instance [overlap ok] ToAbstract NewModuleName ModuleName
instance [overlap ok] ToAbstract OldName QName
instance [overlap ok] ToAbstract PatName APatName
instance [overlap ok] ToAbstract OldQName Expr
instance [overlap ok] ToAbstract (NewName BoundName) Name
instance [overlap ok] ToAbstract (NewName Name) Name
instance [overlap ok] ToAbstract c a => ToAbstract (Maybe c) (Maybe a)
instance [overlap ok] ToAbstract c a => ToAbstract [c] [a]
instance [overlap ok] (ToAbstract c1 a1, ToAbstract c2 a2, ToAbstract c3 a3) => ToAbstract (c1, c2, c3) (a1, a2, a3)
instance [overlap ok] (ToAbstract c1 a1, ToAbstract c2 a2) => ToAbstract (c1, c2) (a1, a2)

module Agda.Interaction.Monad

-- | Interaction monad.
type IM = TCMT (InputT IO)

-- | Line reader. The line reader history is not stored between sessions.
readline :: String -> IM (Maybe String)
runIM :: IM a -> TCM a
instance MonadError TCErr IM

module Agda.Interaction.Highlighting.Dot
data DotState
DotState :: Map ModuleName String -> [String] -> Set (String, String) -> DotState
dsModules :: DotState -> Map ModuleName String
dsNameSupply :: DotState -> [String]
dsConnection :: DotState -> Set (String, String)
initialDotState :: DotState
type DotM = StateT DotState TCM
addModule :: ModuleName -> DotM (String, Bool)
addConnection :: String -> String -> DotM ()
dottify :: Interface -> DotM String
generateDot :: Interface -> TCM ()


-- | 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 :: EmbPrj a => FilePath -> a -> TCM ()

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

-- | 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.
decodeFile :: EmbPrj a => FilePath -> TCM (Maybe a)
class Typeable a => EmbPrj a
instance [incoherent] Eq TypeRep'
instance [incoherent] EmbPrj Tag
instance [incoherent] EmbPrj Forced
instance [incoherent] EmbPrj Relevance
instance [incoherent] EmbPrj InjectiveFun
instance [incoherent] EmbPrj EInterface
instance [incoherent] EmbPrj Interface
instance [incoherent] EmbPrj ScopeInfo
instance [incoherent] EmbPrj Precedence
instance [incoherent] EmbPrj MetaInfo
instance [incoherent] EmbPrj OtherAspect
instance [incoherent] EmbPrj Aspect
instance [incoherent] EmbPrj NameKind
instance [incoherent] EmbPrj a => EmbPrj (Builtin a)
instance [incoherent] EmbPrj Pattern
instance [incoherent] EmbPrj Delayed
instance [incoherent] EmbPrj ClauseBody
instance [incoherent] EmbPrj Clause
instance [incoherent] EmbPrj IsAbstract
instance [incoherent] EmbPrj TermHead
instance [incoherent] EmbPrj FunctionInverse
instance [incoherent] EmbPrj CompiledClauses
instance [incoherent] EmbPrj a => EmbPrj (Case a)
instance [incoherent] EmbPrj Defn
instance [incoherent] EmbPrj CompiledRepresentation
instance [incoherent] EmbPrj Occurrence
instance [incoherent] EmbPrj Polarity
instance [incoherent] EmbPrj MemberId
instance [incoherent] EmbPrj GlobalId
instance [incoherent] EmbPrj LocalId
instance [incoherent] EmbPrj Exp
instance [incoherent] EmbPrj HaskellRepresentation
instance [incoherent] EmbPrj Definition
instance [incoherent] EmbPrj MutualId
instance [incoherent] EmbPrj DisplayTerm
instance [incoherent] EmbPrj CtxId
instance [incoherent] EmbPrj a => EmbPrj (Open a)
instance [incoherent] EmbPrj DisplayForm
instance [incoherent] EmbPrj Literal
instance [incoherent] EmbPrj Sort
instance [incoherent] EmbPrj LevelAtom
instance [incoherent] EmbPrj PlusLevel
instance [incoherent] EmbPrj Level
instance [incoherent] EmbPrj Term
instance [incoherent] EmbPrj a => EmbPrj (Abs a)
instance [incoherent] EmbPrj Type
instance [incoherent] EmbPrj Relevance
instance [incoherent] EmbPrj Hiding
instance [incoherent] EmbPrj Induction
instance [incoherent] EmbPrj a => EmbPrj (Arg a)
instance [incoherent] EmbPrj Permutation
instance [incoherent] EmbPrj Telescope
instance [incoherent] EmbPrj Section
instance [incoherent] EmbPrj Signature
instance [incoherent] EmbPrj NameId
instance [incoherent] EmbPrj Name
instance [incoherent] EmbPrj ModuleName
instance [incoherent] EmbPrj QName
instance [incoherent] EmbPrj GenPart
instance [incoherent] EmbPrj Fixity'
instance [incoherent] EmbPrj Fixity
instance [incoherent] EmbPrj KindOfName
instance [incoherent] EmbPrj AbstractModule
instance [incoherent] EmbPrj AbstractName
instance [incoherent] EmbPrj NameSpace
instance [incoherent] EmbPrj Access
instance [incoherent] EmbPrj NameSpaceId
instance [incoherent] EmbPrj Scope
instance [incoherent] EmbPrj QName
instance [incoherent] EmbPrj NamePart
instance [incoherent] EmbPrj Name
instance [incoherent] EmbPrj Range
instance [incoherent] EmbPrj Range
instance [incoherent] EmbPrj Interval
instance [incoherent] (Ord a, EmbPrj a) => EmbPrj (Set a)
instance [incoherent] (Ord a, EmbPrj a, EmbPrj b) => EmbPrj (Map a b)
instance [incoherent] EmbPrj a => EmbPrj [a]
instance [incoherent] EmbPrj TopLevelModuleName
instance [incoherent] EmbPrj Position
instance [incoherent] EmbPrj AbsolutePath
instance [incoherent] EmbPrj Bool
instance [incoherent] EmbPrj a => EmbPrj (Maybe a)
instance [incoherent] (EmbPrj a, EmbPrj b, EmbPrj c) => EmbPrj (a, b, c)
instance [incoherent] (EmbPrj a, EmbPrj b) => EmbPrj (a, b)
instance [incoherent] EmbPrj ()
instance [incoherent] EmbPrj Double
instance [incoherent] EmbPrj Char
instance [incoherent] EmbPrj Int
instance [incoherent] EmbPrj Int32
instance [incoherent] EmbPrj Integer
instance [incoherent] EmbPrj String
instance [incoherent] Hashable TypeRep'


-- | Compute eta short normal forms.
module Agda.TypeChecking.EtaContract
data BinAppView
App :: Term -> (Arg Term) -> BinAppView
NoApp :: Term -> BinAppView
binAppView :: Term -> BinAppView
etaContract :: TermLike a => a -> TCM a
etaOnce :: Term -> TCM Term


-- | Irrelevant function types.
module Agda.TypeChecking.Irrelevance

-- | data <a>Relevance</a> see <a>Common</a>
--   
--   <tt>unusableRelevance rel == True</tt> iff we cannot use a variable of
--   <tt>rel</tt>.
unusableRelevance :: Relevance -> Bool
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
--   <a>moreRelevant</a> (r <a>composeRelevance</a> y)</tt> iff <tt>(r
--   <a>inverseComposeRelevance</a> x) <a>moreRelevant</a> y</tt> (Galois
--   connection).
inverseComposeRelevance :: Relevance -> Relevance -> Relevance

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

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

-- | Prepare parts of a parameter telescope for abstraction in constructors
--   and projections.
hideAndRelParams :: Arg a -> Arg a

-- | <tt>modifyArgRelevance f arg</tt> applies <tt>f</tt> to the
--   <a>argRelevance</a> component of <tt>arg</tt>.
modifyArgRelevance :: (Relevance -> Relevance) -> Arg a -> Arg a

-- | Used to modify context when going into a <tt>rel</tt> argument.
inverseApplyRelevance :: Relevance -> Arg a -> Arg 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 -> Arg a -> Arg 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

-- | Call me if --experimental-irrelevance is set.
doWorkOnTypes :: 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.Interaction.Highlighting.Vim
on :: (t1 -> t1 -> t) -> (t2 -> t1) -> t2 -> t2 -> t
vimFile :: FilePath -> FilePath
escape :: String -> String
keyword :: String -> [String] -> String
match :: String -> [String] -> String
matches :: [String] -> [String] -> [String] -> [String] -> [String]
toVim :: NamesInScope -> String
generateVimFile :: FilePath -> TCM ()

module Agda.TypeChecking.Reduce
traceFun :: String -> TCM a -> TCM a
traceFun' :: Show a => String -> TCM a -> TCM a

-- | 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 -> TCM t
class Reduce t where reduce t = ignoreBlocking <$> reduceB t reduceB t = notBlocked <$> reduce t
reduce :: Reduce t => t -> TCM t
reduceB :: Reduce t => t -> TCM (Blocked t)

-- | If the first argument is <a>True</a>, then a single delayed clause may
--   be unfolded.
unfoldDefinition :: Bool -> (Term -> TCM (Blocked Term)) -> Term -> QName -> Args -> TCM (Blocked Term)
class Normalise t
normalise :: Normalise t => t -> TCM t
class InstantiateFull t
instantiateFull :: InstantiateFull t => t -> TCM t

-- | <tt>telViewM t</tt> is like <tt>telView' t</tt>, but it reduces
--   <tt>t</tt> to expose function type constructors.
telViewM :: Type -> TCM TelView
instance InstantiateFull a => InstantiateFull (Maybe a)
instance InstantiateFull a => InstantiateFull (Builtin a)
instance InstantiateFull Interface
instance InstantiateFull Clause
instance InstantiateFull CompiledClauses
instance InstantiateFull a => InstantiateFull (Case a)
instance InstantiateFull FunctionInverse
instance InstantiateFull Defn
instance InstantiateFull DisplayTerm
instance InstantiateFull DisplayForm
instance InstantiateFull a => InstantiateFull (Open a)
instance InstantiateFull Definition
instance InstantiateFull Char
instance (Raise a, InstantiateFull a) => InstantiateFull (Tele a)
instance InstantiateFull Section
instance InstantiateFull Signature
instance InstantiateFull Scope
instance InstantiateFull ModuleName
instance (Ord k, InstantiateFull e) => InstantiateFull (Map k e)
instance InstantiateFull Elim
instance InstantiateFull Constraint
instance InstantiateFull ProblemConstraint
instance InstantiateFull a => InstantiateFull (Closure a)
instance (InstantiateFull a, InstantiateFull b, InstantiateFull c) => InstantiateFull (a, b, c)
instance (InstantiateFull a, InstantiateFull b) => InstantiateFull (a, b)
instance InstantiateFull t => InstantiateFull [t]
instance InstantiateFull t => InstantiateFull (Arg t)
instance (Raise t, InstantiateFull t) => InstantiateFull (Abs t)
instance InstantiateFull ClauseBody
instance InstantiateFull Pattern
instance InstantiateFull LevelAtom
instance InstantiateFull PlusLevel
instance InstantiateFull Level
instance InstantiateFull Term
instance InstantiateFull Type
instance InstantiateFull Sort
instance InstantiateFull Name
instance Normalise a => Normalise (Maybe a)
instance (Ord k, Normalise e) => Normalise (Map k e)
instance Normalise DisplayForm
instance Normalise Pattern
instance Normalise Constraint
instance Normalise ProblemConstraint
instance (Raise a, Normalise a) => Normalise (Tele a)
instance Normalise a => Normalise (Closure a)
instance (Normalise a, Normalise b, Normalise c) => Normalise (a, b, c)
instance (Normalise a, Normalise b) => Normalise (a, b)
instance Normalise t => Normalise [t]
instance Normalise t => Normalise (Arg t)
instance (Raise t, Normalise t) => Normalise (Abs t)
instance Normalise ClauseBody
instance Normalise LevelAtom
instance Normalise PlusLevel
instance Normalise Level
instance Normalise Elim
instance Normalise Term
instance Normalise Type
instance Normalise Sort
instance (Ord k, Reduce e) => Reduce (Map k e)
instance Reduce Constraint
instance Reduce Telescope
instance Reduce a => Reduce (Closure a)
instance Reduce Term
instance (Reduce a, Reduce b, Reduce c) => Reduce (a, b, c)
instance (Reduce a, Reduce b) => Reduce (a, b)
instance Reduce t => Reduce (Arg t)
instance Reduce t => Reduce [t]
instance (Raise t, Reduce t) => Reduce (Abs t)
instance Reduce LevelAtom
instance Reduce PlusLevel
instance Reduce Level
instance Reduce Elim
instance Reduce Sort
instance Reduce Type
instance (Ord k, Instantiate e) => Instantiate (Map k e)
instance Instantiate Constraint
instance Instantiate Telescope
instance Instantiate a => Instantiate (Closure a)
instance (Instantiate a, Instantiate b, Instantiate c) => Instantiate (a, b, c)
instance (Instantiate a, Instantiate b) => Instantiate (a, b)
instance Instantiate t => Instantiate [t]
instance Instantiate t => Instantiate (Arg t)
instance Instantiate t => Instantiate (Abs t)
instance Instantiate Elim
instance Instantiate Sort
instance Instantiate Type
instance Instantiate a => Instantiate (Blocked a)
instance Instantiate LevelAtom
instance Instantiate PlusLevel
instance Instantiate Level
instance Instantiate Term

module Agda.TypeChecking.Telescope

-- | The permutation should permute the corresponding telescope.
--   (left-to-right list)
renameP :: Subst t => Permutation -> t -> t

-- | If <tt>permute π : [a]Γ -&gt; [a]Δ</tt>, then <tt>substs (renaming π)
--   : Term Γ -&gt; Term Δ</tt>
renaming :: Permutation -> [Term]

-- | If <tt>permute π : [a]Γ -&gt; [a]Δ</tt>, then <tt>substs (renamingR π)
--   : Term Δ -&gt; Term Γ</tt>
renamingR :: Permutation -> [Term]

-- | Flatten telescope: (Γ : Tel) -&gt; [Type Γ]
flattenTel :: Telescope -> [Arg Type]

-- | Order a flattened telescope in the correct dependeny order: Γ -&gt;
--   Permutation (Γ -&gt; Γ~)
reorderTel :: [Arg Type] -> Maybe Permutation
reorderTel_ :: [Arg Type] -> Permutation

-- | Unflatten: turns a flattened telescope into a proper telescope. Must
--   be properly ordered.
unflattenTel :: [String] -> [Arg Type] -> Telescope

-- | Get the suggested names from a telescope
teleNames :: Telescope -> [String]
teleArgNames :: Telescope -> [Arg String]
teleArgs :: Telescope -> Args

-- | A telescope split in two.
data SplitTel
SplitTel :: Telescope -> Telescope -> Permutation -> SplitTel
firstPart :: SplitTel -> Telescope
secondPart :: SplitTel -> Telescope
splitPerm :: SplitTel -> Permutation

-- | Split a telescope into the part that defines the given variables and
--   the part that doesn't.
splitTelescope :: VarSet -> Telescope -> SplitTel
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 $n &lt; 0$.
telViewUpTo :: Int -> Type -> TCM TelView

-- | A safe variant of piApply.
piApplyM :: Type -> Args -> TCM Type

module Agda.TypeChecking.Tests

-- | <pre>
--   telFromList . telToList == id
--   </pre>
prop_telToListInv :: TermConfiguration -> Property

-- | All elements of <a>flattenTel</a> are well-scoped under the original
--   telescope.
prop_flattenTelScope :: TermConfiguration -> Property

-- | <pre>
--   unflattenTel . flattenTel == id
--   </pre>
prop_flattenTelInv :: TermConfiguration -> Property

-- | <a>reorderTel</a> is stable.
prop_reorderTelStable :: TermConfiguration -> Property

-- | The result of splitting a telescope is well-scoped.
prop_splitTelescopeScope :: TermConfiguration -> Property

-- | The permutation generated when splitting a telescope preserves
--   scoping.
prop_splitTelescopePermScope :: TermConfiguration -> Property
tests :: IO Bool

module Agda.TypeChecking.Eliminators
data ElimView
VarElim :: Nat -> [Elim] -> ElimView
DefElim :: QName -> [Elim] -> ElimView
ConElim :: QName -> [Elim] -> ElimView
MetaElim :: MetaId -> [Elim] -> ElimView
NoElim :: Term -> ElimView
elimView :: Term -> TCM ElimView

-- | Only used when producing error messages.
unElimView :: ElimView -> Term
unElim :: Term -> [Elim] -> Term


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


-- | 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
prNatEquality :: Var
prPred :: Var
prFalse :: Var
prTrue :: Var
prSuc :: 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
head'' :: [t] -> t -> t

-- | 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.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
levelSucFunction :: TCM (Term -> Term)
builtinLevelKit :: TCM (Maybe LevelKit)

-- | Raises an error if no level kit is available.
requireLevels :: TCM LevelKit
reallyUnLevelView :: Level -> TCM Term
maybePrimCon :: TCM Term -> TCM (Maybe QName)
maybePrimDef :: TCM Term -> TCM (Maybe QName)
levelView :: Term -> TCM Level
levelLub :: Level -> Level -> Level

module Agda.TypeChecking.DisplayForm
displayForm :: QName -> Args -> TCM (Maybe DisplayTerm)
matchDisplayForm :: DisplayForm -> Args -> Maybe DisplayTerm
class Match a
match :: Match a => Nat -> a -> a -> Maybe [Term]
instance Match Term
instance Match a => Match (Arg a)
instance Match a => Match [a]

module Agda.TypeChecking.Datatypes

-- | Get the name of the datatype constructed by a given constructor.
--   Precondition: The argument must refer to a constructor
getConstructorData :: QName -> TCM QName

-- | Check if a name refers to a datatype or a record with a named
--   constructor.
isDatatype :: QName -> TCM Bool

-- | Check if a name refers to a datatype or a record.
isDataOrRecordType :: QName -> TCM Bool
data DatatypeInfo
DataInfo :: QName -> Telescope -> Args -> Telescope -> Args -> DatatypeInfo
datatypeName :: DatatypeInfo -> QName
datatypeParTel :: DatatypeInfo -> Telescope
datatypePars :: DatatypeInfo -> Args
datatypeIxTel :: DatatypeInfo -> Telescope
datatypeIxs :: DatatypeInfo -> Args

-- | Get the name and parameters from a type if it's a datatype or record
--   type with a named constructor.
getDatatypeInfo :: Type -> TCM (Maybe DatatypeInfo)


-- | Translating from internal syntax to abstract syntax. Enables nice
--   pretty printing of internal syntax.
--   
--   TODO
--   
--   <ul>
--   <li>numbers on metas - fake dependent functions to independent
--   functions - meta parameters - shadowing</li>
--   </ul>
module Agda.Syntax.Translation.InternalToAbstract
apps :: (Expr, [Arg Expr]) -> TCM Expr
exprInfo :: ExprInfo
reifyApp :: Expr -> [Arg Term] -> TCM Expr
class Reify i a | i -> a
reify :: Reify i a => i -> TCM a
reifyDisplayForm :: QName -> Args -> TCM Expr -> TCM Expr
reifyDisplayFormP :: LHS -> TCM LHS
data NamedClause
NamedClause :: QName -> Clause -> NamedClause
stripImplicits :: [NamedArg Pattern] -> [Pattern] -> TCM ([NamedArg Pattern], [Pattern])

-- | <tt>dotVars ps</tt> gives all the variables inside of dot patterns of
--   <tt>ps</tt> It is only invoked for patternish things. (Ulf O-tone!)
--   Use it for printing l.h.sides: which of the implicit arguments have to
--   be made explicit.
class DotVars a
dotVars :: DotVars a => a -> Set Name
reifyPatterns :: Telescope -> Permutation -> [Arg Pattern] -> TCM [NamedArg Pattern]
instance (Reify t t', Reify a a') => Reify (Judgement t a) (Judgement t' a')
instance (Reify i1 a1, Reify i2 a2) => Reify (i1, i2) (a1, a2)
instance Reify i a => Reify [i] [a]
instance Reify i a => Reify (Arg i) (Arg a)
instance Reify Telescope Telescope
instance (Free i, Reify i a) => Reify (Abs i) (Name, a)
instance Reify Level Expr
instance Reify Sort Expr
instance Reify Type Expr
instance Reify NamedClause Clause
instance DotVars TypedBinding
instance DotVars TypedBindings
instance DotVars RHS
instance DotVars Expr
instance DotVars Pattern
instance DotVars Clause
instance (DotVars a, DotVars b) => DotVars (a, b)
instance DotVars a => DotVars [a]
instance DotVars a => DotVars (Named s a)
instance DotVars a => DotVars (Arg a)
instance Reify ClauseBody RHS
instance Reify Elim Expr
instance Reify Term Expr
instance Reify Literal Expr
instance Reify DisplayTerm Expr
instance Reify MetaId Expr

module Agda.TypeChecking.Pretty
type Doc = Doc
empty :: TCM Doc
comma :: TCM Doc
pretty :: (Monad m, Pretty a) => a -> m Doc
prettyA :: (Pretty c, ToConcrete a c) => a -> TCM Doc
text :: String -> TCM Doc
pwords :: Monad m => String -> [m Doc]
fwords :: Monad m => String -> m Doc
sep :: [TCM Doc] -> TCM Doc
vcat :: [TCM Doc] -> TCM Doc
hsep :: [TCM Doc] -> TCM Doc
fsep :: [TCM Doc] -> TCM Doc
($$) :: TCM Doc -> TCM Doc -> TCM Doc
(<+>) :: TCM Doc -> TCM Doc -> TCM Doc
(<>) :: TCM Doc -> TCM Doc -> TCM Doc
nest :: Functor f => Int -> f Doc -> f Doc
braces :: Functor f => f Doc -> f Doc
dbraces :: Functor f => f Doc -> f Doc
brackets :: Functor f => f Doc -> f Doc
parens :: Functor f => f Doc -> f Doc
prettyList :: [TCM Doc] -> TCMT IO Doc
punctuate :: TCM Doc -> [TCM Doc] -> [TCM Doc]
class PrettyTCM a
prettyTCM :: PrettyTCM a => a -> TCM Doc
newtype PrettyContext
PrettyContext :: Context -> PrettyContext
instance PrettyTCM Context
instance PrettyTCM PrettyContext
instance PrettyTCM Telescope
instance PrettyTCM ModuleName
instance PrettyTCM QName
instance PrettyTCM Name
instance PrettyTCM Literal
instance PrettyTCM Constraint
instance PrettyTCM ProblemConstraint
instance PrettyTCM Comparison
instance PrettyTCM Relevance
instance PrettyTCM Expr
instance PrettyTCM Elim
instance (Reify a e, ToConcrete e c, Pretty c) => PrettyTCM (Arg a)
instance PrettyTCM a => PrettyTCM (Blocked a)
instance PrettyTCM MetaId
instance (PrettyTCM a, PrettyTCM b) => PrettyTCM (Judgement a b)
instance PrettyTCM ClauseBody
instance PrettyTCM Level
instance PrettyTCM NamedClause
instance PrettyTCM DisplayTerm
instance PrettyTCM Sort
instance PrettyTCM Type
instance PrettyTCM Term
instance PrettyTCM a => PrettyTCM [a]
instance PrettyTCM a => PrettyTCM (Closure a)

module Agda.TypeChecking.Errors
prettyError :: TCErr -> TCM String
class PrettyTCM a
prettyTCM :: PrettyTCM a => a -> TCM Doc
tcErrString :: TCErr -> String
instance PrettyTCM Call
instance PrettyTCM TypeError
instance PrettyTCM TCErr


-- | Functions which give precise syntax highlighting info to Emacs.
module Agda.Interaction.Highlighting.Emacs

-- | Shows syntax highlighting information in an Emacsy fashion.
showHighlightingInfo :: Maybe (HighlightingInfo, ModuleToSource) -> String

-- | All the properties.
tests :: IO Bool


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


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


-- | 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 <a>or</a>
(||-) :: Relevance -> Relevance -> Relevance

-- | Relevance <a>and</a>
(&&-) :: Relevance -> Relevance -> Relevance
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 :: (Functor m, 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 :: (Ord k, Eq a) => Map k a -> Map k a -> [(k, (a, a))]


-- | 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
evaluateTerm :: Term -> Compile TCM 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

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)]))
remAbs :: ClauseBody -> Term
isNoBody :: ClauseBody -> Bool
patternToTerm :: Nat -> Pattern -> Term
nrBinds :: Num i => Pattern -> i
substForDot :: [Arg Pattern] -> Substitution
isInjectiveHere :: QName -> Int -> Clause -> Compile TCM InjConstraints
litToCon :: Literal -> TCM Term
litCon :: 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? Precondition: t1 is normalised, t2 is in
--   WHNF When reducing t2, it may become a literal, which makes this not
--   work in some cases...
(<:) :: Term -> Term -> (QName :-> InjectiveFun) -> Compile TCM InjConstraints
data TagEq
Same :: Int -> TagEq
IsTag :: Tag -> TagEq
data Tags
Tags :: Int :-> Set QName -> QName :-> TagEq -> Tags
eqGroups :: Tags -> Int :-> Set QName
constrGroup :: Tags -> 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 => k :-> v -> k -> v
instance Eq TagEq

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]

-- | 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.
getRecordDef :: QName -> TCM Defn

-- | Get the field names of a record.
getRecordFieldNames :: QName -> TCM [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 type of the record constructor.
getRecordConstructorType :: QName -> TCM Type

-- | Returns the given record type's constructor name (with an empty
--   range).
getRecordConstructor :: QName -> TCM QName

-- | Check if a name refers to a record.
isRecord :: QName -> TCM Bool

-- | Check if a name refers to an eta expandable record.
isEtaRecord :: 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.
isRecordConstructor :: QName -> TCM Bool

-- | Check if a constructor name is the internally generated record
--   constructor.
isGeneratedRecordConstructor :: QName -> TCM Bool

-- | Compute the eta expansion of a record. The first argument should be
--   the name of a record type. Given
--   
--   <pre>
--   record R : Set where x : A; y : B; .z : C
--   </pre>
--   
--   and <tt>r : R</tt>, <tt>etaExpand R [] r</tt> is <tt>[R.x r, R.y r,
--   DontCare]</tt>
etaExpandRecord :: QName -> Args -> Term -> TCM (Telescope, Args)

-- | The fields should be eta contracted already.
etaContractRecord :: QName -> QName -> Args -> TCM 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)
isSingletonRecord' :: Bool -> QName -> Args -> TCM (Either MetaId Bool)


-- | 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.
--   
--   If the input clause contains dot patterns inside record patterns, then
--   the translation may yield clauses which are not type-correct. However,
--   we believe that it is safe to use the output as input to
--   <a>compileClauses</a>. Perhaps it would be better to perform record
--   pattern translation on the compiled clauses instead, but the code
--   below has already been implemented and seems to work.
translateRecordPatterns :: Clause -> TCM Clause
instance Functor RecPatM
instance Applicative RecPatM
instance Monad RecPatM
instance MonadIO RecPatM
instance MonadTCM RecPatM
instance MonadReader TCEnv RecPatM
instance MonadState TCState RecPatM
instance Eq Kind

module Agda.TypeChecking.CompiledClause.Compile
compileClauses :: Bool -> [Clause] -> TCM CompiledClauses
type Cl = ([Arg Pattern], ClauseBody)
type Cls = [Cl]
compile :: Cls -> CompiledClauses
nextSplit :: Cls -> Maybe Int
splitOn :: Int -> Cls -> Case Cls
splitC :: Int -> Cl -> Case Cl
expandCatchAlls :: Int -> Cls -> Cls
substBody :: Int -> Integer -> Term -> ClauseBody -> ClauseBody

module Agda.TypeChecking.MetaVars.Mention
class MentionsMeta t
mentionsMeta :: MentionsMeta t => MetaId -> t -> Bool
instance MentionsMeta Constraint
instance MentionsMeta ProblemConstraint
instance MentionsMeta a => MentionsMeta (Tele a)
instance MentionsMeta Elim
instance MentionsMeta a => MentionsMeta (Closure a)
instance (MentionsMeta a, MentionsMeta b, MentionsMeta c) => MentionsMeta (a, b, c)
instance (MentionsMeta a, MentionsMeta b) => MentionsMeta (a, b)
instance MentionsMeta t => MentionsMeta (Maybe t)
instance MentionsMeta t => MentionsMeta [t]
instance MentionsMeta t => MentionsMeta (Arg t)
instance MentionsMeta t => MentionsMeta (Abs t)
instance MentionsMeta Sort
instance MentionsMeta Type
instance MentionsMeta LevelAtom
instance MentionsMeta PlusLevel
instance MentionsMeta Level
instance MentionsMeta 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 cs c</tt> tries to solve constraints <tt>cs</tt>
--   first. If successful, it moves on to solve <tt>c</tt>, otherwise it
--   returns a <tt>Guarded c 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 ()
solveConstraint :: Constraint -> TCM ()
solveConstraint_ :: Constraint -> TCM ()
localState :: MonadState s m => m a -> m a

module Agda.TypeChecking.MetaVars.Occurs
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 in an irrelevant argument
Irrel :: OccursCtx
data UnfoldStrategy
YesUnfold :: UnfoldStrategy
NoUnfold :: UnfoldStrategy
defArgs :: UnfoldStrategy -> OccursCtx -> OccursCtx
unfold :: UnfoldStrategy -> Term -> TCM (Blocked Term)

-- | Leave the strongly rigid position.
weakly :: OccursCtx -> OccursCtx
strongly :: OccursCtx -> OccursCtx
abort :: OccursCtx -> TypeError -> TCM ()

-- | Distinguish relevant and irrelevant variables in occurs check.
type Vars = ([Nat], [Nat])
goIrrelevant :: Vars -> Vars
allowedVar :: Nat -> Vars -> Bool
takeRelevant :: Vars -> [Nat]
underAbs :: Vars -> Vars

-- | Extended occurs check.
class Occurs t
occurs :: Occurs t => UnfoldStrategy -> OccursCtx -> MetaId -> Vars -> t -> TCM t

-- | 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 :: MetaId -> Vars -> Term -> TCM Term

-- | <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>.
prune :: MetaId -> Args -> [Nat] -> TCM PruneResult

-- | <tt>hasBadRigid xs v = 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.
hasBadRigid :: [Nat] -> Term -> Bool
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. <tt>True</tt> is only
--   returned if all arguments could be pruned.
killArgs :: [Bool] -> MetaId -> TCM PruneResult

-- | <tt>killedType [((x1,a1),k1)..((xn,an),kn)] b = ([k'1..k'n],t')</tt>
--   (ignoring <tt>Arg</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 :: [(Arg (String, Type), Bool)] -> Type -> ([Arg Bool], Type)
performKill :: [Arg Bool] -> MetaId -> Type -> TCM ()
instance Eq OccursCtx
instance Show OccursCtx
instance Eq UnfoldStrategy
instance Show UnfoldStrategy
instance Eq PruneResult
instance Show PruneResult
instance Occurs a => Occurs [a]
instance (Occurs a, Occurs b) => Occurs (a, b)
instance Occurs a => Occurs (Arg a)
instance Occurs a => Occurs (Abs a)
instance Occurs Sort
instance Occurs Type
instance Occurs LevelAtom
instance Occurs PlusLevel
instance Occurs Level
instance Occurs Term

module Agda.TypeChecking.Forcing
addForcingAnnotations :: Type -> TCM Type
forcedVariables :: Term -> TCM [Nat]
force :: [Nat] -> Type -> Type


-- | Check that a datatype is strictly positive.
module Agda.TypeChecking.Positivity

-- | Check that the datatypes in the given mutual block are strictly
--   positive.
checkStrictlyPositive :: MutualId -> TCM ()
getDefArity :: Definition -> TCMT IO Nat

-- | Description of an occurrence.
data OccursWhere
LeftOfArrow :: OccursWhere -> OccursWhere

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

-- | as an argument to a bound variable
VarArg :: OccursWhere -> OccursWhere

-- | as an argument of a metavariable
MetaArg :: OccursWhere -> OccursWhere

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

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

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

-- | an unknown position (treated as negative)
Unknown :: OccursWhere
(>*<) :: OccursWhere -> OccursWhere -> OccursWhere
data Item
AnArg :: Nat -> Item
ADef :: QName -> Item
type Occurrences = Map Item [OccursWhere]
(>+<) :: Occurrences -> Occurrences -> Occurrences
concatOccurs :: [Occurrences] -> Occurrences
occursAs :: (OccursWhere -> OccursWhere) -> Occurrences -> Occurrences
here :: Item -> Occurrences
class ComputeOccurrences a
occurrences :: ComputeOccurrences a => [Maybe Item] -> a -> Occurrences

-- | Compute the occurrences in a given definition.
computeOccurrences :: QName -> TCM Occurrences

-- | Eta expand a clause to have the given number of variables. Warning:
--   doesn't update telescope or permutation! 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
prettyGraph :: PrettyTCM a => Graph a Edge -> TCM Doc
data Edge
Edge :: Occurrence -> OccursWhere -> Edge
buildOccurrenceGraph :: Set QName -> TCM (Graph Node Edge)

-- | Given an <a>OccursWhere</a> computes the target node and an
--   <a>Edge</a>. The first argument is the set of names in the current
--   mutual block.
computeEdge :: Set QName -> OccursWhere -> TCM (Node, Edge)
instance Show OccursWhere
instance Eq OccursWhere
instance Eq Item
instance Ord Item
instance Show Item
instance Eq Node
instance Ord Node
instance Show Edge
instance SemiRing Edge
instance PrettyTCM Node
instance Show Node
instance (ComputeOccurrences a, ComputeOccurrences b) => ComputeOccurrences (a, b)
instance ComputeOccurrences a => ComputeOccurrences [a]
instance ComputeOccurrences a => ComputeOccurrences (Arg a)
instance ComputeOccurrences a => ComputeOccurrences (Abs a)
instance ComputeOccurrences a => ComputeOccurrences (Tele a)
instance ComputeOccurrences Type
instance ComputeOccurrences LevelAtom
instance ComputeOccurrences PlusLevel
instance ComputeOccurrences Level
instance ComputeOccurrences Term
instance ComputeOccurrences Clause
instance PrettyTCM OccursWhere
instance SemiRing Occurrence

module Agda.TypeChecking.Polarity
getArity :: QName -> TCM Arity
computePolarity :: QName -> TCM ()

-- | Hack for polarity of size indices.
sizePolarity :: QName -> TCM [Polarity]
checkSizeIndex :: Nat -> Nat -> Type -> TCM Bool
(/\) :: Polarity -> Polarity -> Polarity
neg :: Polarity -> Polarity
composePol :: Polarity -> Polarity -> Polarity
class HasPolarity a
polarities :: HasPolarity a => Nat -> a -> TCM [Polarity]
polarity :: HasPolarity a => Nat -> a -> TCM Polarity
instance HasPolarity LevelAtom
instance HasPolarity PlusLevel
instance HasPolarity Level
instance HasPolarity Term
instance HasPolarity Type
instance (HasPolarity a, HasPolarity b) => HasPolarity (a, b)
instance HasPolarity a => HasPolarity [a]
instance HasPolarity a => HasPolarity (Abs a)
instance HasPolarity a => HasPolarity (Arg a)

module Agda.TypeChecking.Quote
quotingKit :: TCM (Term -> Term, Type -> Term)
quoteName :: QName -> Term
quoteTerm :: Term -> TCM Term
quoteType :: Type -> TCM Term
agdaTermType :: TCM Type
qNameType :: TCM Type
isCon :: QName -> TCM Term -> TCM Bool
unquoteFailedGeneric :: String -> TCM a
unquoteFailed :: String -> String -> Term -> TCM a
class Unquote a
unquote :: Unquote a => Term -> TCM a
unquoteH :: Unquote a => Arg Term -> TCM a
unquoteN :: Unquote a => Arg Term -> TCM a
choice :: Monad m => [(m Bool, m a)] -> m a -> m a
instance Unquote Term
instance Unquote Type
instance Unquote Level
instance Unquote Sort
instance Unquote a => Unquote (Abs a)
instance Unquote QName
instance Unquote Relevance
instance Unquote Hiding
instance Unquote a => Unquote [a]
instance Unquote Integer
instance Unquote a => Unquote (Arg a)


-- | Primitive functions, such as addition on builtin integers.
module Agda.TypeChecking.Primitive

-- | Rewrite a literal to constructor form if possible.
constructorForm :: Term -> TCM Term
data PrimitiveImpl
PrimImpl :: Type -> PrimFun -> PrimitiveImpl
newtype Str
Str :: String -> Str
unStr :: Str -> String
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
toTerm :: ToTerm a => TCM (a -> 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 -> TCM (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 :: TCM (Reduced a a') -> (a -> b) -> (a' -> TCM (Reduced b b')) -> TCM (Reduced b b')
redReturn :: a -> TCM (Reduced a' a)
fromReducedTerm :: (Term -> Maybe a) -> TCM (FromTermFunction a)
fromLiteral :: (Literal -> Maybe a) -> TCM (FromTermFunction a)
primTrustMe :: TCM PrimitiveImpl
primQNameType :: TCM PrimitiveImpl
primQNameDefinition :: TCM PrimitiveImpl
primDataConstructors :: TCM PrimitiveImpl
mkPrimLevelZero :: TCM PrimitiveImpl
mkPrimLevelSuc :: TCM PrimitiveImpl
mkPrimLevelMax :: TCM PrimitiveImpl
mkPrimFun1TCM :: (FromTerm a, ToTerm b) => TCM Type -> (a -> TCM b) -> TCM PrimitiveImpl
mkPrimFun1 :: (PrimType a, PrimType b, FromTerm a, ToTerm b) => (a -> b) -> TCM PrimitiveImpl
mkPrimFun2 :: (PrimType a, PrimType b, PrimType c, FromTerm a, ToTerm a, FromTerm b, 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
gpi :: Hiding -> Relevance -> String -> TCM Type -> TCM Type -> TCM Type
hPi :: String -> TCM Type -> TCM Type -> TCM Type
nPi :: String -> TCM Type -> TCM Type -> TCM Type
var :: Integer -> TCM Term
gApply :: Hiding -> TCM Term -> TCM Term -> TCM Term
(<@>) :: TCM Term -> TCM Term -> TCM Term
(<#>) :: TCM Term -> TCM Term -> TCM Term
list :: TCM Term -> TCM Term
io :: TCM Term -> TCM Term
el :: TCM Term -> TCM Type
tset :: TCM Type

-- | Abbreviation: <tt>argN = <a>Arg</a> <a>NotHidden</a>
--   <a>Relevant</a></tt>.
argN :: e -> Arg e

-- | Abbreviation: <tt>argH = <a>Arg</a> <a>Hidden</a>
--   <a>Relevant</a></tt>.
argH :: e -> Arg 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)
lookupPrimitiveFunction :: String -> TCM PrimitiveImpl

-- | Rebind a primitive. Assumes everything is type correct. Used when
--   importing a module with primitives.
rebindPrimitive :: String -> TCM PrimFun
instance Eq Str
instance Ord Str
instance Eq Nat
instance Ord Nat
instance Num Nat
instance Integral Nat
instance Enum Nat
instance Real Nat
instance Eq Lvl
instance Ord Lvl
instance (ToTerm a, FromTerm a) => FromTerm [a]
instance FromTerm Bool
instance FromTerm QName
instance FromTerm Str
instance FromTerm Char
instance FromTerm Double
instance FromTerm Lvl
instance FromTerm Nat
instance FromTerm Integer
instance (PrimTerm a, ToTerm a) => ToTerm [a]
instance ToTerm Type
instance ToTerm Bool
instance ToTerm QName
instance ToTerm Str
instance ToTerm Char
instance ToTerm Double
instance ToTerm Lvl
instance ToTerm Nat
instance ToTerm Integer
instance PrimTerm a => PrimTerm (IO a)
instance PrimTerm a => PrimTerm [a]
instance PrimTerm Type
instance PrimTerm QName
instance PrimTerm Lvl
instance PrimTerm Nat
instance PrimTerm Str
instance PrimTerm Double
instance PrimTerm Char
instance PrimTerm Bool
instance PrimTerm Integer
instance PrimTerm a => PrimType a
instance (PrimType a, PrimType b) => PrimTerm (a -> b)
instance Show Nat
instance Show Lvl

module Agda.TypeChecking.CompiledClause.Match
matchCompiled :: CompiledClauses -> MaybeReducedArgs -> TCM (Reduced (Blocked Args) Term)
type Stack = [(CompiledClauses, MaybeReducedArgs, Args -> Args)]
match :: CompiledClauses -> MaybeReducedArgs -> (Args -> Args) -> Stack -> TCM (Reduced (Blocked Args) Term)
match' :: Stack -> TCM (Reduced (Blocked Args) Term)
unfoldCorecursion :: Term -> TCM (Blocked Term)

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
Yes :: [Term] -> Match
No :: Match
DontKnow :: (Maybe MetaId) -> Match
matchPatterns :: [Arg Pattern] -> [Arg Term] -> TCM (Match, [Arg Term])
matchPattern :: Arg Pattern -> Arg Term -> TCM (Match, Arg Term)
instance Monoid Match

module Agda.TypeChecking.Rebind

-- | Change <a>Bind</a>s to <tt>NoBind</tt> if the variable is not used in
--   the body. Also normalises the body in the process. Or not. Disabled.
rebindClause :: Clause -> TCM Clause

module Agda.TypeChecking.Rules.LHS.Implicit

-- | Insert implicit patterns in a problem.
insertImplicitProblem :: Problem -> TCM Problem

-- | Insert implicit patterns in a list of patterns.
insertImplicitPatterns :: [NamedArg Pattern] -> Telescope -> TCM [NamedArg Pattern]

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 :: MetaId -> TCM Bool

-- | Performing the meta variable assignment.
--   
--   The instantiation should not be an <a>InstV</a> or <a>InstS</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 -> Term -> TCM ()
newSortMeta :: TCM Sort
newSortMetaCtx :: Args -> TCM Sort
newTypeMeta :: Sort -> TCM Type
newTypeMeta_ :: TCM Type

-- | Create a new <a>implicit from scope</a> metavariable
newIFSMeta :: Type -> TCM Term

-- | Create a new value meta with specific dependencies.
newIFSMetaCtx :: Type -> Args -> TCM Term

-- | Create a new metavariable, possibly η-expanding in the process.
newValueMeta :: Type -> TCM Term
newValueMetaCtx :: Type -> Args -> TCM Term

-- | Create a new value meta without η-expanding.
newValueMeta' :: Type -> TCM Term

-- | Create a new value meta with specific dependencies.
newValueMetaCtx' :: Type -> Args -> TCM Term
newTelMeta :: Telescope -> TCM Args
newArgsMeta :: Type -> TCM Args
newArgsMetaCtx :: Type -> Telescope -> 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 -> Args -> TCM Term
newQuestionMark :: Type -> TCM Term

-- | Construct a blocked constant if there are constraints.
blockTerm :: Type -> TCM Term -> TCM Term
blockTermOnProblem :: Type -> Term -> ProblemId -> TCM Term

-- | <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_ :: Expr -> Type -> 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 :: Expr -> Type -> TCM Bool -> TCM Term

-- | 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 :: MetaId -> Args -> Term -> TCM ()

-- | <pre>
--   assign sort? x vs v
--   </pre>
assign :: MetaId -> Args -> Term -> TCM ()
type FVs = VarSet

-- | Check that arguments to a metavar are in pattern fragment. Assumes all
--   arguments already in whnf. 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 list of corresponding indices for each arg. Linearity
--   has to be checked separately.
--   
--   <tt>reverse</tt> is necessary because we are directly abstracting over
--   this list <tt>ids</tt>.
checkAllVars :: Args -> TCM [Nat]

-- | filter out irrelevant args and check that all others are variables.
--   Return the reversed list of variables.
allVarOrIrrelevant :: Args -> Maybe [Arg Nat]
updateMeta :: MetaId -> Term -> TCM ()
instance Eq MetaKind
instance Enum MetaKind
instance Bounded MetaKind

module Agda.TypeChecking.SizedTypes

-- | Compare two sizes. Only with --sized-types.
compareSizes :: Comparison -> Term -> Term -> TCM ()
trivial :: Term -> Term -> TCM Bool

-- | Find the size constraints.
getSizeConstraints :: TCM [SizeConstraint]
getSizeMetas :: TCM [(MetaId, Int)]
data SizeExpr
SizeMeta :: MetaId -> [CtxId] -> SizeExpr
Rigid :: CtxId -> SizeExpr
data SizeConstraint
Leq :: SizeExpr -> Int -> SizeExpr -> SizeConstraint
computeSizeConstraint :: Closure Constraint -> TCM (Maybe SizeConstraint)

-- | Throws a <a>patternViolation</a> if the term isn't a proper size
--   expression.
sizeExpr :: Term -> TCM (SizeExpr, Int)
flexibleVariables :: SizeConstraint -> [(MetaId, [CtxId])]
haveSizedTypes :: TCM Bool
solveSizeConstraints :: TCM ()
instance Show SizeConstraint
instance Show SizeExpr


-- | Generates data used for precise syntax highlighting.
module Agda.Interaction.Highlighting.Generate

-- | Generates syntax highlighting information.
generateSyntaxInfo :: AbsolutePath -> Maybe TCErr -> TopLevelInfo -> [TerminationError] -> TCM HighlightingInfo

-- | Generates syntax highlighting information for an error, represented as
--   a range and an optional string. The error range is completed so that
--   there are no gaps in it.
--   
--   Nothing is generated unless the file name component of the range is
--   defined.
generateErrorInfo :: Range -> Maybe String -> Maybe HighlightingInfo

-- | All the properties.
tests :: IO Bool


-- | Function for generating highlighted, hyperlinked HTML from Agda
--   sources.
module Agda.Interaction.Highlighting.HTML

-- | Generates HTML files from all the sources which the given module
--   depends on (including the module itself).
--   
--   This function should only be called after type checking has completed
--   successfully.
generateHTML :: ModuleName -> TCM ()

module Agda.TypeChecking.Injectivity

-- | Reduce simple (single clause) definitions.
reduceHead :: Term -> TCM (Blocked Term)
headSymbol :: Term -> TCM (Maybe TermHead)
checkInjectivity :: QName -> [Clause] -> TCM FunctionInverse

-- | Argument should be on weak head normal form.
functionInverse :: Term -> TCM InvView
data InvView
Inv :: QName -> Args -> (Map TermHead Clause) -> InvView
NoInv :: InvView
useInjectivity :: Comparison -> Type -> Term -> Term -> TCM ()

module Agda.TypeChecking.Conversion
mlevel :: TCM (Maybe Term)
nextPolarity :: [Polarity] -> (Polarity, [Polarity])

-- | Check if to lists of arguments are the same (and all variables).
--   Precondition: the lists have the same length.
sameVars :: Args -> Args -> 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 :: Args -> Args -> Maybe [Bool]
equalTerm :: Type -> Term -> Term -> TCM ()
equalAtom :: Type -> Term -> Term -> TCM ()
equalType :: Type -> Type -> TCM ()

-- | Type directed equality on values.
compareTerm :: Comparison -> Type -> Term -> Term -> TCM ()
compareTerm' :: Comparison -> Type -> Term -> Term -> TCM ()

-- | <tt>compareTel t1 t2 cmp tel1 tel1</tt> checks whether pointwise
--   <tt>tel1 <tt>cmp</tt> tel2</tt> and complains that <tt>t2 <tt>cmp</tt>
--   t1</tt> failed if not.
compareTel :: Type -> Type -> Comparison -> Telescope -> Telescope -> TCM ()

-- | Syntax directed equality on atomic values
compareAtom :: Comparison -> Type -> Term -> Term -> TCM ()

-- | Type-directed equality on eliminator spines
compareElims :: [Polarity] -> Type -> Term -> [Elim] -> [Elim] -> TCM ()

-- | 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 ()
compareSort :: Comparison -> Sort -> Sort -> TCM ()

-- | Check that the first sort is less or equal to the second.
leqSort :: Sort -> Sort -> TCM ()
leqLevel :: Level -> Level -> TCM ()
equalLevel :: Level -> Level -> TCM ()

-- | Check that the first sort equal to the second.
equalSort :: Sort -> Sort -> TCM ()

module Agda.TypeChecking.Rules.LHS.Unify
newtype Unify a
U :: ReaderT UnifyEnv (WriterT UnifyOutput (ExceptionT UnifyException (StateT UnifyState TCM))) a -> Unify a
unUnify :: Unify a -> ReaderT UnifyEnv (WriterT UnifyOutput (ExceptionT UnifyException (StateT UnifyState TCM))) a
data UnifyMayPostpone
MayPostpone :: UnifyMayPostpone
MayNotPostpone :: UnifyMayPostpone
type UnifyEnv = UnifyMayPostpone
emptyUEnv :: UnifyMayPostpone
noPostponing :: Unify a -> Unify a
askPostpone :: Unify UnifyMayPostpone

-- | Output the result of unification (success or maybe).
type UnifyOutput = Unifiable
emptyUOutput :: UnifyOutput

-- | Were two terms unifiable or did we have to postpone some equation such
--   that we are not sure?
data Unifiable

-- | Unification succeeded.
Definitely :: Unifiable

-- | Unification did not fail, but we had to postpone a part.
Possibly :: Unifiable

-- | Tell that something could not be unified right now, so the unification
--   succeeds only <a>Possibly</a>.
reportPostponing :: Unify ()

-- | Check whether unification proceeded without postponement.
ifClean :: Unify () -> Unify a -> Unify a -> Unify a
data Equality
Equal :: TypeHH -> Term -> Term -> Equality
type Sub = Map Nat Term
data UnifyException
ConstructorMismatch :: Type -> Term -> Term -> UnifyException
StronglyRigidOccurrence :: Type -> Term -> Term -> UnifyException
GenericUnifyException :: String -> UnifyException
data UnifyState
USt :: Sub -> [Equality] -> UnifyState
uniSub :: UnifyState -> Sub
uniConstr :: UnifyState -> [Equality]
emptyUState :: UnifyState
constructorMismatch :: Type -> Term -> Term -> Unify a
constructorMismatchHH :: TypeHH -> Term -> Term -> Unify a
onSub :: (Sub -> a) -> Unify a
modSub :: (Sub -> Sub) -> Unify ()
checkEqualities :: [Equality] -> TCM ()

-- | Force equality now instead of postponing it using <a>addEquality</a>.
checkEquality :: Type -> Term -> Term -> TCM ()

-- | Try equality. If constraints remain, postpone (enter unsafe mode).
--   Heterogeneous equalities cannot be tried nor reawakened, so we can
--   throw them away and flag <a>dirty</a>.
checkEqualityHH :: TypeHH -> Term -> Term -> Unify ()

-- | Check whether heterogeneous situation is really homogeneous. If not,
--   give up.
forceHom :: TypeHH -> TCM Type
addEquality :: Type -> Term -> Term -> Unify ()
addEqualityHH :: TypeHH -> Term -> Term -> Unify ()
takeEqualities :: Unify [Equality]

-- | Includes flexible occurrences, metas need to be solved. TODO: relax?
--   TODO: later solutions may remove flexible occurences
occursCheck :: Nat -> Term -> Type -> Unify ()

-- | Assignment with preceding occurs check.
(|->) :: Nat -> (Term, Type) -> Unify ()
makeSubstitution :: Sub -> [Term]

-- | Apply the current substitution on a term and reduce to weak head
--   normal form.
class UReduce t
ureduce :: UReduce t => t -> Unify t

-- | Take a substitution σ and ensure that no variables from the domain
--   appear in the targets. The context of the targets is not changed.
--   TODO: can this be expressed using makeSubstitution and substs?
flattenSubstitution :: Substitution -> Substitution
data UnificationResult
Unifies :: Substitution -> UnificationResult
NoUnify :: Type -> Term -> Term -> UnificationResult
DontKnow :: TCErr -> UnificationResult

-- | Are we in a homogeneous (one type) or heterogeneous (two types)
--   situation?
data HomHet a

-- | homogeneous
Hom :: a -> HomHet a

-- | heterogeneous
Het :: a -> a -> HomHet a
isHom :: HomHet a -> Bool
fromHom :: HomHet a -> a
leftHH :: HomHet a -> a
rightHH :: HomHet a -> a
type TermHH = HomHet Term
type TypeHH = HomHet Type
type TelHH = Tele (Arg TypeHH)
type TelViewHH = TelV TypeHH
absAppHH :: SubstHH t tHH => Abs t -> TermHH -> tHH
class ApplyHH t
applyHH :: ApplyHH t => t -> HomHet Args -> HomHet t
substHH :: SubstHH t tHH => TermHH -> t -> tHH

-- | <tt>substHH u t</tt> substitutes <tt>u</tt> for the 0th variable in
--   <tt>t</tt>.
class SubstHH t tHH
substUnderHH :: SubstHH t tHH => Nat -> TermHH -> t -> tHH
trivialHH :: SubstHH t tHH => t -> tHH

-- | Unify indices.
unifyIndices_ :: MonadTCM tcm => FlexibleVars -> Type -> [Arg Term] -> [Arg Term] -> tcm Substitution
unifyIndices :: MonadTCM tcm => FlexibleVars -> Type -> [Arg Term] -> [Arg Term] -> tcm UnificationResult

-- | Given the type of a constructor application the corresponding data or
--   record type, applied to its parameters (extracted from the given
--   type), is returned.
--   
--   Precondition: The type has to correspond to an application of the
--   given constructor.
dataOrRecordType :: QName -> Type -> TCM (Maybe Type)
dataOrRecordType' :: QName -> Type -> TCM (Maybe (QName, Type, Args))

-- | Heterogeneous situation. <tt>a1</tt> and <tt>a2</tt> need to end in
--   same datatype/record.
dataOrRecordTypeHH :: QName -> TypeHH -> TCM (Maybe TypeHH)

-- | Return record type identifier if argument is a record type.
isEtaRecordTypeHH :: MonadTCM tcm => TypeHH -> tcm (Maybe (QName, HomHet Args))

-- | Views an expression (pair) as type shape. Fails if not same shape.
data ShapeView a
PiSh :: (Arg a) -> (Abs a) -> ShapeView a
FunSh :: (Arg a) -> a -> ShapeView a

-- | data/record
DefSh :: QName -> ShapeView a

-- | neutral type
VarSh :: Nat -> ShapeView a

-- | built-in type
LitSh :: Literal -> ShapeView a
SortSh :: ShapeView a

-- | some meta
MetaSh :: ShapeView a

-- | not a type or not definitely same shape
ElseSh :: ShapeView a

-- | Return the type and its shape. Expects input in (u)reduced form.
shapeView :: Type -> Unify (Type, ShapeView Type)

-- | Return the reduced type(s) and the common shape.
shapeViewHH :: TypeHH -> Unify (TypeHH, ShapeView TypeHH)

-- | <tt>telViewUpToHH n t</tt> takes off the first <tt>n</tt> function
--   types of <tt>t</tt>. Takes off all if $n &lt; 0$.
telViewUpToHH :: Int -> TypeHH -> Unify TelViewHH
instance Typeable1 HomHet
instance Typeable1 ShapeView
instance Data a => Data (HomHet a)
instance Show a => Show (HomHet a)
instance Eq a => Eq (HomHet a)
instance Ord a => Ord (HomHet a)
instance Functor HomHet
instance Foldable HomHet
instance Traversable HomHet
instance Monad Unify
instance MonadIO Unify
instance Functor Unify
instance Applicative Unify
instance MonadException UnifyException Unify
instance MonadWriter UnifyOutput Unify
instance Data a => Data (ShapeView a)
instance Show a => Show (ShapeView a)
instance (Eq a, Raise a) => Eq (ShapeView a)
instance (Ord a, Raise a) => Ord (ShapeView a)
instance Functor ShapeView
instance SubstHH a b => SubstHH (Tele a) (Tele b)
instance (SubstHH a a', SubstHH b b') => SubstHH (a, b) (a', b')
instance SubstHH a b => SubstHH (Abs a) (Abs b)
instance SubstHH a b => SubstHH (Arg a) (Arg b)
instance SubstHH Type (HomHet Type)
instance SubstHH Term (HomHet Term)
instance (Free a, Subst a) => SubstHH (HomHet a) (HomHet a)
instance ApplyHH Type
instance ApplyHH Term
instance PrettyTCM a => PrettyTCM (HomHet a)
instance Subst a => Subst (HomHet a)
instance Raise a => Raise (HomHet a)
instance UReduce t => UReduce (Maybe t)
instance UReduce t => UReduce (HomHet t)
instance UReduce Type
instance UReduce Term
instance Subst Equality
instance MonadTCM Unify
instance MonadState TCState Unify
instance Error UnifyException
instance Monoid Unifiable
instance MonadReader TCEnv Unify


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

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

-- | 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 telescope. Binds the variables defined by the telescope.
checkTelescope_ :: 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.
checkTypedBindings_ :: TypedBindings -> (Telescope -> TCM a) -> TCM a
data LamOrPi
LamNotPi :: LamOrPi
PiNotLam :: LamOrPi

-- | 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 -> Hiding -> Relevance -> TypedBinding -> ([(String, Type)] -> TCM a) -> TCM a

-- | Type check a lambda expression.
checkLambda :: Arg TypedBinding -> Expr -> Type -> TCM Term
checkLiteral :: Literal -> Type -> TCM Term
litType :: Literal -> TCM Type
reduceCon :: QName -> TCM QName

-- | <tt>checkArguments' exph r args t0 t e 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 -> Expr -> (Args -> Type -> TCM Term) -> TCM Term
unScope :: Expr -> Expr

-- | Type check an expression.
checkExpr :: Expr -> Type -> TCM Term
domainFree :: Hiding -> Relevance -> Name -> LamBinding
checkMeta :: (Type -> TCM Term) -> Type -> MetaInfo -> TCM Term
inferMeta :: (Type -> TCM Term) -> MetaInfo -> TCM (Args -> Term, Type)

-- | Infer the type of a head thing (variable, function symbol, or
--   constructor)
inferHead :: Expr -> TCM (Args -> Term, Type)
inferDef :: (QName -> 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 -> QName -> [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
data ExpandHidden
ExpandLast :: ExpandHidden
DontExpandLast :: ExpandHidden
traceCallE :: Error e => (Maybe r -> Call) -> ErrorT e TCM r -> ErrorT e TCM r

-- | 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.
--   
--   TODO: doesn't do proper blocking of terms
checkArguments :: ExpandHidden -> Range -> [NamedArg Expr] -> Type -> Type -> ErrorT Type TCM (Args, Type)

-- | Check that a list of arguments fits a telescope.
checkArguments_ :: ExpandHidden -> Range -> [NamedArg Expr] -> Telescope -> TCM Args

-- | Infer the type of an expression. Implemented by checking against a
--   meta variable.
inferExpr :: Expr -> TCM (Term, Type)
checkTerm :: Term -> Type -> TCM Term
checkLetBindings :: [LetBinding] -> TCM a -> TCM a
checkLetBinding :: LetBinding -> TCM a -> TCM a
instance Eq LamOrPi
instance Show LamOrPi
instance Error Type

module Agda.TypeChecking.Rules.Builtin

-- | Bind a builtin thing to an expression.
bindBuiltin :: String -> Expr -> 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 ()


-- | Handling of the INFINITY, SHARP and FLAT builtins.
module Agda.TypeChecking.Rules.Builtin.Coinduction

-- | The type of <tt>&amp;#x221e</tt>.
typeOfInf :: TCM Type

-- | The type of <tt>&amp;#x266f_</tt>.
typeOfSharp :: TCM Type

-- | The type of <tt>&amp;#x266d</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 ()

-- | 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 (Maybe CoinductionKit)

module Agda.Termination.TermCheck

-- | Termination check a sequence of declarations.
termDecls :: [Declaration] -> TCM Result

-- | The result of termination checking a module.
type Result = [TerminationError]

-- | Termination check clauses
data DeBruijnPat
instance StripAllProjections Term
instance StripAllProjections a => StripAllProjections [a]
instance StripAllProjections a => StripAllProjections (Arg a)
instance PrettyTCM DeBruijnPat


-- | 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
notAHaskellKind :: Type -> TCM a
notAHaskellType :: Type -> TCM a
getHsType :: QName -> TCM HaskellType
getHsVar :: Nat -> TCM HaskellCode
isHaskellKind :: Type -> TCM Bool
haskellKind :: Type -> TCM HaskellKind

-- | Note that <tt>Inf a b</tt>, where <tt>Inf</tt> is the INFINITY
--   builtin, is translated to <tt><a>translation 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.Rules.Data

-- | Type check a datatype definition. Assumes that the type has already
--   been checked.
checkDataDef :: DefInfo -> QName -> [LamBinding] -> [Constructor] -> TCM ()

-- | Type check a constructor declaration. Checks that the constructor
--   targets the datatype and that it fits inside the declared sort.
checkConstructor :: QName -> Telescope -> Nat -> Sort -> Constructor -> TCM ()

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

-- | Check that a type constructs something of the given datatype. The
--   first argument is the number of parameters to the datatype. TODO: what
--   if there's a meta here?
constructs :: Int -> Type -> QName -> TCM ()

-- | Force a type to be a specific datatype.
forceData :: QName -> Type -> TCM Type

-- | Is the type coinductive? Returns <a>Nothing</a> if the answer cannot
--   be determined.
isCoinductive :: Type -> TCM (Maybe Bool)

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).</li>
--   <li><i><tt>fields</tt></i> List of field signatures.</li>
--   </ul>
checkRecDef :: DefInfo -> QName -> Maybe QName -> [LamBinding] -> Expr -> [Constructor] -> 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>q</tt> </i> name of the record constructor</li>
--   <li><i><tt>tel</tt> </i> parameters</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 -> QName -> Telescope -> Telescope -> [Declaration] -> TCM ()

module Agda.TypeChecking.UniversePolymorphism
compareLevel :: Comparison -> Level -> Level -> TCM ()
isLevelConstraint :: Constraint -> Bool

module Agda.TypeChecking.Rules.LHS.Split

-- | TODO: move to Agda.Syntax.Abstract.View
asView :: Pattern -> ([Name], Pattern)

-- | TODO: move somewhere else
expandLitPattern :: NamedArg Pattern -> TCM (NamedArg Pattern)

-- | Split a problem at the first constructor of datatype type. Implicit
--   patterns should have been inserted.
splitProblem :: Problem -> TCM (Either SplitError SplitProblem)

-- | Checks that the indices are constructors (or literals) applied to
--   distinct variables which do not occur free in the parameters.
wellFormedIndices :: [Arg Term] -> [Arg Term] -> TCM ()

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, [Term], [Type])

-- | Produce a nice error message when splitting failed
nothingToSplitError :: Problem -> TCM a

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 :: MonadTrans t => Int -> TCM Doc -> t (TCMT IO) ()
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 :: Integral a => QName -> a -> Term
unifyI :: Telescope -> [Nat] -> Type -> Args -> Args -> Compile TCM [Maybe Term]
takeTele :: (Eq a, Num a) => a -> Tele a1 -> Tele a1

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

module Agda.TypeChecking.Rules.LHS
data DotPatternInst
DPI :: Expr -> Term -> Type -> DotPatternInst
data AsBinding
AsB :: Name -> Term -> Type -> AsBinding

-- | Compute the set of flexible patterns in a list of patterns. The result
--   is the deBruijn indices of the flexible patterns. A pattern is
--   flexible if it is dotted or implicit.
flexiblePatterns :: [NamedArg Pattern] -> FlexibleVars

-- | Compute the dot pattern instantiations.
dotPatternInsts :: [NamedArg Pattern] -> Substitution -> [Type] -> [DotPatternInst]
instantiatePattern :: Substitution -> Permutation -> [Arg Pattern] -> [Arg Pattern]

-- | 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 :: Clause -> Problem -> TCM ()

-- | Check that a dot pattern matches it's instantiation.
checkDotPattern :: DotPatternInst -> TCM ()

-- | Bind the variables in a left hand side. Precondition: the patterns
--   should all be <a>VarP</a>, <a>WildP</a>, or <a>ImplicitP</a> and the
--   telescope should have the same size as the pattern list.
bindLHSVars :: [NamedArg Pattern] -> Telescope -> TCM a -> TCM a

-- | Bind as patterns
bindAsPatterns :: [AsBinding] -> TCM a -> TCM a

-- | Rename the variables in a telescope using the names from a given
--   pattern
useNamesFromPattern :: [NamedArg Pattern] -> Telescope -> Telescope

-- | Check a LHS. Main function.
checkLeftHandSide :: Clause -> [NamedArg Pattern] -> Type -> (Telescope -> Telescope -> [Term] -> [String] -> [Arg Pattern] -> Type -> Permutation -> TCM a) -> TCM a
noPatternMatchingOnCodata :: [Arg Pattern] -> TCM ()
instance PrettyTCM AsBinding
instance Raise AsBinding
instance Subst AsBinding
instance PrettyTCM DotPatternInst
instance Subst DotPatternInst

module Agda.TypeChecking.Coverage
data SplitClause
SClause :: Telescope -> Permutation -> [Arg Pattern] -> [Term] -> SplitClause

-- | type of variables in scPats
scTel :: SplitClause -> Telescope

-- | how to get from the variables in the patterns to the telescope
scPerm :: SplitClause -> Permutation
scPats :: SplitClause -> [Arg Pattern]

-- | substitution from scTel to old context
scSubst :: SplitClause -> [Term]
type Covering = [SplitClause]
data SplitError

-- | neither data type nor record
NotADatatype :: Type -> SplitError

-- | data type, but in irrelevant position
IrrelevantDatatype :: Type -> SplitError

-- | coinductive data type
CoinductiveDatatype :: Type -> SplitError

-- | record type, but no constructor
NoRecordConstructor :: Type -> SplitError
CantSplit :: QName -> Telescope -> Args -> Args -> [Term] -> SplitError
GenericSplitError :: String -> SplitError
type CoverM = ExceptionT SplitError TCM
typeOfVar :: Telescope -> Nat -> Arg Type

-- | Top-level function for checking pattern coverage.
checkCoverage :: QName -> TCM ()

-- | Check that the list of clauses covers the given split clause. Returns
--   the missing cases.
cover :: [Clause] -> SplitClause -> TCM (Set Nat, [[Arg Pattern]])

-- | Check that a type is a non-irrelevant datatype or a record with named
--   constructor. Unless the <a>Induction</a> argument is
--   <a>CoInductive</a> the data type must be inductive.
isDatatype :: (MonadTCM tcm, MonadException SplitError tcm) => Induction -> Arg Type -> tcm (QName, [Arg Term], [Arg Term], [QName])

-- | <pre>
--   dtype == d pars ixs
--   </pre>
computeNeighbourhood :: Telescope -> Telescope -> Permutation -> QName -> Args -> Args -> Nat -> OneHolePatterns -> QName -> CoverM [SplitClause]

-- | split Δ x ps. Δ ⊢ ps, x ∈ Δ (deBruijn index)
splitClause :: Clause -> Nat -> TCM (Either SplitError Covering)
splitClauseWithAbs :: Clause -> Nat -> TCM (Either SplitError (Either SplitClause Covering))
split :: Induction -> Telescope -> Permutation -> [Arg Pattern] -> Nat -> TCM (Either SplitError Covering)
split' :: Induction -> Telescope -> Permutation -> [Arg Pattern] -> Nat -> TCM (Either SplitError (Either SplitClause Covering))
instance Show SplitError
instance Error SplitError
instance PrettyTCM SplitError

module Agda.TypeChecking.Empty

-- | Make sure that a type is empty.
isReallyEmptyType :: Type -> TCM ()
isEmptyType :: Type -> TCM ()

module Agda.TypeChecking.With
showPat :: Pattern -> TCM Doc
withFunctionType :: Telescope -> [Term] -> [Type] -> Telescope -> Type -> TCM Type

-- | Compute the clauses for the with-function given the original patterns.
buildWithFunction :: QName -> Telescope -> [Arg Pattern] -> Permutation -> Nat -> Nat -> [Clause] -> TCM [Clause]

-- | <pre>
--   stripWithClausePatterns Γ qs π ps = ps'
--   </pre>
--   
--   <tt>Δ</tt> - context bound by lhs of original function (not an
--   argument)
--   
--   <tt>Γ</tt> - type of arguments to original function
--   
--   <tt>qs</tt> - internal patterns for original function
--   
--   <tt>π</tt> - permutation taking <tt>vars(qs)</tt> to
--   <tt>support(Δ)</tt>
--   
--   <tt>ps</tt> - patterns in with clause (presumably of type <tt>Γ</tt>)
--   
--   <tt>ps'</tt> - patterns for with function (presumably of type
--   <tt>Δ</tt>)
stripWithClausePatterns :: Telescope -> [Arg Pattern] -> Permutation -> [NamedArg Pattern] -> TCM [NamedArg Pattern]

-- | Construct the display form for a with function. It will display
--   applications of the with function as applications to the original
--   function. For instance, <tt>aux a b c</tt> as <tt>f (suc a) (suc b) |
--   c</tt>
withDisplayForm :: QName -> QName -> Telescope -> Telescope -> Nat -> [Arg Pattern] -> Permutation -> TCM DisplayForm
patsToTerms :: [Arg Pattern] -> [Arg DisplayTerm]

module Agda.TypeChecking.Rules.Def
checkFunDef :: Delayed -> DefInfo -> QName -> [Clause] -> TCM ()

-- | Type check a definition by pattern matching. The first argument
--   specifies whether the clauses are delayed or not.
checkFunDef' :: Type -> Relevance -> Delayed -> DefInfo -> QName -> [Clause] -> TCM ()

-- | Insert some patterns in the in with-clauses LHS of the given RHS
insertPatterns :: [Pattern] -> RHS -> RHS
data WithFunctionProblem
NoWithFunction :: WithFunctionProblem
WithFunction :: QName -> QName -> Telescope -> Telescope -> Telescope -> [Term] -> [Type] -> Type -> [Arg Pattern] -> Permutation -> Permutation -> [Clause] -> WithFunctionProblem

-- | Type check a function clause.
checkClause :: Type -> Clause -> TCM Clause
checkWithFunction :: WithFunctionProblem -> TCM ()

-- | Type check a where clause. The first argument is the number of
--   variables bound in the left hand side.
checkWhere :: Nat -> [Declaration] -> TCM a -> TCM a

-- | Check if a pattern contains an absurd pattern. For instance, <tt>suc
--   ()</tt>
containsAbsurdPattern :: Pattern -> Bool
actualConstructor :: QName -> TCM QName

module Agda.TypeChecking.Rules.Decl

-- | Type check a sequence of declarations.
checkDecls :: [Declaration] -> TCM ()

-- | Type check a single declaration.
checkDecl :: Declaration -> TCM ()

-- | Type check an axiom.
checkAxiom :: DefInfo -> Relevance -> QName -> Expr -> TCM ()

-- | Type check a primitive function declaration.
checkPrimitive :: DefInfo -> QName -> Expr -> TCM ()

-- | Check a pragma.
checkPragma :: Range -> Pragma -> TCM ()

-- | Type check a bunch of mutual inductive recursive definitions.
checkMutual :: DeclInfo -> [Declaration] -> TCM ()

-- | Type check the type signature of an inductive or recursive definition.
checkTypeSignature :: TypeSignature -> TCM ()

-- | Type check a module.
checkSection :: ModuleInfo -> ModuleName -> Telescope -> [Declaration] -> TCM ()
checkModuleArity :: ModuleName -> Telescope -> [NamedArg Expr] -> TCM Telescope

-- | Check an application of a section.
checkSectionApplication :: ModuleInfo -> ModuleName -> ModuleApplication -> Map QName QName -> Map ModuleName ModuleName -> TCM ()
checkSectionApplication' :: ModuleInfo -> ModuleName -> ModuleApplication -> Map QName QName -> Map ModuleName ModuleName -> TCM ()

-- | Type check an import declaration. Actually doesn't do anything, since
--   all the work is done when scope checking.
checkImport :: ModuleInfo -> ModuleName -> TCM ()

module Agda.TypeChecker

-- | Type check a sequence of declarations.
checkDecls :: [Declaration] -> TCM ()

-- | Type check a single declaration.
checkDecl :: Declaration -> TCM ()

-- | Infer the type of an expression. Implemented by checking against a
--   meta variable.
inferExpr :: Expr -> TCM (Term, Type)

-- | Type check an expression.
checkExpr :: Expr -> Type -> TCM Term


-- | This module deals with finding imported modules and loading their
--   interface files.
module Agda.Interaction.Imports

-- | Merge an interface into the current proof state.
mergeInterface :: Interface -> TCM ()
addImportedThings :: Signature -> BuiltinThings PrimFun -> Set String -> 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)

-- | 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, Either Warnings ClockTime) -> TCM (Interface, Either Warnings ClockTime)

-- | Warnings.
--   
--   Invariant: The fields are never empty at the same time.
data Warnings
Warnings :: [TerminationError] -> [Range] -> Constraints -> Warnings

-- | Termination checking problems are not reported if
--   <a>optTerminationCheck</a> is <a>False</a>.
terminationProblems :: Warnings -> [TerminationError]

-- | Meta-variable problems are reported as type errors unless
--   <a>optAllowUnsolved</a> is <a>True</a>.
unsolvedMetaVariables :: Warnings -> [Range]

-- | Same as <a>unsolvedMetaVariables</a>.
unsolvedConstraints :: Warnings -> Constraints

-- | Turns warnings into an error. Even if several errors are possible only
--   one is raised.
warningsToError :: Warnings -> TypeError

-- | Type checks the given module (if necessary).
typeCheck :: AbsolutePath -> TCM (Interface, Maybe Warnings)

-- | Tries to return the interface associated to the given module. The time
--   stamp of the relevant interface file is also returned. May type check
--   the module. An error is raised if a warning is encountered.
getInterface :: ModuleName -> TCM (Interface, ClockTime)

-- | A more precise variant of <a>getInterface</a>. If warnings are
--   encountered then they are returned instead of being turned into
--   errors.
getInterface' :: TopLevelModuleName -> Bool -> TCM (Interface, Either Warnings ClockTime)
readInterface :: FilePath -> TCM (Maybe Interface)

-- | Writes the given interface to the given file. Returns the file's new
--   modification time stamp, or <a>Nothing</a> if the write failed.
writeInterface :: FilePath -> Interface -> TCM ClockTime

-- | Tries to type check a module and write out its interface. The function
--   only writes out an interface file if it does not encounter any
--   warnings.
--   
--   If appropriate this function writes out syntax highlighting
--   information.
createInterface :: AbsolutePath -> TopLevelModuleName -> TCM (Interface, Either Warnings ClockTime)

-- | Builds an interface for the current module, which should already have
--   been successfully type checked.
buildInterface :: TopLevelInfo -> HighlightingInfo -> Set String -> [OptionsPragma] -> TCM Interface

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

module Agda.Compiler.MAlonzo.Misc
setInterface :: Interface -> TCM ()
curIF :: TCM Interface
curSig :: TCM Signature
curMName :: TCM ModuleName
curHsMod :: TCM ModuleName
curDefs :: TCM Definitions
sigMName :: Signature -> ModuleName
ihname :: String -> Nat -> Name
unqhname :: String -> QName -> Name
tlmodOf :: ModuleName -> TCM ModuleName
tlmname :: ModuleName -> TCM ModuleName
xqual :: QName -> Name -> TCM QName
xhqn :: String -> QName -> TCM QName
conhqn :: QName -> TCM QName
bltQual :: String -> String -> TCM QName
dsubname :: (Eq a, Num a, Show a) => QName -> a -> Name
hsVarUQ :: Name -> Exp
mazstr :: [Char]
mazName :: Name
mazMod' :: [Char] -> ModuleName
mazMod :: ModuleName -> ModuleName
mazerror :: [Char] -> t
mazCoerce :: Exp
mazIncompleteMatch :: Exp
rtmIncompleteMatch :: QName -> Exp
mazRTE :: ModuleName
rtmMod :: ModuleName
rtmQual :: String -> QName
rtmVar :: String -> Exp
rtmError :: [Char] -> Exp
unsafeCoerceMod :: ModuleName
fakeD :: Name -> String -> Decl
fakeDS :: String -> String -> Decl
fakeDQ :: QName -> String -> Decl
fakeType :: String -> Type
fakeExp :: String -> Exp
dummy :: a
gshow' :: Data a => a -> String

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

-- | All the properties.
tests :: IO Bool
instance Show M
instance Arbitrary M


-- | Responsible for running all internal tests.
module Agda.Tests
testSuite :: IO Bool

module Agda.Compiler.MAlonzo.Pretty

-- | Inserts disambiguating parentheses and encodes module names just
--   before pretty-printing.
prettyPrint :: (Pretty a, Data a) => a -> String

module Agda.Compiler.MAlonzo.Primitives

-- | Check that the main function has type IO a, for some a.
checkTypeOfMain :: QName -> Type -> TCM ()
importsForPrim :: TCM [ModuleName]
declsForPrim :: TCM [Decl]
mazNatToInteger :: [Char]
mazIntegerToNat :: [Char]
mazNatToInt :: [Char]
mazIntToNat :: [Char]
mazCharToInteger :: [Char]
mazListToHList :: [Char]
mazHListToList :: [Char]
mazListToString :: [Char]
mazStringToList :: [Char]
mazBoolToHBool :: [Char]
mazHBoolToBool :: [Char]
xForPrim :: [(String, TCM [a])] -> TCM [a]
primBody :: String -> TCM Exp
repl :: [[Char]] -> [Char] -> [Char]
pconName :: String -> TCM String
hasCompiledData :: [String] -> TCM Bool
bltQual' :: String -> String -> TCMT IO String

module Agda.Compiler.MAlonzo.Compiler
compilerMain :: 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 :: forall a. () -&gt; forall b. () -&gt; b -&gt; b
--      flat _ _ x = x
--   </pre>
definition :: Maybe CoinductionKit -> Definition -> TCM [Decl]
checkConstructorType :: QName -> TCM [Decl]
checkCover :: QName -> HaskellType -> Nat -> [QName] -> TCM [Decl]

-- | Move somewhere else!
conArityAndPars :: QName -> TCM (Nat, Nat)
clause :: QName -> (Nat, Bool, Clause) -> TCM Decl
argpatts :: [Arg Pattern] -> [Pat] -> TCM [Pat]
clausebody :: ClauseBody -> TCM Exp

-- | Extract Agda term to Haskell expression. Irrelevant arguments are
--   extracted as <tt>()</tt>. Types are extracted as <tt>()</tt>.
--   <tt>DontCare</tt> outside of irrelevant arguments is extracted as
--   <tt>error</tt>.
term :: Term -> ReaderT Nat TCM Exp

-- | Irrelevant arguments are replaced by Haskells' ().
term' :: Arg Term -> ReaderT Nat TCM Exp
literal :: Literal -> TCM Exp
hslit :: Literal -> Literal
litqname :: QName -> TCM Exp
condecl :: QName -> TCM (Nat, ConDecl)
cdecl :: QName -> Nat -> ConDecl
tvaldecl :: QName -> Induction -> Nat -> Nat -> [ConDecl] -> Maybe Clause -> [Decl]
infodecl :: QName -> Decl
hsCast :: Exp -> Exp
hsCast' :: Exp -> Exp
hsCoerce :: Exp -> Exp
writeModule :: Module -> TCM ()
rteModule :: Module
compileDir :: TCM FilePath
outFile' :: (Data a, Pretty a) => a -> TCMT IO (FilePath, FilePath)
outFile :: ModuleName -> TCM FilePath
outFile_ :: TCM FilePath
callGHC :: Interface -> TCM ()


-- | Epic compiler backend.
module Agda.Compiler.Epic.Compiler

-- | Compile an interface into an executable using Epic
compilerMain :: Interface -> TCM ()

module Agda.Compiler.JS.Compiler
compilerMain :: Interface -> TCM ()
compile :: Interface -> TCM ()
prefix :: [Char]
jsMod :: ModuleName -> GlobalId
jsFileName :: GlobalId -> String
jsMember :: Name -> MemberId
global' :: QName -> TCM (Exp, [MemberId])
global :: QName -> TCM (Exp, [MemberId])
reorder :: [Export] -> [Export]
reorder' :: Set [MemberId] -> [Export] -> [Export]
insertAfter :: Set [MemberId] -> Export -> [Export] -> [Export]
curModule :: TCM Module
definition :: (QName, Definition) -> TCM Export
defn :: QName -> [MemberId] -> Type -> Maybe JSCode -> Defn -> TCM Exp
numPars :: [Clause] -> Nat
clause :: Clause -> TCM Case
mapping :: [Pattern] -> (Nat, Nat, [Exp])
mapping' :: Pattern -> (Nat, Nat, [Exp]) -> (Nat, Nat, [Exp])
pattern :: Pattern -> TCM Patt
tag :: QName -> TCM Tag
visitorName :: QName -> TCM MemberId
body :: ClauseBody -> TCM Exp
term :: Term -> TCM Exp
isSingleton :: Type -> TCM (Maybe Exp)
defProjection :: Definition -> Maybe (QName, Int)
args :: Maybe (QName, Int) -> Args -> TCM [Exp]
qname :: QName -> TCM Exp
literal :: Literal -> Exp
dummyLambda :: Int -> Exp -> Exp
writeModule :: Module -> TCM ()
compileDir :: TCM FilePath
outFile :: GlobalId -> TCM FilePath
outFile_ :: TCM FilePath

module Agda.Interaction.BasicOps

-- | Parses an expression.
parseExpr :: Range -> String -> TCM Expr
parseExprIn :: InteractionId -> Range -> String -> TCM Expr
giveExpr :: MetaId -> Expr -> TCM Expr
give :: InteractionId -> Maybe Range -> Expr -> TCM (Expr, [InteractionId])
addDecl :: Declaration -> TCM ([InteractionId])
refine :: InteractionId -> Maybe Range -> Expr -> TCM (Expr, [InteractionId])

-- | 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
Normalised :: Rewrite
rewrite :: (Normalise a, Reduce a) => Rewrite -> a -> TCMT IO a
data OutputForm a b
OutputForm :: 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
IsEmptyType :: a -> OutputConstraint a b
FindInScopeOF :: b -> 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
showComparison :: Comparison -> String
judgToOutputForm :: Judgement a c -> OutputConstraint a c
getConstraints :: TCM [OutputForm Expr Expr]
getSolvedInteractionPoints :: TCM [(InteractionId, MetaId, Expr)]
typeOfMetaMI :: Rewrite -> MetaId -> TCM (OutputConstraint Expr MetaId)
typeOfMeta :: Rewrite -> InteractionId -> TCM (OutputConstraint Expr InteractionId)
typesOfVisibleMetas :: Rewrite -> TCM [OutputConstraint Expr InteractionId]
typesOfHiddenMetas :: Rewrite -> TCM [OutputConstraint Expr MetaId]
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 :: InteractionId -> TCM [String]

-- | Runs the given computation as if in an anonymous goal at the end of
--   the top-level module.
atTopLevel :: TCM a -> TCM a

-- | Returns the contents of the given module.
moduleContents :: Range -> String -> TCM ([Name], [(Name, Type)])
instance Functor (OutputConstraint a)
instance Functor (OutputForm a)
instance ToConcrete MetaId Expr
instance ToConcrete InteractionId Expr
instance (ToConcrete a c, ToConcrete b d) => ToConcrete (OutputConstraint' a b) (OutputConstraint' c d)
instance (Pretty a, Pretty b) => Pretty (OutputConstraint' a b)
instance (ToConcrete a c, ToConcrete b d) => ToConcrete (OutputConstraint a b) (OutputConstraint c d)
instance (ToConcrete a c, ToConcrete b d) => ToConcrete (OutputForm a b) (OutputForm c d)
instance (Show a, Show b) => Show (OutputConstraint a b)
instance (Show a, Show b) => Show (OutputForm a b)
instance Reify Constraint (OutputConstraint Expr Expr)
instance Reify ProblemConstraint (Closure (OutputForm Expr Expr))

module Agda.Interaction.CommandLine.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)
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 ()

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 :: (Map k a, [a1])
popMapS :: MonadState s m => (s -> (t, [a])) -> ((t, [a]) -> s -> s) -> m (Maybe a)
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 -> TCMT IO Nat
getMeta :: MetaId -> TOM (Metavar (Exp O) (RefInfo O))
getEqs :: TCM [(Bool, Term, Term)]
tomyClauses :: [Clause] -> StateT S TCM [([Pat O], MExp O)]
tomyClause :: Clause -> StateT S TCM (Maybe ([Pat O], MExp O))
tomyPat :: Arg Pattern -> StateT S TCM (Pat O)
tomyBody :: Num t => ClauseBody -> StateT S (TCMT IO) (Maybe (MExp O, t))
weaken :: Int -> MExp O -> MExp O
weakens :: Int -> MArgList O -> MArgList O
tomyType :: Type -> TOM (MExp O)
tomyExp :: Term -> TOM (MExp O)
tomyExps :: [Arg Term] -> StateT S TCM (MM (ArgList O) (RefInfo O))
tomyIneq :: Comparison -> Bool
fmType :: MetaId -> Type -> Bool
fmExp :: MetaId -> Term -> Bool
fmExps :: MetaId -> [Arg Term] -> Bool
fmLevel :: MetaId -> PlusLevel -> Bool
cnvh :: Hiding -> FMode
icnvh :: FMode -> Hiding
frommy :: MExp O -> ErrorT String IO Term
frommyType :: MExp O -> ErrorT String IO Type
frommyExp :: MExp O -> ErrorT String IO Term
frommyExps :: Nat -> MArgList O -> Term -> ErrorT String IO Term
abslamvarname :: [Char]
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)) -> ErrorT String IO Clause
contains_constructor :: [CSPat O] -> Bool
etaContractBody :: ClauseBody -> TCM ClauseBody
freeIn :: Nat -> MExp o -> Bool
negtype :: ConstRef o -> MExp o -> MExp o
findClauseDeep :: MetaId -> TCM (Maybe (QName, Clause, Bool))
matchType :: Integer -> Integer -> Type -> Type -> Maybe (Nat, Nat)
instance Eq TMode

module Agda.Interaction.MakeCase
data CaseContext
FunctionDef :: CaseContext
ExtendedLambda :: Int -> Int -> CaseContext

-- | Find the clause whose right hand side is the given meta BY SEARCHING
--   THE WHOLE SIGNATURE. Returns the original clause, before record
--   patterns have been translated away. Raises an error if there is no
--   matching clause.
--   
--   Andreas, 2010-09-21: This looks like a SUPER UGLY HACK to me. You are
--   walking through the WHOLE signature to find an information you have
--   thrown away earlier. (shutter with disgust). This code fails for
--   record rhs because they have been eta-expanded, so the MVar is gone.
findClause :: MetaId -> TCM (CaseContext, QName, Clause)
makeCase :: InteractionId -> Range -> String -> TCM (CaseContext, [Clause])
makeAbsurdClause :: QName -> SplitClause -> TCM Clause
makeAbstractClause :: QName -> SplitClause -> TCM Clause
deBruijnIndex :: Expr -> TCM Nat
instance Eq CaseContext

module Agda.Auto.Auto
auto :: InteractionId -> Range -> String -> TCM (Either [(InteractionId, String)] (Either [String] String), Maybe String)

module Agda.Interaction.GhciTop
data State
State :: TCState -> [InteractionId] -> Maybe (AbsolutePath, ClockTime) -> State
theTCState :: State -> TCState

-- | The interaction points of the buffer, in the order in which they
--   appear in the buffer. The interaction points are recorded in
--   <a>theTCState</a>, 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 :: State -> [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 :: State -> Maybe (AbsolutePath, ClockTime)
initState :: State
theState :: IORef State

-- | Can the command run even if the relevant file has not been loaded into
--   the state?
data Independence

-- | Yes. If the argument is <tt><a>Just</a> is</tt>, then <tt>is</tt> is
--   used as the command's include directories.
Independent :: (Maybe [FilePath]) -> Independence
Dependent :: Independence

-- | An interactive computation.
--   
--   Is the command independent?
data Interaction
Interaction :: Independence -> TCM (Maybe ModuleName) -> Interaction

-- | Is the command independent?
independence :: Interaction -> Independence

-- | If a module name is returned, then syntax highlighting information
--   will be written for the given module (by <a>ioTCM</a>).
command :: Interaction -> TCM (Maybe ModuleName)
isIndependent :: Interaction -> Bool

-- | Run a TCM computation in the current state. Should only be used for
--   debugging.
ioTCM_ :: TCM a -> IO a

-- | Runs a <a>TCM</a> computation. All calls from the Emacs mode should be
--   wrapped in this function.
ioTCM :: FilePath -> Maybe FilePath -> Interaction -> IO ()

-- | <tt>cmd_load m includes</tt> loads the module in file <tt>m</tt>,
--   using <tt>includes</tt> as the include directories.
cmd_load :: FilePath -> [FilePath] -> Interaction

-- | <tt>cmd_load' m includes cmd cmd2</tt> loads the module in file
--   <tt>m</tt>, using <tt>includes</tt> as the include directories.
--   
--   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>typeCheck</a>.
cmd_load' :: FilePath -> [FilePath] -> Bool -> ((Interface, Maybe Warnings) -> TCM ()) -> Interaction

-- | Available backends.
data Backend
MAlonzo :: Backend
Epic :: Backend
JS :: Backend

-- | <tt>cmd_compile b m includes</tt> compiles the module in file
--   <tt>m</tt> using the backend <tt>b</tt>, using <tt>includes</tt> as
--   the include directories.
cmd_compile :: Backend -> FilePath -> [FilePath] -> Interaction
cmd_constraints :: Interaction
cmd_metas :: Interaction

-- | If the range is <a>noRange</a>, then the string comes from the
--   minibuffer rather than the goal.
type GoalCommand = InteractionId -> Range -> String -> Interaction
cmd_give :: GoalCommand
cmd_refine :: GoalCommand
give_gen :: ToConcrete a2 a1 => (InteractionId -> Maybe a -> Expr -> TCMT IO (a2, [InteractionId])) -> (Range -> String -> a1 -> String) -> InteractionId -> Range -> String -> Interaction
give_gen' :: ToConcrete a2 a1 => (InteractionId -> Maybe a -> Expr -> TCMT IO (a2, [InteractionId])) -> (Range -> String -> a1 -> String) -> InteractionId -> Range -> String -> TCMT IO (Maybe a3)
cmd_intro :: GoalCommand
cmd_refine_or_intro :: GoalCommand
cmd_auto :: GoalCommand

-- | 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
cmd_context :: Rewrite -> GoalCommand
cmd_infer :: Rewrite -> GoalCommand
cmd_goal_type :: Rewrite -> GoalCommand

-- | Displays the current goal, the given document, and the current
--   context.
cmd_goal_type_context_and :: Doc -> Rewrite -> InteractionId -> t -> t1 -> TCMT IO (Maybe a)

-- | Displays the current goal and context.
cmd_goal_type_context :: Rewrite -> GoalCommand

-- | Displays the current goal and context <i>and</i> infers the type of an
--   expression.
cmd_goal_type_context_infer :: Rewrite -> GoalCommand

-- | Shows all the top-level names in the given module, along with their
--   types.
showModuleContents :: Range -> String -> TCM ()

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

-- | Shows all the top-level names in the given module, along with their
--   types. Uses the top-level scope.
cmd_show_module_contents_toplevel :: String -> Interaction

-- | Sets the command line options and updates the status information.
setCommandLineOptions :: CommandLineOptions -> TCM ()

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

-- | Computes some status information.
status :: TCM Status

-- | Shows status information.
showStatus :: Status -> String

-- | Displays/updates status information.
displayStatus :: Status -> IO ()

-- | <tt>display_info' header content</tt> displays <tt>content</tt> (with
--   header <tt>header</tt>) in some suitable way.
display_info' :: String -> String -> IO ()

-- | <tt>display_info</tt> does what <a>display_info'</a> does, but
--   additionally displays some status information (see <a>status</a> and
--   <a>displayStatus</a>).
display_info :: String -> String -> TCM ()

-- | Like <a>display_info</a>, but takes a <a>Doc</a> instead of a
--   <a>String</a>.
display_infoD :: String -> Doc -> TCM ()
showNumIId :: InteractionId -> Lisp [Char]
takenNameStr :: TCM [String]
refreshStr :: [String] -> String -> ([String], String)
nameModifiers :: [[Char]]
cmd_make_case :: GoalCommand
cmd_solveAll :: Interaction
class LowerMeta a
lowerMeta :: LowerMeta a => a -> a
preMeta :: Expr
preUscore :: Expr
cmd_compute :: Bool -> GoalCommand

-- | 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 Expr) -> String -> String -> Interaction

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

-- | 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 :: Bool -> String -> Interaction

-- | <tt>cmd_write_highlighting_info source target</tt> writes syntax
--   highlighting information for the module in <tt>source</tt> into
--   <tt>target</tt>.
--   
--   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 the representation of "no
--   highlighting information available" is instead written to
--   <tt>target</tt>.
--   
--   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_write_highlighting_info :: FilePath -> FilePath -> Interaction

-- | Tells the Emacs mode to go to the first error position (if any).
tellEmacsToJumpToError :: Range -> IO ()

-- | Tells Agda whether or not to show implicit arguments.
showImplicitArgs :: Bool -> Interaction

-- | Toggle display of implicit arguments.
toggleImplicitArgs :: Interaction

-- | When an error message is displayed the following title should be used,
--   if appropriate.
errorTitle :: String

-- | Displays an error, instructs Emacs to jump to the site of the error,
--   and terminates the program. Because this function may switch the focus
--   to another file the status information is also updated.
displayErrorAndExit :: Status -> Range -> String -> IO a

-- | Outermost error handler.
infoOnException :: IO a -> IO a

-- | Raises an error if the given file is not the one currently loaded.
ensureFileLoaded :: AbsolutePath -> TCM ()
getCurrentFile :: IO FilePath

-- | Changes the <a>Interaction</a> so that its first action is to turn off
--   all debug messages.
makeSilent :: Interaction -> Interaction
top_command' :: FilePath -> Interaction -> IO ()
goal_command :: InteractionId -> GoalCommand -> String -> IO ()

-- | Constructs <a>AbsolutePath</a>s.
--   
--   Precondition: The path must be absolute and valid.
mkAbsolute :: FilePath -> AbsolutePath
instance LowerMeta a => LowerMeta (Named name a)
instance LowerMeta a => LowerMeta (Arg a)
instance LowerMeta a => LowerMeta [a]
instance LowerMeta WhereClause
instance LowerMeta ModuleApplication
instance LowerMeta Declaration
instance LowerMeta (Maybe Expr)
instance LowerMeta RHS
instance LowerMeta TypedBinding
instance LowerMeta TypedBindings
instance LowerMeta LamBinding
instance LowerMeta (OpApp Expr)
instance LowerMeta Expr


-- | Agda main module.
module Agda.Main

-- | The main function
runAgda :: TCM ()

-- | Print usage information.
printUsage :: IO ()

-- | Print version information.
printVersion :: IO ()

-- | What to do for bad options.
optionError :: String -> IO ()

-- | Main
main :: IO ()
