ModuleAgda-2.8.0.2Haskell2010
Agda.Syntax.Treeless
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
- 10 types
- 1 class
- 20 values
- PackageAgda-2.8.0.2
- Exports33
- LanguageHaskell2010
- LicenceMIT
- SourceTreeless.hs
module Agda.Syntax.Abstract.Name
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
Strip leading coercions and indicate whether there were some.
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 []
Introduces a new binding
Instances6Eq, Ord, Show, Generic, NFData, Rep
Eq ArgUsageDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessOrd ArgUsageDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessShow ArgUsageDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessGeneric ArgUsageDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessNFData ArgUsageDefined in Agda-2.8.0.2 · Agda.Syntax.Treelesstype Rep ArgUsage = D1 ('MetaDataDefined in Agda-2.8.0.2 · Agda.Syntax.Treeless"ArgUsage"
"Agda.Syntax.Treeless"
"Agda-2.8.0.2-3KZoCGOoan2Kayji4DU37s"
'False) (C1 ('MetaCons"ArgUsed"
'PrefixI 'False) U1 :+: C1 ('MetaCons"ArgUnused"
'PrefixI 'False) U1)
Instances7Eq, Ord, Show, Generic, NFData, NamesIn, …
Eq CaseInfoDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessOrd CaseInfoDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessShow CaseInfoDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessGeneric CaseInfoDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessNFData CaseInfoDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessNamesIn CaseInfoDefined in Agda-2.8.0.2 · Agda.Syntax.Internal.Namestype Rep CaseInfo = D1 ('MetaDataDefined in Agda-2.8.0.2 · Agda.Syntax.Treeless"CaseInfo"
"Agda.Syntax.Treeless"
"Agda-2.8.0.2-3KZoCGOoan2Kayji4DU37s"
'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))))
Instances7Eq, Ord, Show, Generic, NFData, NamesIn, …
Eq CaseTypeDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessOrd CaseTypeDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessShow CaseTypeDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessGeneric CaseTypeDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessNFData CaseTypeDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessNamesIn CaseTypeDefined in Agda-2.8.0.2 · Agda.Syntax.Internal.Namestype Rep CaseType = D1 ('MetaDataDefined in Agda-2.8.0.2 · Agda.Syntax.Treeless"CaseType"
"Agda.Syntax.Treeless"
"Agda-2.8.0.2-3KZoCGOoan2Kayji4DU37s"
'False) ((C1 ('MetaCons"CTData"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 QName)) :+: (C1 ('MetaCons"CTNat"
'PrefixI 'False) U1 :+: C1 ('MetaCons"CTInt"
'PrefixI 'False) U1)) :+: ((C1 ('MetaCons"CTChar"
'PrefixI 'False) U1 :+: C1 ('MetaCons"CTString"
'PrefixI 'False) U1) :+: (C1 ('MetaCons"CTFloat"
'PrefixI 'False) U1 :+: C1 ('MetaCons"CTQName"
'PrefixI 'False) U1)))
Instances9Eq, Ord, Show, Generic, NFData, Pretty, …
Eq CompiledDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessOrd CompiledDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessShow CompiledDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessGeneric CompiledDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessNFData CompiledDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessPretty CompiledDefined in Agda-2.8.0.2 · Agda.Compiler.Treeless.Pretty · orphanKillRange CompiledDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessNamesIn CompiledDefined in Agda-2.8.0.2 · Agda.Syntax.Internal.Namestype Rep Compiled = D1 ('MetaDataDefined in Agda-2.8.0.2 · Agda.Syntax.Treeless"Compiled"
"Agda.Syntax.Treeless"
"Agda-2.8.0.2-3KZoCGOoan2Kayji4DU37s"
'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]))))
The treeless compiler can behave differently depending on the target language evaluation strategy. For instance, more aggressive erasure for lazy targets.
Instances2Eq, Show
Eq EvaluationStrategyDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessShow EvaluationStrategyDefined in Agda-2.8.0.2 · Agda.Syntax.Treeless
Instances11Eq, Ord, Show, Generic, NFData, Unreachable, …
Eq TAltDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessOrd TAltDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessShow TAltDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessGeneric TAltDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessNFData TAltDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessUnreachable TAltDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessHasFree TAltDefined in Agda-2.8.0.2 · Agda.Compiler.Treeless.SubstSubst TAltDefined in Agda-2.8.0.2 · Agda.Compiler.Treeless.Subst · orphanNamesIn TAltDefined in Agda-2.8.0.2 · Agda.Syntax.Internal.Namestype Rep TAlt = D1 ('MetaDataDefined in Agda-2.8.0.2 · Agda.Syntax.Treeless"TAlt"
"Agda.Syntax.Treeless"
"Agda-2.8.0.2-3KZoCGOoan2Kayji4DU37s"
'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))))type SubstArg TAlt = TTermDefined in Agda-2.8.0.2 · Agda.Compiler.Treeless.Subst · orphan
Constructors
TUnreachableCode 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 StringCode 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.
Instances6Eq, Ord, Show, Generic, NFData, Rep
Eq TErrorDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessOrd TErrorDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessShow TErrorDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessGeneric TErrorDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessNFData TErrorDefined in Agda-2.8.0.2 · Agda.Syntax.Treelesstype Rep TError = D1 ('MetaDataDefined in Agda-2.8.0.2 · Agda.Syntax.Treeless"TError"
"Agda.Syntax.Treeless"
"Agda-2.8.0.2-3KZoCGOoan2Kayji4DU37s"
'False) (C1 ('MetaCons"TUnreachable"
'PrefixI 'False) U1 :+: C1 ('MetaCons"TMeta"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))
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
Instances6Eq, Ord, Show, Generic, NFData, Rep
Eq TPrimDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessOrd TPrimDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessShow TPrimDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessGeneric TPrimDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessNFData TPrimDefined in Agda-2.8.0.2 · Agda.Syntax.Treelesstype Rep TPrim = D1 ('MetaDataDefined in Agda-2.8.0.2 · Agda.Syntax.Treeless"TPrim"
"Agda.Syntax.Treeless"
"Agda-2.8.0.2-3KZoCGOoan2Kayji4DU37s"
'False) ((((C1 ('MetaCons"PAdd"
'PrefixI 'False) U1 :+: C1 ('MetaCons"PAdd64"
'PrefixI 'False) U1) :+: (C1 ('MetaCons"PSub"
'PrefixI 'False) U1 :+: (C1 ('MetaCons"PSub64"
'PrefixI 'False) U1 :+: C1 ('MetaCons"PMul"
'PrefixI 'False) U1))) :+: ((C1 ('MetaCons"PMul64"
'PrefixI 'False) U1 :+: (C1 ('MetaCons"PQuot"
'PrefixI 'False) U1 :+: C1 ('MetaCons"PQuot64"
'PrefixI 'False) U1)) :+: (C1 ('MetaCons"PRem"
'PrefixI 'False) U1 :+: (C1 ('MetaCons"PRem64"
'PrefixI 'False) U1 :+: C1 ('MetaCons"PGeq"
'PrefixI 'False) U1)))) :+: (((C1 ('MetaCons"PLt"
'PrefixI 'False) U1 :+: (C1 ('MetaCons"PLt64"
'PrefixI 'False) U1 :+: C1 ('MetaCons"PEqI"
'PrefixI 'False) U1)) :+: (C1 ('MetaCons"PEq64"
'PrefixI 'False) U1 :+: (C1 ('MetaCons"PEqF"
'PrefixI 'False) U1 :+: C1 ('MetaCons"PEqS"
'PrefixI 'False) U1))) :+: ((C1 ('MetaCons"PEqC"
'PrefixI 'False) U1 :+: (C1 ('MetaCons"PEqQ"
'PrefixI 'False) U1 :+: C1 ('MetaCons"PIf"
'PrefixI 'False) U1)) :+: (C1 ('MetaCons"PSeq"
'PrefixI 'False) U1 :+: (C1 ('MetaCons"PITo64"
'PrefixI 'False) U1 :+: C1 ('MetaCons"P64ToI"
'PrefixI 'False) U1)))))
Treeless Term. All local variables are using de Bruijn indices.
Constructors
TVar IntTPrim TPrimTDef QNameTApp TTerm ArgsTLam TTermTLit LiteralTCon QNameTLet TTerm TTermintroduces 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.
TUnitTSortTErasedTCoerce TTermUsed by the GHC backend
TError TErrorA runtime error, something bad has happened.
Instances13Eq, Ord, Show, Generic, NFData, Pretty, …
Eq TTermDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessOrd TTermDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessShow TTermDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessGeneric TTermDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessNFData TTermDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessPretty TTermDefined in Agda-2.8.0.2 · Agda.Compiler.Treeless.Pretty · orphanUnreachable TTermDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessDeBruijn TTermDefined in Agda-2.8.0.2 · Agda.Compiler.Treeless.Subst · orphanHasFree TTermDefined in Agda-2.8.0.2 · Agda.Compiler.Treeless.SubstSubst TTermDefined in Agda-2.8.0.2 · Agda.Compiler.Treeless.Subst · orphanNamesIn TTermDefined in Agda-2.8.0.2 · Agda.Syntax.Internal.Namestype Rep TTerm = D1 ('MetaDataDefined in Agda-2.8.0.2 · Agda.Syntax.Treeless"TTerm"
"Agda.Syntax.Treeless"
"Agda-2.8.0.2-3KZoCGOoan2Kayji4DU37s"
'False) (((C1 ('MetaCons"TVar"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :+: (C1 ('MetaCons"TPrim"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TPrim)) :+: C1 ('MetaCons"TDef"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 QName)))) :+: ((C1 ('MetaCons"TApp"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm) :*: S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Args)) :+: C1 ('MetaCons"TLam"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm))) :+: (C1 ('MetaCons"TLit"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Literal)) :+: C1 ('MetaCons"TCon"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 QName))))) :+: ((C1 ('MetaCons"TLet"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm) :*: S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm)) :+: (C1 ('MetaCons"TCase"
'PrefixI 'False) ((S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CaseInfo)) :*: (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm) :*: S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TAlt]))) :+: C1 ('MetaCons"TUnit"
'PrefixI 'False) U1)) :+: ((C1 ('MetaCons"TSort"
'PrefixI 'False) U1 :+: C1 ('MetaCons"TErased"
'PrefixI 'False) U1) :+: (C1 ('MetaCons"TCoerce"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TTerm)) :+: C1 ('MetaCons"TError"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TError))))))type SubstArg TTerm = TTermDefined in Agda-2.8.0.2 · Agda.Compiler.Treeless.Subst · orphan
Methods
isUnreachable :: a -> BoolChecks if the given expression is unreachable or not.
Instances2Unreachable
Unreachable TAltDefined in Agda-2.8.0.2 · Agda.Syntax.TreelessUnreachable TTermDefined in Agda-2.8.0.2 · Agda.Syntax.Treeless