Agda-2.5.2: A dependently typed functional programming language and proof assistant

Safe Haskell | None
Language | Haskell2010

Agda.Syntax.Treeless

Description

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 Compiled = Compiled {
  - cTreeless :: TTerm
  - cArgUsage :: [Bool]
  }
- type Args = [TTerm]
- data TTerm
  - = TVar Int
  - | TPrim TPrim
  - | TDef QName
  - | TApp TTerm Args
  - | TLam TTerm
  - | TLit Literal
  - | TCon QName
  - | TLet TTerm TTerm
  - | TCase Int CaseType TTerm [TAlt]
  - | TUnit
  - | TSort
  - | TErased
  - | TError TError
- data TPrim
  - = PAdd
  - | PSub
  - | PMul
  - | PQuot
  - | PRem
  - | PGeq
  - | PLt
  - | PEqI
  - | PEqF
  - | PEqS
  - | PEqC
  - | PEqQ
  - | PIf
  - | PSeq
- isPrimEq :: TPrim -> Bool
- mkTApp :: TTerm -> Args -> TTerm
- tAppView :: TTerm -> [TTerm]
- tLetView :: TTerm -> ([TTerm], TTerm)
- tLamView :: TTerm -> (Int, TTerm)
- mkTLam :: Int -> TTerm -> TTerm
- mkLet :: TTerm -> TTerm -> TTerm
- tInt :: Integer -> TTerm
- intView :: TTerm -> Maybe Integer
- tPlusK :: Integer -> TTerm -> TTerm
- tNegPlusK :: Integer -> TTerm -> TTerm
- plusKView :: TTerm -> Maybe (Integer, TTerm)
- negPlusKView :: TTerm -> Maybe (Integer, TTerm)
- tOp :: TPrim -> TTerm -> TTerm -> TTerm
- tUnreachable :: TTerm
- tIfThenElse :: TTerm -> TTerm -> TTerm -> TTerm
- data CaseType
  - = CTData QName
  - | CTNat
  - | CTInt
  - | CTChar
  - | CTString
  - | CTFloat
  - | CTQName
- data TAlt
  - = TACon {
    - aCon :: QName
    - aArity :: Int
    - aBody :: TTerm
    }
  - | TAGuard {
    - aGuard :: TTerm
    - aBody :: TTerm
    }
  - | TALit {
    - aLit :: Literal
    - aBody :: TTerm
    }
- data TError = TUnreachable
- class Unreachable a where

# Documentation

module Agda.Syntax.Abstract.Name

data Compiled #

Constructors

Compiled |
Fields cTreeless :: TTerm cArgUsage :: [Bool]

Instances

Eq Compiled # |
Methods (==) :: Compiled -> Compiled -> Bool # (/=) :: Compiled -> Compiled -> Bool #
Ord Compiled # |
Methods compare :: Compiled -> Compiled -> Ordering # (<) :: Compiled -> Compiled -> Bool # (<=) :: Compiled -> Compiled -> Bool # (>) :: Compiled -> Compiled -> Bool # (>=) :: Compiled -> Compiled -> Bool # max :: Compiled -> Compiled -> Compiled # min :: Compiled -> Compiled -> Compiled #
Show Compiled # |
Methods showsPrec :: Int -> Compiled -> ShowS # show :: Compiled -> String # showList :: [Compiled] -> ShowS #
KillRange Compiled # |
Methods killRange :: KillRangeT Compiled #

type Args = [TTerm] #

data TTerm #

Constructors

TVar Int |
TPrim TPrim |
TDef QName |
TApp TTerm Args |
TLam TTerm |
TLit Literal |
TCon QName |
TLet TTerm TTerm | introduces a new 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 CaseType 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 |
TError TError | A runtime error, something bad has happened.

Instances

Eq TTerm # |
Methods (==) :: TTerm -> TTerm -> Bool # (/=) :: TTerm -> TTerm -> Bool #
Ord TTerm # |
Methods compare :: TTerm -> TTerm -> Ordering # (<) :: TTerm -> TTerm -> Bool # (<=) :: TTerm -> TTerm -> Bool # (>) :: TTerm -> TTerm -> Bool # (>=) :: TTerm -> TTerm -> Bool # max :: TTerm -> TTerm -> TTerm # min :: TTerm -> TTerm -> TTerm #
Show TTerm # |
Methods showsPrec :: Int -> TTerm -> ShowS # show :: TTerm -> String # showList :: [TTerm] -> ShowS #
Unreachable TTerm # |
Methods isUnreachable :: TTerm -> Bool #
HasFree TTerm # |
Methods freeVars :: TTerm -> Map Int Occurs #

data TPrim #

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

Constructors

PAdd |
PSub |
PMul |
PQuot |
PRem |
PGeq |
PLt |
PEqI |
PEqF |
PEqS |
PEqC |
PEqQ |
PIf |
PSeq |

Instances

Eq TPrim # |
Methods (==) :: TPrim -> TPrim -> Bool # (/=) :: TPrim -> TPrim -> Bool #
Ord TPrim # |
Methods compare :: TPrim -> TPrim -> Ordering # (<) :: TPrim -> TPrim -> Bool # (<=) :: TPrim -> TPrim -> Bool # (>) :: TPrim -> TPrim -> Bool # (>=) :: TPrim -> TPrim -> Bool # max :: TPrim -> TPrim -> TPrim # min :: TPrim -> TPrim -> TPrim #
Show TPrim # |
Methods showsPrec :: Int -> TPrim -> ShowS # show :: TPrim -> String # showList :: [TPrim] -> ShowS #

isPrimEq :: TPrim -> Bool #

mkTApp :: TTerm -> Args -> TTerm #

tAppView :: TTerm -> [TTerm] #

tLetView :: TTerm -> ([TTerm], TTerm) #

tLamView :: TTerm -> (Int, TTerm) #

mkTLam :: Int -> TTerm -> TTerm #

mkLet :: TTerm -> TTerm -> TTerm #

Introduces a new binding

tInt :: Integer -> TTerm #

intView :: TTerm -> Maybe Integer #

tPlusK :: Integer -> TTerm -> TTerm #

tNegPlusK :: Integer -> TTerm -> TTerm #

plusKView :: TTerm -> Maybe (Integer, TTerm) #

negPlusKView :: TTerm -> Maybe (Integer, TTerm) #

tOp :: TPrim -> TTerm -> TTerm -> TTerm #

tUnreachable :: TTerm #

tIfThenElse :: TTerm -> TTerm -> TTerm -> TTerm #

data CaseType #

Constructors

CTData QName |
CTNat |
CTInt |
CTChar |
CTString |
CTFloat |
CTQName |

Instances

Eq CaseType # |
Methods (==) :: CaseType -> CaseType -> Bool # (/=) :: CaseType -> CaseType -> Bool #
Ord CaseType # |
Methods compare :: CaseType -> CaseType -> Ordering # (<) :: CaseType -> CaseType -> Bool # (<=) :: CaseType -> CaseType -> Bool # (>) :: CaseType -> CaseType -> Bool # (>=) :: CaseType -> CaseType -> Bool # max :: CaseType -> CaseType -> CaseType # min :: CaseType -> CaseType -> CaseType #
Show CaseType # |
Methods showsPrec :: Int -> CaseType -> ShowS # show :: CaseType -> String # showList :: [CaseType] -> ShowS #

data TAlt #

Constructors

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)
Fields aCon :: QName aArity :: Int aBody :: TTerm
TAGuard | Binds no variables
Fields aGuard :: TTerm aBody :: TTerm
TALit |
Fields aLit :: Literal aBody :: TTerm

Instances

Eq TAlt # |
Methods (==) :: TAlt -> TAlt -> Bool # (/=) :: TAlt -> TAlt -> Bool #
Ord TAlt # |
Methods compare :: TAlt -> TAlt -> Ordering # (<) :: TAlt -> TAlt -> Bool # (<=) :: TAlt -> TAlt -> Bool # (>) :: TAlt -> TAlt -> Bool # (>=) :: TAlt -> TAlt -> Bool # max :: TAlt -> TAlt -> TAlt # min :: TAlt -> TAlt -> TAlt #
Show TAlt # |
Methods showsPrec :: Int -> TAlt -> ShowS # show :: TAlt -> String # showList :: [TAlt] -> ShowS #
Unreachable TAlt # |
Methods isUnreachable :: TAlt -> Bool #
HasFree TAlt # |
Methods freeVars :: TAlt -> Map Int Occurs #

data TError #

Constructors

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.

Instances

Eq TError # |
Methods (==) :: TError -> TError -> Bool # (/=) :: TError -> TError -> Bool #
Ord TError # |
Methods compare :: TError -> TError -> Ordering # (<) :: TError -> TError -> Bool # (<=) :: TError -> TError -> Bool # (>) :: TError -> TError -> Bool # (>=) :: TError -> TError -> Bool # max :: TError -> TError -> TError # min :: TError -> TError -> TError #
Show TError # |
Methods showsPrec :: Int -> TError -> ShowS # show :: TError -> String # showList :: [TError] -> ShowS #

class Unreachable a where #

Minimal complete definition

isUnreachable

Methods

isUnreachable :: a -> Bool #

Checks if the given expression is unreachable or not.

Instances

Unreachable TAlt # |
Methods isUnreachable :: TAlt -> Bool #
Unreachable TTerm # |
Methods isUnreachable :: TTerm -> Bool #