Safe Haskell | Safe-Infered |
---|
The Haskell→Javascript compiler.
- compile :: CompilesTo from to => Config -> from -> IO (Either CompileError to)
- runCompile :: Config -> Compile a -> IO (Either CompileError a)
- compileViaStr :: (Show from, Show to, CompilesTo from to) => Config -> (from -> Compile to) -> String -> IO (Either CompileError String)
- compileToAst :: (Show from, Show to, CompilesTo from to) => Config -> (from -> Compile to) -> String -> IO (Either CompileError to)
- compileFromStr :: (Parseable a, MonadError CompileError m) => (a -> m a1) -> String -> m a1
- compileModule :: Module -> Compile [JsStmt]
- compileImport :: ImportDecl -> Compile [JsStmt]
- compileDecls :: [Decl] -> Compile [JsStmt]
- compileDecl :: Decl -> Compile [JsStmt]
- compilePatBind :: Maybe Type -> Decl -> Compile [JsStmt]
- compileNormalPatBind :: Name -> Exp -> Compile [JsStmt]
- compileFFIFunc :: Type -> Name -> (String, String, String) -> Compile [JsStmt]
- compileFFIMethod :: Type -> Name -> (String, String, String) -> Compile [JsStmt]
- compileFFI :: Type -> Name -> (String, String, String) -> JsExp -> [JsName] -> [JsName] -> Compile [JsStmt]
- data ArgType
- = FunctionType
- | JsType
- | StringType
- | DoubleType
- | ListType
- | BoolType
- | UnknownType
- serialize :: ArgType -> JsExp -> JsExp
- functionTypeArgs :: Type -> [ArgType]
- typeArity :: Type -> Integer
- compileDataDecl :: Decl -> [QualConDecl] -> Compile [JsStmt]
- qname :: QName -> String
- unname :: Name -> String
- compileFunCase :: [Match] -> Compile [JsStmt]
- optimizeTailCalls :: [JsParam] -> Name -> [JsStmt] -> [JsStmt]
- flatten :: JsExp -> Maybe [JsExp]
- expand :: JsExp -> Maybe [JsExp]
- compileRhs :: Rhs -> Compile JsExp
- compileFunMatch :: Match -> Compile [JsStmt]
- compileExp :: Exp -> Compile JsExp
- compileApp :: Exp -> Exp -> Compile JsExp
- optimizeApp :: JsExp -> JsExp
- compileInfixApp :: Exp -> QOp -> Exp -> Compile JsExp
- compileList :: [Exp] -> Compile JsExp
- compileIf :: Exp -> Exp -> Exp -> Compile JsExp
- compileLambda :: [Pat] -> Exp -> Compile JsExp
- compileCase :: Exp -> [Alt] -> Compile JsExp
- compileDoBlock :: [Stmt] -> Compile JsExp
- compileStmt :: Maybe Exp -> Stmt -> Compile (Maybe Exp)
- compilePatAlt :: JsExp -> Alt -> Compile [JsStmt]
- compilePat :: JsExp -> Pat -> [JsStmt] -> Compile [JsStmt]
- compilePLit :: JsExp -> Literal -> [JsStmt] -> Compile [JsStmt]
- equalExps :: JsExp -> JsExp -> JsExp
- isConstant :: JsExp -> Bool
- compilePApp :: QName -> [Pat] -> JsExp -> [JsStmt] -> Compile [JsStmt]
- compilePList :: [Pat] -> [JsStmt] -> JsExp -> Compile [JsStmt]
- compileInfixPat :: JsExp -> Pat -> [JsStmt] -> Compile [JsStmt]
- compileGuardedAlt :: GuardedAlts -> Compile JsExp
- compileLet :: [Decl] -> Exp -> Compile JsExp
- compileLetDecl :: Decl -> Compile [JsStmt]
- compileLit :: Literal -> Compile JsExp
- uniqueNames :: [JsParam]
- thenm :: JsExp -> JsExp -> JsExp
- optimizePatConditions :: [[JsStmt]] -> [[JsStmt]]
- throw :: String -> JsExp -> JsStmt
- throwExp :: String -> JsExp -> JsExp
- isWildCardAlt :: Alt -> Bool
- isWildCardPat :: Pat -> Bool
- tmpName :: JsExp -> JsName
- thunk :: JsExp -> JsExp
- monad :: JsExp -> JsExp
- stmtsThunk :: [JsStmt] -> JsExp
- unserialize :: String -> JsExp -> JsExp
- force :: JsExp -> JsExp
- forceInlinable :: Config -> JsExp -> JsExp
- resolveOpToVar :: QOp -> Compile Exp
- hjIdent :: String -> QName
- parseResult :: ((SrcLoc, String) -> b) -> (a -> b) -> ParseResult a -> b
Documentation
compile :: CompilesTo from to => Config -> from -> IO (Either CompileError to)Source
Compile something that compiles to something else.
runCompile :: Config -> Compile a -> IO (Either CompileError a)Source
Run the compiler.
compileViaStr :: (Show from, Show to, CompilesTo from to) => Config -> (from -> Compile to) -> String -> IO (Either CompileError String)Source
Compile a Haskell source string to a JavaScript source string.
compileToAst :: (Show from, Show to, CompilesTo from to) => Config -> (from -> Compile to) -> String -> IO (Either CompileError to)Source
Compile a Haskell source string to a JavaScript source string.
compileFromStr :: (Parseable a, MonadError CompileError m) => (a -> m a1) -> String -> m a1Source
compileModule :: Module -> Compile [JsStmt]Source
Compile Haskell module.
compileImport :: ImportDecl -> Compile [JsStmt]Source
Compile the given import.
compileDecls :: [Decl] -> Compile [JsStmt]Source
Compile Haskell declaration.
compileDecl :: Decl -> Compile [JsStmt]Source
compileFFI :: Type -> Name -> (String, String, String) -> JsExp -> [JsName] -> [JsName] -> Compile [JsStmt]Source
Compile an FFI call.
These are the data types that are serializable directly to native JS data types. Strings, floating points and arrays. The others are: actiosn in the JS monad, which are thunks that shouldn't be forced when serialized but wrapped up as JS zero-arg functions, and unknown types can't be converted but should at least be forced.
functionTypeArgs :: Type -> [ArgType]Source
Get arg types of a function type.
compileDataDecl :: Decl -> [QualConDecl] -> Compile [JsStmt]Source
compileFunCase :: [Match] -> Compile [JsStmt]Source
Compile a function which pattern matches (causing a case analysis).
:: [JsParam] | The function parameters. |
-> Name | The function name. |
-> [JsStmt] | The body of the function. |
-> [JsStmt] | A new optimized function body. |
Optimize functions in tail-call form.
compileRhs :: Rhs -> Compile JsExpSource
Compile a right-hand-side expression.
compileFunMatch :: Match -> Compile [JsStmt]Source
Compile a pattern match binding.
compileExp :: Exp -> Compile JsExpSource
Compile Haskell expression.
optimizeApp :: JsExp -> JsExpSource
compileList :: [Exp] -> Compile JsExpSource
compileDoBlock :: [Stmt] -> Compile JsExpSource
compilePatAlt :: JsExp -> Alt -> Compile [JsStmt]Source
Compile the given pattern against the given expression.
compilePat :: JsExp -> Pat -> [JsStmt] -> Compile [JsStmt]Source
Compile the given pattern against the given expression.
isConstant :: JsExp -> BoolSource
compileGuardedAlt :: GuardedAlts -> Compile JsExpSource
Compile a guarded alt.
compileLetDecl :: Decl -> Compile [JsStmt]Source
Compile let declaration.
compileLit :: Literal -> Compile JsExpSource
Compile Haskell literal.
uniqueNames :: [JsParam]Source
Generate unique names.
optimizePatConditions :: [[JsStmt]] -> [[JsStmt]]Source
Optimize pattern matching conditions by merging conditions in common.
isWildCardAlt :: Alt -> BoolSource
Is an alt a wildcard?
isWildCardPat :: Pat -> BoolSource
Is a pattern a wildcard?
stmtsThunk :: [JsStmt] -> JsExpSource
Wrap an expression in a thunk.
unserialize :: String -> JsExp -> JsExpSource
forceInlinable :: Config -> JsExp -> JsExpSource
Force an expression in a thunk.
resolveOpToVar :: QOp -> Compile ExpSource
Resolve operators to only built-in (for now) functions.
parseResult :: ((SrcLoc, String) -> b) -> (a -> b) -> ParseResult a -> bSource
Parse result.