Safe Haskell | None |
---|
- type CodeWriter = RWS Readers Writers States
- data Readers = Readers {
- alias :: [(VarId, Expr)]
- sourceInfo :: SourceInfo
- initReader :: Readers
- data Writers = Writers {}
- type Task = [Prog]
- data States = States {}
- initState :: States
- type Location = Expr
- class Compile sub dom where
- compileProgSym :: sub a -> Info (DenResult a) -> Location -> Args (AST (Decor Info dom)) a -> CodeWriter ()
- compileExprSym :: sub a -> Info (DenResult a) -> Args (AST (Decor Info dom)) a -> CodeWriter Expr
- compileExprLoc :: Compile sub dom => sub a -> Info (DenResult a) -> Location -> Args (AST (Decor Info dom)) a -> CodeWriter ()
- compileProgFresh :: Compile sub dom => sub a -> Info (DenResult a) -> Args (AST (Decor Info dom)) a -> CodeWriter Expr
- compileProgDecor :: Compile dom dom => Location -> Decor Info dom a -> Args (AST (Decor Info dom)) a -> CodeWriter ()
- compileExprDecor :: Compile dom dom => Decor Info dom a -> Args (AST (Decor Info dom)) a -> CodeWriter Expr
- compileProg :: Compile dom dom => Location -> ASTF (Decor Info dom) a -> CodeWriter ()
- compileExpr :: Compile dom dom => ASTF (Decor Info dom) a -> CodeWriter Expr
- compileExprVar :: Compile dom dom => ASTF (Decor Info dom) a -> CodeWriter Expr
- compileNumType :: Signedness a -> BitWidth n -> Type
- compileTypeRep :: TypeRep a -> Size a -> Type
- mkVarName :: VarId -> String
- mkVar :: Type -> VarId -> Expr
- mkVariable :: Type -> VarId -> Var
- freshId :: CodeWriter Integer
- freshVar :: String -> TypeRep a -> Size a -> CodeWriter Expr
- declare :: Expr -> CodeWriter ()
- tellDef :: [Ent] -> CodeWriter ()
- tellProg :: [Prog] -> CodeWriter ()
- tellDecl :: [Def] -> CodeWriter ()
- assign :: Location -> Expr -> CodeWriter ()
- confiscateBlock :: CodeWriter a -> CodeWriter (a, Block)
- withAlias :: VarId -> Expr -> CodeWriter a -> CodeWriter a
- isVariableOrLiteral :: (Project (Variable :|| Type) dom, Project (Literal :|| Type) dom) => AST (Decor info dom) a -> Bool
- mkLength :: (Project (Literal :|| Type) dom, Project (Variable :|| Type) dom, Compile dom dom) => ASTF (Decor Info dom) a -> CodeWriter Expr
Documentation
Readers | |
|
class Compile sub dom whereSource
A minimal complete instance has to define either compileProgSym
or
compileExprSym
.
compileProgSym :: sub a -> Info (DenResult a) -> Location -> Args (AST (Decor Info dom)) a -> CodeWriter ()Source
compileExprSym :: sub a -> Info (DenResult a) -> Args (AST (Decor Info dom)) a -> CodeWriter ExprSource
compileExprLoc :: Compile sub dom => sub a -> Info (DenResult a) -> Location -> Args (AST (Decor Info dom)) a -> CodeWriter ()Source
Implementation of compileExprSym
that assigns an expression to the given
location.
compileProgFresh :: Compile sub dom => sub a -> Info (DenResult a) -> Args (AST (Decor Info dom)) a -> CodeWriter ExprSource
Implementation of compileProgSym
that generates code into a fresh
variable.
compileProgDecor :: Compile dom dom => Location -> Decor Info dom a -> Args (AST (Decor Info dom)) a -> CodeWriter ()Source
compileExprDecor :: Compile dom dom => Decor Info dom a -> Args (AST (Decor Info dom)) a -> CodeWriter ExprSource
compileProg :: Compile dom dom => Location -> ASTF (Decor Info dom) a -> CodeWriter ()Source
compileExpr :: Compile dom dom => ASTF (Decor Info dom) a -> CodeWriter ExprSource
compileExprVar :: Compile dom dom => ASTF (Decor Info dom) a -> CodeWriter ExprSource
Utility functions
compileNumType :: Signedness a -> BitWidth n -> TypeSource
compileTypeRep :: TypeRep a -> Size a -> TypeSource
mkVariable :: Type -> VarId -> VarSource
declare :: Expr -> CodeWriter ()Source
tellDef :: [Ent] -> CodeWriter ()Source
tellProg :: [Prog] -> CodeWriter ()Source
tellDecl :: [Def] -> CodeWriter ()Source
assign :: Location -> Expr -> CodeWriter ()Source
confiscateBlock :: CodeWriter a -> CodeWriter (a, Block)Source
Like listen
, but also prevents the program from being written in the
monad.
withAlias :: VarId -> Expr -> CodeWriter a -> CodeWriter aSource