module FreeC.LiftedIR.Syntax.Expr where
import qualified FreeC.Backend.Agda.Syntax as Agda
import qualified FreeC.Backend.Coq.Syntax as Coq
import FreeC.IR.SrcSpan ( SrcSpan )
import FreeC.LiftedIR.Effect ( Effect )
import FreeC.LiftedIR.Syntax.Name
import FreeC.LiftedIR.Syntax.Type
data Expr
=
Con { exprSrcSpan :: SrcSpan, exprConName :: ConName }
| SmartCon { exprSrcSpan :: SrcSpan, exprConName :: ConName }
| Var { exprSrcSpan :: SrcSpan
, exprVarName :: VarName
, exprAgdaVarName :: Agda.QName
, exprCoqVarIdent :: Coq.Qualid
}
| App { exprSrcSpan :: SrcSpan
, exprAppFunc :: Expr
, exprAppTypeArgs :: [Type]
, exprEffects :: [Effect]
, exprAppArgs :: [Expr]
, exprFreeArgs :: Bool
}
| If { exprSrcSpan :: SrcSpan
, ifExprCond :: Expr
, ifExprThen :: Expr
, ifExprElse :: Expr
}
| Case { exprSrcSpan :: SrcSpan
, caseExprScrutinee :: Expr
, caseExprAlts :: [Alt]
}
| Undefined { exprSrcSpan :: SrcSpan }
| ErrorExpr { exprSrcSpan :: SrcSpan }
| Trace { exprSrcSpan :: SrcSpan }
| IntLiteral { exprSrcSpan :: SrcSpan, intLiteralValue :: Integer }
| StringLiteral { exprSrcSpan :: SrcSpan, stringLiteralValue :: String }
| Lambda { exprSrcSpan :: SrcSpan
, lambdaExprArgs :: [VarPat]
, lambdaExprRhs :: Expr
}
| Pure
{ exprSrcSpan :: SrcSpan
, exprPureArg :: Expr
}
| Bind { exprSrcSpan :: SrcSpan
, exprBindArg :: Expr
, exprBindCont :: Expr
}
| Share { exprScrSpan :: SrcSpan
, exprShareArg :: Expr
, exprShareType :: Maybe Type
}
deriving ( Eq, Show )
data Alt = Alt { altSrcSpan :: SrcSpan
, altConPat :: ConPat
, altVarPats :: [VarPat]
, altRhs :: Expr
}
deriving ( Eq, Show )
data ConPat = ConPat { conPatSrcSpan :: SrcSpan, conPatName :: ConName }
deriving ( Eq, Show )
data VarPat = VarPat
{ varPatSrcSpan :: SrcSpan
, varPatIdent :: String
, varPatType :: Maybe Type
, varPatAgdaIdent :: Agda.QName
, varPatCoqIdent :: Coq.Qualid
}
deriving ( Eq, Show )