Agda-2.6.3.20230805: A dependently typed functional programming language and proof assistant
Safe HaskellSafe-Inferred
LanguageHaskell2010

Agda.TypeChecking.Names

Description

EDSL to construct terms without touching De Bruijn indices.

e.g. given t, u :: Term, Γ ⊢ t, u : A, we can build "λ f. f t u" like this:

runNames [] $ do -- open binds t and u to computations that know how to weaken themselves in -- an extended context

t,u
<- mapM open [t,u]
  • - lam gives the illusion of HOAS by providing f as a computation.
  • - It also extends the internal context with the name "f", so that
  • - t and u will get weakened in the body.
  • - We apply f with the (@) combinator from Agda.TypeChecking.Primitive.

lam "f" $ f -> f @ t @ u

Synopsis

Documentation

newtype NamesT m a Source #

Constructors

NamesT 

Fields

Instances

Instances details
MonadTrans NamesT Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

lift :: Monad m => m a -> NamesT m a #

MonadError e m => MonadError e (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

throwError :: e -> NamesT m a #

catchError :: NamesT m a -> (e -> NamesT m a) -> NamesT m a #

MonadState s m => MonadState s (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

get :: NamesT m s #

put :: s -> NamesT m () #

state :: (s -> (a, s)) -> NamesT m a #

HasOptions m => HasOptions (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

MonadReduce m => MonadReduce (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

liftReduce :: ReduceM a -> NamesT m a Source #

MonadTCEnv m => MonadTCEnv (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

askTC :: NamesT m TCEnv Source #

localTC :: (TCEnv -> TCEnv) -> NamesT m a -> NamesT m a Source #

MonadTCM m => MonadTCM (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

liftTCM :: TCM a -> NamesT m a Source #

MonadTCState m => MonadTCState (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

ReadTCState m => ReadTCState (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

getTCState :: NamesT m TCState Source #

locallyTCState :: Lens' TCState a -> (a -> a) -> NamesT m b -> NamesT m b Source #

withTCState :: (TCState -> TCState) -> NamesT m a -> NamesT m a Source #

HasBuiltins m => HasBuiltins (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

MonadAddContext m => MonadAddContext (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

addCtx :: Name -> Dom Type -> NamesT m a -> NamesT m a Source #

addLetBinding' :: Origin -> Name -> Term -> Dom Type -> NamesT m a -> NamesT m a Source #

updateContext :: Substitution -> (Context -> Context) -> NamesT m a -> NamesT m a Source #

withFreshName :: Range -> ArgName -> (Name -> NamesT m a) -> NamesT m a Source #

MonadDebug m => MonadDebug (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

(HasBuiltins m, HasConstInfo m, MonadAddContext m, MonadReduce m) => PureTCM (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

HasConstInfo m => HasConstInfo (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

MonadFail m => MonadFail (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

fail :: String -> NamesT m a #

MonadIO m => MonadIO (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

liftIO :: IO a -> NamesT m a #

Applicative m => Applicative (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

pure :: a -> NamesT m a #

(<*>) :: NamesT m (a -> b) -> NamesT m a -> NamesT m b #

liftA2 :: (a -> b -> c) -> NamesT m a -> NamesT m b -> NamesT m c #

(*>) :: NamesT m a -> NamesT m b -> NamesT m b #

(<*) :: NamesT m a -> NamesT m b -> NamesT m a #

Functor m => Functor (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

fmap :: (a -> b) -> NamesT m a -> NamesT m b #

(<$) :: a -> NamesT m b -> NamesT m a #

Monad m => Monad (NamesT m) Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

(>>=) :: NamesT m a -> (a -> NamesT m b) -> NamesT m b #

(>>) :: NamesT m a -> NamesT m b -> NamesT m b #

return :: a -> NamesT m a #

type Names = [String] Source #

A list of variable names from a context.

runNamesT :: Names -> NamesT m a -> m a Source #

cxtSubst :: MonadFail m => Names -> NamesT m (Substitution' a) Source #

cxtSubst Γ returns the substitution needed to go from Γ to the current context.

Fails if Γ is not a subcontext of the current one.

inCxt :: (MonadFail m, Subst a) => Names -> a -> NamesT m a Source #

inCxt Γ t takes a t in context Γ and produce an action that will return t weakened to the current context.

Fails whenever cxtSubst Γ would.

cl' :: Applicative m => a -> NamesT m a Source #

Closed terms

cl :: Monad m => m a -> NamesT m a Source #

open :: (MonadFail m, Subst a) => a -> NamesT m (NamesT m a) Source #

Open terms in the current context.

type Var m = forall b. (Subst b, DeBruijn b) => NamesT m b Source #

Monadic actions standing for variables.

b is quantified over so the same variable can be used e.g. both as a pattern and as an expression.

bind :: MonadFail m => ArgName -> ((forall b. (Subst b, DeBruijn b) => NamesT m b) -> NamesT m a) -> NamesT m (Abs a) Source #

bind n f provides f with a fresh variable, which can be used in any extended context.

Returns an Abs which binds the extra variable.

bind' :: MonadFail m => ArgName -> ((forall b. (Subst b, DeBruijn b) => NamesT m b) -> NamesT m a) -> NamesT m a Source #

Like bind but returns a bare term.

Helpers to build lambda abstractions.

Combinators for n-ary binders.

data AbsN a Source #

Constructors

AbsN 

Fields

Instances

Instances details
Foldable AbsN Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

fold :: Monoid m => AbsN m -> m #

foldMap :: Monoid m => (a -> m) -> AbsN a -> m #

foldMap' :: Monoid m => (a -> m) -> AbsN a -> m #

foldr :: (a -> b -> b) -> b -> AbsN a -> b #

foldr' :: (a -> b -> b) -> b -> AbsN a -> b #

foldl :: (b -> a -> b) -> b -> AbsN a -> b #

foldl' :: (b -> a -> b) -> b -> AbsN a -> b #

foldr1 :: (a -> a -> a) -> AbsN a -> a #

foldl1 :: (a -> a -> a) -> AbsN a -> a #

toList :: AbsN a -> [a] #

null :: AbsN a -> Bool #

length :: AbsN a -> Int #

elem :: Eq a => a -> AbsN a -> Bool #

maximum :: Ord a => AbsN a -> a #

minimum :: Ord a => AbsN a -> a #

sum :: Num a => AbsN a -> a #

product :: Num a => AbsN a -> a #

Traversable AbsN Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

traverse :: Applicative f => (a -> f b) -> AbsN a -> f (AbsN b) #

sequenceA :: Applicative f => AbsN (f a) -> f (AbsN a) #

mapM :: Monad m => (a -> m b) -> AbsN a -> m (AbsN b) #

sequence :: Monad m => AbsN (m a) -> m (AbsN a) #

Functor AbsN Source # 
Instance details

Defined in Agda.TypeChecking.Names

Methods

fmap :: (a -> b) -> AbsN a -> AbsN b #

(<$) :: a -> AbsN b -> AbsN a #

Subst a => Subst (AbsN a) Source # 
Instance details

Defined in Agda.TypeChecking.Names

Associated Types

type SubstArg (AbsN a) Source #

type SubstArg (AbsN a) Source # 
Instance details

Defined in Agda.TypeChecking.Names

type SubstArg (AbsN a) = SubstArg a

toAbsN :: Abs (AbsN a) -> AbsN a Source #

Will crash on NoAbs

absAppN :: Subst a => AbsN a -> [SubstArg a] -> a Source #

type ArgVars m = forall b. (Subst b, DeBruijn b) => [NamesT m (Arg b)] Source #

type Vars m = forall b. (Subst b, DeBruijn b) => [NamesT m b] Source #

bindN :: MonadFail m => [ArgName] -> (Vars m -> NamesT m a) -> NamesT m (AbsN a) Source #

bindNArg :: MonadFail m => [Arg ArgName] -> (ArgVars m -> NamesT m a) -> NamesT m (AbsN a) Source #

type Vars1 m = forall b. (Subst b, DeBruijn b) => List1 (NamesT m b) Source #

bindN1 :: MonadFail m => List1 ArgName -> (Vars1 m -> NamesT m a) -> NamesT m (AbsN a) Source #

applyN :: (Monad m, Subst a) => NamesT m (AbsN a) -> [NamesT m (SubstArg a)] -> NamesT m a Source #

applyN' :: (Monad m, Subst a) => NamesT m (AbsN a) -> NamesT m [SubstArg a] -> NamesT m a Source #

abstractN :: (MonadFail m, Abstract a) => NamesT m Telescope -> (Vars m -> NamesT m a) -> NamesT m a Source #

abstractT :: (MonadFail m, Abstract a) => String -> NamesT m Type -> (Var m -> NamesT m a) -> NamesT m a Source #

lamTel :: Monad m => NamesT m (Abs [Term]) -> NamesT m [Term] Source #

appTel :: Monad m => NamesT m [Term] -> NamesT m Term -> NamesT m [Term] Source #