Safe Haskell | None |
---|
TT is the core language of Idris. The language has:
- Full dependent types
- A hierarchy of universes, with cumulativity: Type : Type1, Type1 : Type2, ...
- Pattern matching letrec binding
- (primitive types defined externally)
Some technical stuff:
- Typechecker is kept as simple as possible - no unification, just a checker for incomplete terms.
- We have a simple collection of tactics which we use to elaborate source programs with implicit syntax into fully explicit terms.
- data Option
- data FC = FC {}
- newtype FC' = FC' {}
- emptyFC :: FC
- fileFC :: String -> FC
- data Err
- = Msg String
- | InternalMsg String
- | CantUnify Bool Term Term Err [(Name, Type)] Int
- | InfiniteUnify Name Term [(Name, Type)]
- | CantConvert Term Term [(Name, Type)]
- | UnifyScope Name Name Term [(Name, Type)]
- | CantInferType String
- | NonFunctionType Term Term
- | CantIntroduce Term
- | NoSuchVariable Name
- | NoTypeDecl Name
- | NotInjective Term Term Term
- | CantResolve Term
- | CantResolveAlts [String]
- | IncompleteTerm Term
- | UniverseError
- | ProgramLineComment
- | Inaccessible Name
- | NonCollapsiblePostulate Name
- | AlreadyDefined Name
- | ProofSearchFail Err
- | NoRewriting Term
- | At FC Err
- | Elaborating String Name Err
- | ProviderError String
- | LoadingFailed String Err
- score :: Err -> Int
- data TC a
- tfail :: Err -> TC a
- trun :: FC -> TC a -> TC a
- discard :: Monad m => m a -> m ()
- showSep :: String -> [String] -> String
- pmap :: (t -> t1) -> (t, t) -> (t1, t1)
- traceWhen :: Bool -> String -> a -> a
- data Name
- data SpecialName
- showCG :: Name -> String
- type Ctxt a = Map Name (Map Name a)
- emptyContext :: Map k a
- tcname :: Name -> Bool
- implicitable :: Name -> Bool
- nsroot :: Name -> Name
- addDef :: Name -> a -> Ctxt a -> Ctxt a
- lookupCtxtName :: Name -> Ctxt a -> [(Name, a)]
- lookupCtxt :: Name -> Ctxt a -> [a]
- lookupCtxtExact :: Name -> Ctxt a -> [a]
- updateDef :: Name -> (a -> a) -> Ctxt a -> Ctxt a
- toAlist :: Ctxt a -> [(Name, a)]
- addAlist :: Show a => [(Name, a)] -> Ctxt a -> Ctxt a
- data NativeTy
- data IntTy
- data ArithTy
- nativeTyWidth :: NativeTy -> Int
- intTyWidth :: IntTy -> Int
- data Const
- data Raw
- data Binder b
- fmapMB :: Monad m => (a -> m b) -> Binder a -> m (Binder b)
- raw_apply :: Raw -> [Raw] -> Raw
- raw_unapply :: Raw -> (Raw, [Raw])
- data RawFun = RawFun {}
- data RawDatatype = RDatatype Name Raw [(Name, Raw)]
- data RDef
- type RProgram = [(Name, RDef)]
- data UExp
- data UConstraint
- type UCs = (Int, [UConstraint])
- data NameType
- data TT n
- class TermSize a where
- type EnvTT n = [(n, Binder (TT n))]
- data Datatype n = Data {}
- isInjective :: TT n -> Bool
- vinstances :: Int -> TT n -> Int
- instantiate :: TT n -> TT n -> TT n
- substV :: TT n -> TT n -> TT n
- explicitNames :: TT n -> TT n
- pToV :: Eq n => n -> TT n -> TT n
- pToV' :: Eq n => n -> Int -> TT n -> TT n
- addBinder :: TT n -> TT n
- pToVs :: Eq n => [n] -> TT n -> TT n
- vToP :: TT n -> TT n
- finalise :: Eq n => TT n -> TT n
- subst :: Eq n => n -> TT n -> TT n -> TT n
- substNames :: Eq n => [(n, TT n)] -> TT n -> TT n
- substTerm :: Eq n => TT n -> TT n -> TT n -> TT n
- noOccurrence :: Eq n => n -> TT n -> Bool
- freeNames :: Eq n => TT n -> [n]
- arity :: TT n -> Int
- unApply :: TT n -> (TT n, [TT n])
- mkApp :: TT n -> [TT n] -> TT n
- forget :: TT Name -> Raw
- bindAll :: [(n, Binder (TT n))] -> TT n -> TT n
- bindTyArgs :: (TT n -> Binder (TT n)) -> [(n, TT n)] -> TT n -> TT n
- getArgTys :: TT n -> [(n, TT n)]
- getRetTy :: TT n -> TT n
- uniqueName :: Name -> [Name] -> Name
- uniqueBinders :: [Name] -> TT Name -> TT Name
- nextName :: Name -> Name
- type Term = TT Name
- type Type = Term
- type Env = EnvTT Name
- newtype WkEnvTT n = Wk (EnvTT n)
- type WkEnv = WkEnvTT Name
- itBitsName :: NativeTy -> [Char]
- showEnv :: (Eq a, Show a) => [(a, Binder (TT a))] -> TT a -> [Char]
- showEnvDbg :: (Eq a, Show a) => [(a, Binder (TT a))] -> TT a -> [Char]
- prettyEnv :: (Eq a, Show a, Pretty a) => [(a, Binder (TT a))] -> TT a -> Doc
- showEnv' :: (Eq a, Show a) => [(a, Binder (TT a))] -> TT a -> Bool -> [Char]
- pureTerm :: TT Name -> Bool
- weakenTm :: Int -> TT n -> TT n
- weakenEnv :: EnvTT n -> EnvTT n
- weakenTmEnv :: Int -> EnvTT n -> EnvTT n
- orderPats :: Term -> Term
Documentation
Source location. These are typically produced by the parser getFC
Names are hierarchies of strings, describing scope (so no danger of duplicate names, but need to be careful on lookup).
data SpecialName Source
type Ctxt a = Map Name (Map Name a)Source
Contexts allow us to map names to things. A root name maps to a collection of things in different namespaces with that name.
emptyContext :: Map k aSource
implicitable :: Name -> BoolSource
lookupCtxtName :: Name -> Ctxt a -> [(Name, a)]Source
Look up a name in the context, given an optional namespace. The name (n) may itself have a (partial) namespace given.
Rules for resolution:
- if an explicit namespace is given, return the names which match it. If none match, return all names.
- if the name has has explicit namespace given, return the names which match it and ignore the given namespace.
- otherwise, return all names.
lookupCtxt :: Name -> Ctxt a -> [a]Source
lookupCtxtExact :: Name -> Ctxt a -> [a]Source
nativeTyWidth :: NativeTy -> IntSource
intTyWidth :: IntTy -> IntSource
Deprecated: Non-total function, use nativeTyWidth and appropriate casing
All binding forms are represented in a unform fashion.
raw_unapply :: Raw -> (Raw, [Raw])Source
Universe expressions for universe checking
data UConstraint Source
Universe constraints
type UCs = (Int, [UConstraint])Source
Terms in the core language
P NameType n (TT n) | named references |
V Int | a resolved de Bruijn-indexed variable |
Bind n (Binder (TT n)) (TT n) | a binding |
App (TT n) (TT n) | function, function type, arg |
Constant Const | constant |
Proj (TT n) Int | argument projection; runtime only (-1) is a special case for 'subtract one from BI' |
Erased | an erased term |
Impossible | special case for totality checking |
TType UExp | the type of types at some level |
Functor TT | |
Binary CaseAlt | |
Binary SC | |
TermSize CaseAlt | |
TermSize SC | |
Transform CaseAlt | |
Transform SC | |
ToIR SC | |
Eq n => Eq (TT n) | |
Ord n => Ord (TT n) | |
(Eq n, Show n) => Show (TT n) | |
Binary (TT Name) | |
NFData n => NFData (TT n) | |
Pretty a => Pretty (TT a) | |
Sized a => Sized (TT a) | |
TermSize (TT Name) | |
Optimisable (TT Name) | |
Transform (TT Name) | |
ToIR (TT Name) | |
ToIR ([Name], SC) |
A few handy operations on well typed terms:
isInjective :: TT n -> BoolSource
A term is injective iff it is a data constructor, type constructor, constant, the type Type, pi-binding, or an application of an injective term.
vinstances :: Int -> TT n -> IntSource
Count the number of instances of a de Bruijn index in a term
instantiate :: TT n -> TT n -> TT nSource
explicitNames :: TT n -> TT nSource
noOccurrence :: Eq n => n -> TT n -> BoolSource
unApply :: TT n -> (TT n, [TT n])Source
Deconstruct an application; returns the function and a list of arguments
uniqueName :: Name -> [Name] -> NameSource
itBitsName :: NativeTy -> [Char]Source
weakenTm :: Int -> TT n -> TT nSource
Weaken a term by adding i to each de Bruijn index (i.e. lift it over i bindings)
weakenEnv :: EnvTT n -> EnvTT nSource
Weaken an environment so that all the de Bruijn indices are correct according to the latest bound variable
weakenTmEnv :: Int -> EnvTT n -> EnvTT nSource