Copyright | Copyright (c) 2016 the Hakaru team |
---|---|
License | BSD3 |
Maintainer | zsulliva@indiana.edu |
Stability | experimental |
Portability | GHC-only This module provides a monad for C code generation as well |
Safe Haskell | None |
Language | Haskell2010 |
as some useful helper functions for manipulating it
- type CodeGen = State CG
- data CG = CG {
- freshNames :: [String]
- reservedNames :: Set String
- extDecls :: [CExtDecl]
- declarations :: [CDecl]
- statements :: [CStat]
- varEnv :: Env
- parallel :: Bool
- runCodeGen :: CodeGen a -> ([CExtDecl], [CDecl], [CStat])
- runCodeGenBlock :: CodeGen a -> CodeGen CStat
- runCodeGenWith :: CodeGen a -> CG -> [CExtDecl]
- emptyCG :: CG
- suffixes :: [String]
- declare :: Sing (a :: Hakaru) -> Ident -> CodeGen ()
- declare' :: CDecl -> CodeGen ()
- assign :: Ident -> CExpr -> CodeGen ()
- putStat :: CStat -> CodeGen ()
- putExprStat :: CExpr -> CodeGen ()
- extDeclare :: CExtDecl -> CodeGen ()
- defineFunction :: Sing (a :: Hakaru) -> Ident -> [CDecl] -> CodeGen () -> CodeGen ()
- funCG :: CTypeSpec -> Ident -> [CDecl] -> CodeGen () -> CodeGen ()
- isParallel :: CodeGen Bool
- mkParallel :: CodeGen ()
- mkSequential :: CodeGen ()
- reserveName :: String -> CodeGen ()
- genIdent :: CodeGen Ident
- genIdent' :: String -> CodeGen Ident
- createIdent :: Variable (a :: Hakaru) -> CodeGen Ident
- lookupIdent :: Variable (a :: Hakaru) -> CodeGen Ident
- whileCG :: CExpr -> CodeGen () -> CodeGen ()
- doWhileCG :: CExpr -> CodeGen () -> CodeGen ()
- forCG :: CExpr -> CExpr -> CExpr -> CodeGen () -> CodeGen ()
- reductionCG :: CBinaryOp -> Ident -> CExpr -> CExpr -> CExpr -> CodeGen () -> CodeGen ()
Documentation
CG | |
|
declare :: Sing (a :: Hakaru) -> Ident -> CodeGen () Source #
types like SData and SMeasure are impure in that they will produce extra code in the CodeGenMonad while literal types SReal, SInt, SNat, and SProb do not
putExprStat :: CExpr -> CodeGen () Source #
extDeclare :: CExtDecl -> CodeGen () Source #
isParallel :: CodeGen Bool Source #
mkParallel :: CodeGen () Source #
mkSequential :: CodeGen () Source #
reserveName :: String -> CodeGen () Source #