perga/lib/IR.hs

49 lines
986 B
Haskell

{-# LANGUAGE TemplateHaskell #-}
module IR where
import Control.Lens
type Param = (Text, IRExpr)
data IRExpr
= Var {_varName :: Text}
| Level {_level :: Integer}
| App
{ _appFunc :: IRExpr
, _appArg :: IRExpr
}
| Abs
{ _absParamName :: Text
, _absParamType :: IRExpr
, _absBody :: IRExpr
}
| Pi
{ _piParamName :: Text
, _piParamType :: IRExpr
, _piBody :: IRExpr
}
| Let
{ _letVarName :: Text
, _letAscription :: Maybe IRExpr
, _letValue :: IRExpr
, _letBody :: IRExpr
}
deriving (Show, Eq, Ord)
makeLenses ''IRExpr
data IRDef
= Def
{ _defName :: Text
, _defParams :: [Param]
, _defAscription :: Maybe IRExpr
, _defBody :: IRExpr
}
| Axiom
{ _axiomName :: Text
, _axiomParams :: [Param]
, _axiomAscription :: IRExpr
}
type IRProgram = [IRDef]