45 lines
852 B
Haskell
45 lines
852 B
Haskell
|
|
{-# LANGUAGE TemplateHaskell #-}
|
||
|
|
|
||
|
|
module IR where
|
||
|
|
|
||
|
|
import Control.Lens
|
||
|
|
|
||
|
|
type Param = (Text, IRExpr)
|
||
|
|
|
||
|
|
data IRExpr
|
||
|
|
= Var {_varName :: Text}
|
||
|
|
| Axiom
|
||
|
|
| 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
|
||
|
|
}
|
||
|
|
|
||
|
|
type IRProgram = [IRDef]
|