perga/lib/IR.hs

44 lines
889 B
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}
| 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
}
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
, defParams :: [Param]
, defAscription :: Maybe IRExpr
, defBody :: IRExpr
2024-11-30 21:05:07 -08:00
}
| Axiom
2024-11-30 22:36:27 -08:00
{ axiomName :: Text
, axiomParams :: [Param]
, axiomAscription :: IRExpr
2024-11-30 21:05:07 -08:00
}
2024-11-30 20:34:09 -08:00
type IRProgram = [IRDef]