Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
The treeless syntax is intended to be used as input for the compiler backends. It is more low-level than Internal syntax and is not used for type checking.
Some of the features of treeless syntax are: - case expressions instead of case trees - no instantiated datatypes / constructors
Synopsis
- module Agda.Syntax.Abstract.Name
- data ArgUsage
- data TTerm
- data EvaluationStrategy
- data Compiled = Compiled {}
- type Args = [TTerm]
- class Unreachable a where
- isUnreachable :: a -> Bool
- data TPrim
- data CaseInfo = CaseInfo {
- caseLazy :: Bool
- caseErased :: Erased
- caseType :: CaseType
- data TAlt
- data TError
- = TUnreachable
- | TMeta String
- data CaseType
- pattern TPOp :: TPrim -> TTerm -> TTerm -> TTerm
- pattern TPFn :: TPrim -> TTerm -> TTerm
- filterUsed :: [ArgUsage] -> [a] -> [a]
- mkLet :: TTerm -> TTerm -> TTerm
- isPrimEq :: TPrim -> Bool
- coerceView :: TTerm -> (Bool, TTerm)
- mkTApp :: TTerm -> Args -> TTerm
- tAppView :: TTerm -> (TTerm, [TTerm])
- coerceAppView :: TTerm -> ((Bool, TTerm), [TTerm])
- tLetView :: TTerm -> ([TTerm], TTerm)
- tLamView :: TTerm -> (Int, TTerm)
- mkTLam :: Int -> TTerm -> TTerm
- tInt :: Integer -> TTerm
- intView :: TTerm -> Maybe Integer
- word64View :: TTerm -> Maybe Word64
- tPlusK :: Integer -> TTerm -> TTerm
- tOp :: TPrim -> TTerm -> TTerm -> TTerm
- tNegPlusK :: Integer -> TTerm -> TTerm
- plusKView :: TTerm -> Maybe (Integer, TTerm)
- negPlusKView :: TTerm -> Maybe (Integer, TTerm)
- tUnreachable :: TTerm
- tIfThenElse :: TTerm -> TTerm -> TTerm -> TTerm
Documentation
module Agda.Syntax.Abstract.Name
Usage status of function arguments in treeless code.
Instances
Generic ArgUsage Source # | |
Show ArgUsage Source # | |
NFData ArgUsage Source # | |
Defined in Agda.Syntax.Treeless | |
Eq ArgUsage Source # | |
Ord ArgUsage Source # | |
type Rep ArgUsage Source # | |
Defined in Agda.Syntax.Treeless type Rep ArgUsage = D1 ('MetaData "ArgUsage" "Agda.Syntax.Treeless" "Agda-2.6.3.20230930-inplace" 'False) (C1 ('MetaCons "ArgUsed" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ArgUnused" 'PrefixI 'False) (U1 :: Type -> Type)) |
Treeless Term. All local variables are using de Bruijn indices.
TVar Int | |
TPrim TPrim | |
TDef QName | |
TApp TTerm Args | |
TLam TTerm | |
TLit Literal | |
TCon QName | |
TLet TTerm TTerm | introduces a new (non-recursive) local binding. The bound term MUST only be evaluated if it is used inside the body. Sharing may happen, but is optional. It is also perfectly valid to just inline the bound term in the body. |
TCase Int CaseInfo TTerm [TAlt] | Case scrutinee (always variable), case type, default value, alternatives First, all TACon alternatives are tried; then all TAGuard alternatives in top to bottom order. TACon alternatives must not overlap. |
TUnit | |
TSort | |
TErased | |
TCoerce TTerm | Used by the GHC backend |
TError TError | A runtime error, something bad has happened. |
Instances
HasFree TTerm Source # | |
Pretty TTerm Source # | |
NamesIn TTerm Source # | |
Defined in Agda.Syntax.Internal.Names | |
Unreachable TTerm Source # | |
Defined in Agda.Syntax.Treeless isUnreachable :: TTerm -> Bool Source # | |
Subst TTerm Source # | |
Defined in Agda.Compiler.Treeless.Subst applySubst :: Substitution' (SubstArg TTerm) -> TTerm -> TTerm Source # | |
DeBruijn TTerm Source # | |
Defined in Agda.Compiler.Treeless.Subst deBruijnVar :: Int -> TTerm Source # debruijnNamedVar :: String -> Int -> TTerm Source # deBruijnView :: TTerm -> Maybe Int Source # | |
Generic TTerm Source # | |
Show TTerm Source # | |
NFData TTerm Source # | |
Defined in Agda.Syntax.Treeless | |
Eq TTerm Source # | |
Ord TTerm Source # | |
type SubstArg TTerm Source # | |
Defined in Agda.Compiler.Treeless.Subst | |
type Rep TTerm Source # | |
Defined in Agda.Syntax.Treeless type Rep TTerm = D1 ('MetaData "TTerm" "Agda.Syntax.Treeless" "Agda-2.6.3.20230930-inplace" 'False) (((C1 ('MetaCons "TVar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :+: (C1 ('MetaCons "TPrim" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TPrim)) :+: C1 ('MetaCons "TDef" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 QName)))) :+: ((C1 ('MetaCons "TApp" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Args)) :+: C1 ('MetaCons "TLam" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm))) :+: (C1 ('MetaCons "TLit" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Literal)) :+: C1 ('MetaCons "TCon" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 QName))))) :+: ((C1 ('MetaCons "TLet" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm)) :+: (C1 ('MetaCons "TCase" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CaseInfo)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TAlt]))) :+: C1 ('MetaCons "TUnit" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "TSort" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TErased" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TCoerce" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm)) :+: C1 ('MetaCons "TError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TError)))))) |
data EvaluationStrategy Source #
The treeless compiler can behave differently depending on the target language evaluation strategy. For instance, more aggressive erasure for lazy targets.
Instances
Show EvaluationStrategy Source # | |
Defined in Agda.Syntax.Treeless showsPrec :: Int -> EvaluationStrategy -> ShowS show :: EvaluationStrategy -> String showList :: [EvaluationStrategy] -> ShowS | |
Eq EvaluationStrategy Source # | |
Defined in Agda.Syntax.Treeless (==) :: EvaluationStrategy -> EvaluationStrategy -> Bool (/=) :: EvaluationStrategy -> EvaluationStrategy -> Bool |
Instances
Pretty Compiled Source # | |
NamesIn Compiled Source # | |
Defined in Agda.Syntax.Internal.Names | |
KillRange Compiled Source # | |
Defined in Agda.Syntax.Treeless | |
Generic Compiled Source # | |
Show Compiled Source # | |
NFData Compiled Source # | |
Defined in Agda.Syntax.Treeless | |
Eq Compiled Source # | |
Ord Compiled Source # | |
type Rep Compiled Source # | |
Defined in Agda.Syntax.Treeless type Rep Compiled = D1 ('MetaData "Compiled" "Agda.Syntax.Treeless" "Agda-2.6.3.20230930-inplace" 'False) (C1 ('MetaCons "Compiled" 'PrefixI 'True) (S1 ('MetaSel ('Just "cTreeless") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm) :*: S1 ('MetaSel ('Just "cArgUsage") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe [ArgUsage])))) |
class Unreachable a where Source #
isUnreachable :: a -> Bool Source #
Checks if the given expression is unreachable or not.
Instances
Unreachable TAlt Source # | |
Defined in Agda.Syntax.Treeless isUnreachable :: TAlt -> Bool Source # | |
Unreachable TTerm Source # | |
Defined in Agda.Syntax.Treeless isUnreachable :: TTerm -> Bool Source # |
Compiler-related primitives. This are NOT the same thing as primitives in Agda's surface or internal syntax! Some of the primitives have a suffix indicating which type of arguments they take, using the following naming convention: Char | Type C | Character F | Float I | Integer Q | QName S | String
PAdd | |
PAdd64 | |
PSub | |
PSub64 | |
PMul | |
PMul64 | |
PQuot | |
PQuot64 | |
PRem | |
PRem64 | |
PGeq | |
PLt | |
PLt64 | |
PEqI | |
PEq64 | |
PEqF | |
PEqS | |
PEqC | |
PEqQ | |
PIf | |
PSeq | |
PITo64 | |
P64ToI |
Instances
Generic TPrim Source # | |
Show TPrim Source # | |
NFData TPrim Source # | |
Defined in Agda.Syntax.Treeless | |
Eq TPrim Source # | |
Ord TPrim Source # | |
type Rep TPrim Source # | |
Defined in Agda.Syntax.Treeless type Rep TPrim = D1 ('MetaData "TPrim" "Agda.Syntax.Treeless" "Agda-2.6.3.20230930-inplace" 'False) ((((C1 ('MetaCons "PAdd" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PAdd64" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "PSub" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PSub64" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PMul" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "PMul64" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PQuot" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PQuot64" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "PRem" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PRem64" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PGeq" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "PLt" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PLt64" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PEqI" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "PEq64" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PEqF" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PEqS" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "PEqC" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PEqQ" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PIf" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "PSeq" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PITo64" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "P64ToI" 'PrefixI 'False) (U1 :: Type -> Type)))))) |
CaseInfo | |
|
Instances
NamesIn CaseInfo Source # | |
Defined in Agda.Syntax.Internal.Names | |
Generic CaseInfo Source # | |
Show CaseInfo Source # | |
NFData CaseInfo Source # | |
Defined in Agda.Syntax.Treeless | |
Eq CaseInfo Source # | |
Ord CaseInfo Source # | |
type Rep CaseInfo Source # | |
Defined in Agda.Syntax.Treeless type Rep CaseInfo = D1 ('MetaData "CaseInfo" "Agda.Syntax.Treeless" "Agda-2.6.3.20230930-inplace" 'False) (C1 ('MetaCons "CaseInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "caseLazy") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "caseErased") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Erased) :*: S1 ('MetaSel ('Just "caseType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CaseType)))) |
TACon | Matches on the given constructor. If the match succeeds, the pattern variables are prepended to the current environment (pushes all existing variables aArity steps further away) |
TAGuard | Binds no variables The guard must only use the variable that the case expression matches on. |
TALit | |
Instances
HasFree TAlt Source # | |
NamesIn TAlt Source # | |
Defined in Agda.Syntax.Internal.Names | |
Unreachable TAlt Source # | |
Defined in Agda.Syntax.Treeless isUnreachable :: TAlt -> Bool Source # | |
Subst TAlt Source # | |
Defined in Agda.Compiler.Treeless.Subst applySubst :: Substitution' (SubstArg TAlt) -> TAlt -> TAlt Source # | |
Generic TAlt Source # | |
Show TAlt Source # | |
NFData TAlt Source # | |
Defined in Agda.Syntax.Treeless | |
Eq TAlt Source # | |
Ord TAlt Source # | |
type SubstArg TAlt Source # | |
Defined in Agda.Compiler.Treeless.Subst | |
type Rep TAlt Source # | |
Defined in Agda.Syntax.Treeless type Rep TAlt = D1 ('MetaData "TAlt" "Agda.Syntax.Treeless" "Agda-2.6.3.20230930-inplace" 'False) (C1 ('MetaCons "TACon" 'PrefixI 'True) (S1 ('MetaSel ('Just "aCon") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 QName) :*: (S1 ('MetaSel ('Just "aArity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "aBody") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm))) :+: (C1 ('MetaCons "TAGuard" 'PrefixI 'True) (S1 ('MetaSel ('Just "aGuard") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm) :*: S1 ('MetaSel ('Just "aBody") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm)) :+: C1 ('MetaCons "TALit" 'PrefixI 'True) (S1 ('MetaSel ('Just "aLit") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Literal) :*: S1 ('MetaSel ('Just "aBody") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm)))) |
TUnreachable | Code which is unreachable. E.g. absurd branches or missing case defaults. Runtime behaviour of unreachable code is undefined, but preferably the program will exit with an error message. The compiler is free to assume that this code is unreachable and to remove it. |
TMeta String | Code which could not be obtained because of a hole in the program. This should throw a runtime error. The string gives some information about the meta variable that got compiled. |
Instances
Generic TError Source # | |
Show TError Source # | |
NFData TError Source # | |
Defined in Agda.Syntax.Treeless | |
Eq TError Source # | |
Ord TError Source # | |
type Rep TError Source # | |
Defined in Agda.Syntax.Treeless type Rep TError = D1 ('MetaData "TError" "Agda.Syntax.Treeless" "Agda-2.6.3.20230930-inplace" 'False) (C1 ('MetaCons "TUnreachable" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TMeta" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))) |
Instances
NamesIn CaseType Source # | |
Defined in Agda.Syntax.Internal.Names | |
Generic CaseType Source # | |
Show CaseType Source # | |
NFData CaseType Source # | |
Defined in Agda.Syntax.Treeless | |
Eq CaseType Source # | |
Ord CaseType Source # | |
type Rep CaseType Source # | |
Defined in Agda.Syntax.Treeless type Rep CaseType = D1 ('MetaData "CaseType" "Agda.Syntax.Treeless" "Agda-2.6.3.20230930-inplace" 'False) ((C1 ('MetaCons "CTData" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 QName)) :+: (C1 ('MetaCons "CTNat" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CTInt" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "CTChar" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CTString" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "CTFloat" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CTQName" 'PrefixI 'False) (U1 :: Type -> Type)))) |
filterUsed :: [ArgUsage] -> [a] -> [a] Source #
filterUsed used args
drops those args
which are labelled
ArgUnused
in list used
.
Specification:
filterUsed used args = [ a | (a, ArgUsed) <- zip args $ used ++ repeat ArgUsed ]
Examples:
filterUsed [] == id filterUsed (repeat ArgUsed) == id filterUsed (repeat ArgUnused) == const []
coerceView :: TTerm -> (Bool, TTerm) Source #
Strip leading coercions and indicate whether there were some.
coerceAppView :: TTerm -> ((Bool, TTerm), [TTerm]) Source #
Expose the format coerce f args
.
We fuse coercions, even if interleaving with applications.
We assume that coercion is powerful enough to satisfy
coerce (coerce f a) b = coerce f a b
word64View :: TTerm -> Maybe Word64 Source #
negPlusKView :: TTerm -> Maybe (Integer, TTerm) Source #
tUnreachable :: TTerm Source #