perga/lib/IR.hs

58 lines
1.2 KiB
Haskell
Raw Normal View History

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}
| 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
, absAscription :: Maybe IRExpr
2024-11-30 22:36:27 -08:00
, absBody :: IRExpr
2024-11-30 20:34:09 -08:00
}
| Pi
2024-11-30 22:36:27 -08:00
{ piParamName :: Text
, piParamType :: IRExpr
, piAscription :: Maybe IRExpr
2024-11-30 22:36:27 -08:00
, 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
}
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]