perga/lib/IR.hs

56 lines
1.1 KiB
Haskell

module IR where
type Param = (Text, IRExpr)
data IRExpr
= Var {varName :: Text}
| PureVar {pvName :: Text}
| Star
| 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)
data IRSectionDef
= Section
{ sectionName :: Text
, sectionContents :: [IRSectionDef]
}
| Variable
{ variableName :: Text
, variableType :: IRExpr
}
| IRDef IRDef
deriving (Show, Eq, Ord)
data IRDef
= Def
{ defName :: Text
, defAscription :: Maybe IRExpr
, defBody :: IRExpr
}
| Axiom
{ axiomName :: Text
, axiomAscription :: IRExpr
}
deriving (Show, Eq, Ord)
type IRProgram = [IRSectionDef]