2024-11-30 20:34:09 -08:00
|
|
|
module IR where
|
|
|
|
|
|
|
|
|
|
type Param = (Text, IRExpr)
|
|
|
|
|
|
|
|
|
|
data IRExpr
|
2024-11-30 22:36:27 -08:00
|
|
|
= Var {varName :: Text}
|
2024-12-22 13:16:32 -08:00
|
|
|
| PureVar {pvName :: Text}
|
2024-12-02 20:39:56 -08:00
|
|
|
| Star
|
2024-11-30 22:36:27 -08:00
|
|
|
| Level {level :: Integer}
|
2024-11-30 20:34:09 -08:00
|
|
|
| App
|
2024-11-30 22:36:27 -08:00
|
|
|
{ appFunc :: IRExpr
|
|
|
|
|
, appArg :: IRExpr
|
2024-11-30 20:34:09 -08:00
|
|
|
}
|
|
|
|
|
| Abs
|
2024-11-30 22:36:27 -08:00
|
|
|
{ absParamName :: Text
|
|
|
|
|
, absParamType :: IRExpr
|
|
|
|
|
, absBody :: IRExpr
|
2024-11-30 20:34:09 -08:00
|
|
|
}
|
|
|
|
|
| Pi
|
2024-11-30 22:36:27 -08:00
|
|
|
{ piParamName :: Text
|
|
|
|
|
, piParamType :: IRExpr
|
|
|
|
|
, piBody :: IRExpr
|
2024-11-30 20:34:09 -08:00
|
|
|
}
|
|
|
|
|
| Let
|
2024-11-30 22:36:27 -08:00
|
|
|
{ letVarName :: Text
|
|
|
|
|
, letAscription :: Maybe IRExpr
|
|
|
|
|
, letValue :: IRExpr
|
|
|
|
|
, letBody :: IRExpr
|
2024-11-30 20:34:09 -08:00
|
|
|
}
|
2025-01-25 10:39:50 -08:00
|
|
|
| Prod
|
|
|
|
|
{ prodLeft :: IRExpr
|
|
|
|
|
, prodRight :: IRExpr
|
|
|
|
|
}
|
|
|
|
|
| Pair
|
|
|
|
|
{ pairLeft :: IRExpr
|
|
|
|
|
, pairRight :: IRExpr
|
|
|
|
|
}
|
|
|
|
|
| Pi1 IRExpr
|
|
|
|
|
| Pi2 IRExpr
|
2024-11-30 20:34:09 -08:00
|
|
|
deriving (Show, Eq, Ord)
|
|
|
|
|
|
2024-12-06 13:36:14 -08:00
|
|
|
data IRSectionDef
|
|
|
|
|
= Section
|
|
|
|
|
{ sectionName :: Text
|
|
|
|
|
, sectionContents :: [IRSectionDef]
|
|
|
|
|
}
|
|
|
|
|
| Variable
|
|
|
|
|
{ variableName :: Text
|
|
|
|
|
, variableType :: IRExpr
|
|
|
|
|
}
|
|
|
|
|
| IRDef IRDef
|
|
|
|
|
deriving (Show, Eq, Ord)
|
|
|
|
|
|
2024-11-30 21:05:07 -08:00
|
|
|
data IRDef
|
|
|
|
|
= Def
|
2024-11-30 22:36:27 -08:00
|
|
|
{ defName :: Text
|
|
|
|
|
, defAscription :: Maybe IRExpr
|
|
|
|
|
, defBody :: IRExpr
|
2024-11-30 21:05:07 -08:00
|
|
|
}
|
|
|
|
|
| Axiom
|
2024-11-30 22:36:27 -08:00
|
|
|
{ axiomName :: Text
|
|
|
|
|
, axiomAscription :: IRExpr
|
2024-11-30 21:05:07 -08:00
|
|
|
}
|
2024-12-04 17:46:50 -08:00
|
|
|
deriving (Show, Eq, Ord)
|
2024-11-30 20:34:09 -08:00
|
|
|
|
2024-12-06 13:36:14 -08:00
|
|
|
type IRProgram = [IRSectionDef]
|