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

Safe Haskell | None
Language | Haskell2010

Agda.TypeChecking.Primitive

Contents

- Primitive functions
- The actual primitive functions

Description

Primitive functions, such as addition on builtin integers.

Synopsis

- data PrimitiveImpl = PrimImpl Type PrimFun
- newtype Nat = Nat {
  - unNat :: Integer
  }
- newtype Lvl = Lvl {
  - unLvl :: Integer
  }
- class PrimType a where
- class PrimTerm a where
- class ToTerm a where
- buildList :: TCM ([Term] -> Term)
- type FromTermFunction a = Arg Term -> ReduceM (Reduced (MaybeReduced (Arg Term)) a)
- class FromTerm a where
- redBind :: ReduceM (Reduced a a') -> (a -> b) -> (a' -> ReduceM (Reduced b b')) -> ReduceM (Reduced b b')
- redReturn :: a -> ReduceM (Reduced a' a)
- fromReducedTerm :: (Term -> Maybe a) -> TCM (FromTermFunction a)
- fromLiteral :: (Literal -> Maybe a) -> TCM (FromTermFunction a)
- primTrustMe :: TCM PrimitiveImpl
- genPrimForce :: TCM Type -> (Term -> Arg Term -> Term) -> TCM PrimitiveImpl
- primForce :: TCM PrimitiveImpl
- primForceLemma :: TCM PrimitiveImpl
- mkPrimLevelZero :: TCM PrimitiveImpl
- mkPrimLevelSuc :: TCM PrimitiveImpl
- mkPrimLevelMax :: TCM PrimitiveImpl
- mkPrimFun1TCM :: (FromTerm a, ToTerm b, TermLike b) => TCM Type -> (a -> ReduceM b) -> TCM PrimitiveImpl
- mkPrimFun1 :: (PrimType a, FromTerm a, PrimType b, ToTerm b) => (a -> b) -> TCM PrimitiveImpl
- mkPrimFun2 :: (PrimType a, FromTerm a, ToTerm a, PrimType b, FromTerm b, PrimType c, ToTerm c) => (a -> b -> c) -> TCM PrimitiveImpl
- mkPrimFun4 :: (PrimType a, FromTerm a, ToTerm a, PrimType b, FromTerm b, ToTerm b, PrimType c, FromTerm c, ToTerm c, PrimType d, FromTerm d, PrimType e, ToTerm e) => (a -> b -> c -> d -> e) -> TCM PrimitiveImpl
- (-->) :: TCM Type -> TCM Type -> TCM Type
- (.-->) :: TCM Type -> TCM Type -> TCM Type
- (..-->) :: TCM Type -> TCM Type -> TCM Type
- garr :: (Relevance -> Relevance) -> TCM Type -> TCM Type -> TCM Type
- gpi :: ArgInfo -> String -> TCM Type -> TCM Type -> TCM Type
- hPi :: String -> TCM Type -> TCM Type -> TCM Type
- nPi :: String -> TCM Type -> TCM Type -> TCM Type
- varM :: Int -> TCM Term
- gApply :: Hiding -> TCM Term -> TCM Term -> TCM Term
- (<@>) :: TCM Term -> TCM Term -> TCM Term
- (<#>) :: TCM Term -> TCM Term -> TCM Term
- list :: TCM Term -> TCM Term
- io :: TCM Term -> TCM Term
- el :: TCM Term -> TCM Type
- tset :: TCM Type
- tSetOmega :: TCM Type
- sSizeUniv :: Sort
- tSizeUniv :: TCM Type
- argN :: e -> Arg e
- domN :: e -> Dom e
- argH :: e -> Arg e
- domH :: e -> Dom e
- type Op a = a -> a -> a
- type Fun a = a -> a
- type Rel a = a -> a -> Bool
- type Pred a = a -> Bool
- primitiveFunctions :: Map String (TCM PrimitiveImpl)
- floatEq :: Double -> Double -> Bool
- floatLt :: Double -> Double -> Bool
- lookupPrimitiveFunction :: String -> TCM PrimitiveImpl
- lookupPrimitiveFunctionQ :: QName -> TCM (String, PrimitiveImpl)
- getBuiltinName :: String -> TCM (Maybe QName)
- isBuiltin :: QName -> String -> TCM Bool

# Primitive functions

data PrimitiveImpl #

Constructors

PrimImpl Type PrimFun |

newtype Nat #

Constructors

Nat |
Fields unNat :: Integer

Instances

Enum Nat # |
Methods succ :: Nat -> Nat # pred :: Nat -> Nat # toEnum :: Int -> Nat # fromEnum :: Nat -> Int # enumFrom :: Nat -> [Nat] # enumFromThen :: Nat -> Nat -> [Nat] # enumFromTo :: Nat -> Nat -> [Nat] # enumFromThenTo :: Nat -> Nat -> Nat -> [Nat] #
Eq Nat # |
Methods (==) :: Nat -> Nat -> Bool # (/=) :: Nat -> Nat -> Bool #
Integral Nat # |
Methods quot :: Nat -> Nat -> Nat # rem :: Nat -> Nat -> Nat # div :: Nat -> Nat -> Nat # mod :: Nat -> Nat -> Nat # quotRem :: Nat -> Nat -> (Nat, Nat) # divMod :: Nat -> Nat -> (Nat, Nat) # toInteger :: Nat -> Integer #
Num Nat # |
Methods (+) :: Nat -> Nat -> Nat # (-) :: Nat -> Nat -> Nat # (*) :: Nat -> Nat -> Nat # negate :: Nat -> Nat # abs :: Nat -> Nat # signum :: Nat -> Nat # fromInteger :: Integer -> Nat #
Ord Nat # |
Methods compare :: Nat -> Nat -> Ordering # (<) :: Nat -> Nat -> Bool # (<=) :: Nat -> Nat -> Bool # (>) :: Nat -> Nat -> Bool # (>=) :: Nat -> Nat -> Bool # max :: Nat -> Nat -> Nat # min :: Nat -> Nat -> Nat #
Real Nat # |
Methods toRational :: Nat -> Rational #
Show Nat # |
Methods showsPrec :: Int -> Nat -> ShowS # show :: Nat -> String # showList :: [Nat] -> ShowS #
TermLike Nat # |
Methods traverseTerm :: (Term -> Term) -> Nat -> Nat # traverseTermM :: Monad m => (Term -> m Term) -> Nat -> m Nat # foldTerm :: Monoid m => (Term -> m) -> Nat -> m #
FromTerm Nat # |
Methods fromTerm :: TCM (FromTermFunction Nat) #
ToTerm Nat # |
Methods toTerm :: TCM (Nat -> Term) # toTermR :: TCM (Nat -> ReduceM Term) #
PrimTerm Nat # |
Methods primTerm :: Nat -> TCM Term #

newtype Lvl #

Constructors

Lvl |
Fields unLvl :: Integer

Instances

Eq Lvl # |
Methods (==) :: Lvl -> Lvl -> Bool # (/=) :: Lvl -> Lvl -> Bool #
Ord Lvl # |
Methods compare :: Lvl -> Lvl -> Ordering # (<) :: Lvl -> Lvl -> Bool # (<=) :: Lvl -> Lvl -> Bool # (>) :: Lvl -> Lvl -> Bool # (>=) :: Lvl -> Lvl -> Bool # max :: Lvl -> Lvl -> Lvl # min :: Lvl -> Lvl -> Lvl #
Show Lvl # |
Methods showsPrec :: Int -> Lvl -> ShowS # show :: Lvl -> String # showList :: [Lvl] -> ShowS #
FromTerm Lvl # |
Methods fromTerm :: TCM (FromTermFunction Lvl) #
ToTerm Lvl # |
Methods toTerm :: TCM (Lvl -> Term) # toTermR :: TCM (Lvl -> ReduceM Term) #
PrimTerm Lvl # |
Methods primTerm :: Lvl -> TCM Term #

class PrimType a where #

Minimal complete definition

primType

Methods

primType :: a -> TCM Type #

Instances

PrimTerm a => PrimType a # |
Methods primType :: a -> TCM Type #

class PrimTerm a where #

Minimal complete definition

primTerm

Methods

primTerm :: a -> TCM Term #

Instances

PrimTerm Bool # |
Methods primTerm :: Bool -> TCM Term #
PrimTerm Char # |
Methods primTerm :: Char -> TCM Term #
PrimTerm Double # |
Methods primTerm :: Double -> TCM Term #
PrimTerm Integer # |
Methods primTerm :: Integer -> TCM Term #
PrimTerm Str # |
Methods primTerm :: Str -> TCM Term #
PrimTerm Fixity' # |
Methods primTerm :: Fixity' -> TCM Term #
PrimTerm MetaId # |
Methods primTerm :: MetaId -> TCM Term #
PrimTerm QName # |
Methods primTerm :: QName -> TCM Term #
PrimTerm Type # |
Methods primTerm :: Type -> TCM Term #
PrimTerm Lvl # |
Methods primTerm :: Lvl -> TCM Term #
PrimTerm Nat # |
Methods primTerm :: Nat -> TCM Term #
PrimTerm a => PrimTerm [a] # |
Methods primTerm :: [a] -> TCM Term #
PrimTerm a => PrimTerm (IO a) # |
Methods primTerm :: IO a -> TCM Term #
(PrimType a, PrimType b) => PrimTerm (a -> b) # |
Methods primTerm :: (a -> b) -> TCM Term #

class ToTerm a where #

Minimal complete definition

toTerm

Methods

toTerm :: TCM (a -> Term) #

toTermR :: TCM (a -> ReduceM Term) #

Instances

ToTerm Bool # |
Methods toTerm :: TCM (Bool -> Term) # toTermR :: TCM (Bool -> ReduceM Term) #
ToTerm Char # |
Methods toTerm :: TCM (Char -> Term) # toTermR :: TCM (Char -> ReduceM Term) #
ToTerm Double # |
Methods toTerm :: TCM (Double -> Term) # toTermR :: TCM (Double -> ReduceM Term) #
ToTerm Integer # |
Methods toTerm :: TCM (Integer -> Term) # toTermR :: TCM (Integer -> ReduceM Term) #
ToTerm Str # |
Methods toTerm :: TCM (Str -> Term) # toTermR :: TCM (Str -> ReduceM Term) #
ToTerm Fixity' # |
Methods toTerm :: TCM (Fixity' -> Term) # toTermR :: TCM (Fixity' -> ReduceM Term) #
ToTerm MetaId # |
Methods toTerm :: TCM (MetaId -> Term) # toTermR :: TCM (MetaId -> ReduceM Term) #
ToTerm ArgInfo # |
Methods toTerm :: TCM (ArgInfo -> Term) # toTermR :: TCM (ArgInfo -> ReduceM Term) #
ToTerm QName # |
Methods toTerm :: TCM (QName -> Term) # toTermR :: TCM (QName -> ReduceM Term) #
ToTerm Fixity # |
Methods toTerm :: TCM (Fixity -> Term) # toTermR :: TCM (Fixity -> ReduceM Term) #
ToTerm Associativity # |
Methods toTerm :: TCM (Associativity -> Term) # toTermR :: TCM (Associativity -> ReduceM Term) #
ToTerm PrecedenceLevel # |
Methods toTerm :: TCM (PrecedenceLevel -> Term) # toTermR :: TCM (PrecedenceLevel -> ReduceM Term) #
ToTerm Type # |
Methods toTerm :: TCM (Type -> Term) # toTermR :: TCM (Type -> ReduceM Term) #
ToTerm Term # |
Methods toTerm :: TCM (Term -> Term) # toTermR :: TCM (Term -> ReduceM Term) #
ToTerm Lvl # |
Methods toTerm :: TCM (Lvl -> Term) # toTermR :: TCM (Lvl -> ReduceM Term) #
ToTerm Nat # |
Methods toTerm :: TCM (Nat -> Term) # toTermR :: TCM (Nat -> ReduceM Term) #
ToTerm a => ToTerm [a] # |
Methods toTerm :: TCM ([a] -> Term) # toTermR :: TCM ([a] -> ReduceM Term) #

buildList :: TCM ([Term] -> Term) #

`buildList A ts` builds a list of type `List A`. Assumes that the terms `ts` all have type `A`.

type FromTermFunction a = Arg Term -> ReduceM (Reduced (MaybeReduced (Arg Term)) a) #

class FromTerm a where #

Minimal complete definition

fromTerm

Methods

fromTerm :: TCM (FromTermFunction a) #

Instances

FromTerm Bool # |
Methods fromTerm :: TCM (FromTermFunction Bool) #
FromTerm Char # |
Methods fromTerm :: TCM (FromTermFunction Char) #
FromTerm Double # |
Methods fromTerm :: TCM (FromTermFunction Double) #
FromTerm Integer # |
Methods fromTerm :: TCM (FromTermFunction Integer) #
FromTerm Str # |
Methods fromTerm :: TCM (FromTermFunction Str) #
FromTerm MetaId # |
Methods fromTerm :: TCM (FromTermFunction MetaId) #
FromTerm QName # |
Methods fromTerm :: TCM (FromTermFunction QName) #
FromTerm Lvl # |
Methods fromTerm :: TCM (FromTermFunction Lvl) #
FromTerm Nat # |
Methods fromTerm :: TCM (FromTermFunction Nat) #
(ToTerm a, FromTerm a) => FromTerm [a] # |
Methods fromTerm :: TCM (FromTermFunction [a]) #

redBind :: ReduceM (Reduced a a') -> (a -> b) -> (a' -> ReduceM (Reduced b b')) -> ReduceM (Reduced b b') #

Conceptually: `redBind m f k = either (return . Left . f) k =<< m`

redReturn :: a -> ReduceM (Reduced a' a) #

fromReducedTerm :: (Term -> Maybe a) -> TCM (FromTermFunction a) #

fromLiteral :: (Literal -> Maybe a) -> TCM (FromTermFunction a) #

primTrustMe :: TCM PrimitiveImpl #

genPrimForce :: TCM Type -> (Term -> Arg Term -> Term) -> TCM PrimitiveImpl #

primForce :: TCM PrimitiveImpl #

primForceLemma :: TCM PrimitiveImpl #

mkPrimLevelZero :: TCM PrimitiveImpl #

mkPrimLevelSuc :: TCM PrimitiveImpl #

mkPrimLevelMax :: TCM PrimitiveImpl #

mkPrimFun1TCM :: (FromTerm a, ToTerm b, TermLike b) => TCM Type -> (a -> ReduceM b) -> TCM PrimitiveImpl #

mkPrimFun1 :: (PrimType a, FromTerm a, PrimType b, ToTerm b) => (a -> b) -> TCM PrimitiveImpl #

mkPrimFun2 :: (PrimType a, FromTerm a, ToTerm a, PrimType b, FromTerm b, PrimType c, ToTerm c) => (a -> b -> c) -> TCM PrimitiveImpl #

mkPrimFun4 :: (PrimType a, FromTerm a, ToTerm a, PrimType b, FromTerm b, ToTerm b, PrimType c, FromTerm c, ToTerm c, PrimType d, FromTerm d, PrimType e, ToTerm e) => (a -> b -> c -> d -> e) -> TCM PrimitiveImpl #

(-->) :: TCM Type -> TCM Type -> TCM Type infixr 4 #

(.-->) :: TCM Type -> TCM Type -> TCM Type infixr 4 #

(..-->) :: TCM Type -> TCM Type -> TCM Type infixr 4 #

garr :: (Relevance -> Relevance) -> TCM Type -> TCM Type -> TCM Type #

gpi :: ArgInfo -> String -> TCM Type -> TCM Type -> TCM Type #

hPi :: String -> TCM Type -> TCM Type -> TCM Type #

nPi :: String -> TCM Type -> TCM Type -> TCM Type #

varM :: Int -> TCM Term #

gApply :: Hiding -> TCM Term -> TCM Term -> TCM Term #

(<@>) :: TCM Term -> TCM Term -> TCM Term infixl 9 #

(<#>) :: TCM Term -> TCM Term -> TCM Term infixl 9 #

list :: TCM Term -> TCM Term #

io :: TCM Term -> TCM Term #

el :: TCM Term -> TCM Type #

tset :: TCM Type #

tSetOmega :: TCM Type #

sSizeUniv :: Sort #

tSizeUniv :: TCM Type #

argN :: e -> Arg e #

Abbreviation: `argN = `Arg` `defaultArgInfo``.

domN :: e -> Dom e #

argH :: e -> Arg e #

Abbreviation: `argH = `hide` `Arg` `defaultArgInfo``.

domH :: e -> Dom e #

# The actual primitive functions

type Op a = a -> a -> a #

type Fun a = a -> a #

type Rel a = a -> a -> Bool #

type Pred a = a -> Bool #

primitiveFunctions :: Map String (TCM PrimitiveImpl) #

floatEq :: Double -> Double -> Bool #

floatLt :: Double -> Double -> Bool #

lookupPrimitiveFunction :: String -> TCM PrimitiveImpl #

lookupPrimitiveFunctionQ :: QName -> TCM (String, PrimitiveImpl) #

getBuiltinName :: String -> TCM (Maybe QName) #

isBuiltin :: QName -> String -> TCM Bool #