perga/lib/IR.hs

66 lines
1.3 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
}
| Prod
{ prodLeft :: IRExpr
, prodRight :: IRExpr
}
| Pair
{ pairLeft :: IRExpr
, pairRight :: IRExpr
}
| Pi1 IRExpr
| Pi2 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]