Safe Haskell | Safe-Infered |
---|
The Haskell→Javascript compiler.
- compile :: CompilesTo from to => CompileConfig -> from -> IO (Either CompileError (to, CompileState))
- runCompile :: CompileConfig -> Compile a -> IO (Either CompileError (a, CompileState))
- compileViaStr :: (Show from, Show to, CompilesTo from to) => CompileConfig -> (from -> Compile to) -> String -> IO (Either CompileError (String, CompileState))
- compileToAst :: (Show from, Show to, CompilesTo from to) => CompileConfig -> (from -> Compile to) -> String -> IO (Either CompileError (to, CompileState))
- compileFromStr :: (Parseable a, MonadError CompileError m) => (a -> m a1) -> String -> m a1
- printCompile :: (Show from, Show to, CompilesTo from to) => CompileConfig -> (from -> Compile to) -> String -> IO ()
- printTestCompile :: String -> IO ()
- compileModule :: Module -> Compile [JsStmt]
- compileImport :: ImportDecl -> Compile [JsStmt]
- compileDecls :: Bool -> [Decl] -> Compile [JsStmt]
- compileDecl :: Bool -> Decl -> Compile [JsStmt]
- compilePatBind :: Bool -> Maybe Type -> Decl -> Compile [JsStmt]
- compileFFI :: Name -> String -> Type -> Compile [JsStmt]
- formatFFI :: String -> [(JsParam, FundamentalType)] -> Compile String
- serialize :: FundamentalType -> JsExp -> JsExp
- typeRep :: FundamentalType -> JsExp
- functionTypeArgs :: Type -> [FundamentalType]
- argType :: Type -> FundamentalType
- typeArity :: Type -> Int
- compileNormalPatBind :: Bool -> Name -> Exp -> Compile [JsStmt]
- compileDataDecl :: Bool -> Decl -> [QualConDecl] -> Compile [JsStmt]
- qname :: QName -> String
- unname :: Name -> String
- compileFunCase :: Bool -> [Match] -> Compile [JsStmt]
- optimizeTailCalls :: [JsParam] -> Name -> [JsStmt] -> [JsStmt]
- flatten :: JsExp -> Maybe [JsExp]
- expand :: JsExp -> Maybe [JsExp]
- prettyPrintFile :: String -> IO String
- compileRhs :: Rhs -> Compile JsExp
- compileGuards :: [GuardedRhs] -> Compile JsExp
- compileFunMatch :: Bool -> Match -> Compile [JsStmt]
- compileExp :: Exp -> Compile JsExp
- compileApp :: Exp -> Exp -> Compile JsExp
- compileInfixApp :: Exp -> QOp -> Exp -> Compile JsExp
- compileList :: [Exp] -> Compile JsExp
- makeList :: [JsExp] -> 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]
- compilePAsPat :: JsExp -> Name -> Pat -> [JsStmt] -> Compile [JsStmt]
- compileRecConstr :: QName -> [FieldUpdate] -> Compile JsExp
- 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]
- 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 :: FundamentalType -> JsExp -> JsExp
- force :: JsExp -> JsExp
- forceInlinable :: CompileConfig -> JsExp -> JsExp
- resolveOpToVar :: QOp -> Compile Exp
- hjIdent :: String -> QName
- bindToplevel :: Bool -> QName -> JsExp -> Compile JsStmt
- emitExport :: ExportSpec -> Compile ()
- parseResult :: ((SrcLoc, String) -> b) -> (a -> b) -> ParseResult a -> b
- config :: (CompileConfig -> a) -> Compile a
Documentation
compile :: CompilesTo from to => CompileConfig -> from -> IO (Either CompileError (to, CompileState))Source
Compile something that compiles to something else.
runCompile :: CompileConfig -> Compile a -> IO (Either CompileError (a, CompileState))Source
Run the compiler.
compileViaStr :: (Show from, Show to, CompilesTo from to) => CompileConfig -> (from -> Compile to) -> String -> IO (Either CompileError (String, CompileState))Source
Compile a Haskell source string to a JavaScript source string.
compileToAst :: (Show from, Show to, CompilesTo from to) => CompileConfig -> (from -> Compile to) -> String -> IO (Either CompileError (to, CompileState))Source
Compile a Haskell source string to a JavaScript source string.
compileFromStr :: (Parseable a, MonadError CompileError m) => (a -> m a1) -> String -> m a1Source
Compile from a string.
printCompile :: (Show from, Show to, CompilesTo from to) => CompileConfig -> (from -> Compile to) -> String -> IO ()Source
printTestCompile :: String -> IO ()Source
Compile a String of Fay and print it as beautified JavaScript.
compileModule :: Module -> Compile [JsStmt]Source
Compile Haskell module.
compileImport :: ImportDecl -> Compile [JsStmt]Source
Compile the given import.
compilePatBind :: Bool -> Maybe Type -> Decl -> Compile [JsStmt]Source
Compile a top-level pattern bind.
:: Name | Name of the to-be binding. |
-> String | The format string. |
-> Type | Type signature. |
-> Compile [JsStmt] |
Compile an FFI call.
:: String | The format string. |
-> [(JsParam, FundamentalType)] | Arguments. |
-> Compile String | The JS code. |
Format the FFI format string with the given arguments.
serialize :: FundamentalType -> JsExp -> JsExpSource
Serialize a value to native JS, if possible.
typeRep :: FundamentalType -> JsExpSource
Get a JS-representation of a fundamental type for encoding/decoding.
functionTypeArgs :: Type -> [FundamentalType]Source
Get arg types of a function type.
argType :: Type -> FundamentalTypeSource
Convert a Haskell type to an internal FFI representation.
compileNormalPatBind :: Bool -> Name -> Exp -> Compile [JsStmt]Source
Compile a normal simple pattern binding.
compileDataDecl :: Bool -> Decl -> [QualConDecl] -> Compile [JsStmt]Source
Compile a data declaration.
compileFunCase :: Bool -> [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.
flatten :: JsExp -> Maybe [JsExp]Source
Flatten an application expression into function : arg : arg : []
prettyPrintFile :: String -> IO StringSource
Format a JS file using js-beautify, or return the JS as-is if js-beautify is unavailable
compileRhs :: Rhs -> Compile JsExpSource
Compile a right-hand-side expression.
compileGuards :: [GuardedRhs] -> Compile JsExpSource
Compile guards
compileExp :: Exp -> Compile JsExpSource
Compile Haskell expression.
compileInfixApp :: Exp -> QOp -> Exp -> Compile JsExpSource
Compile an infix application, optimizing the JS cases.
compileList :: [Exp] -> Compile JsExpSource
Compile a list expression.
compileDoBlock :: [Stmt] -> Compile JsExpSource
Compile a do block.
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.
compilePLit :: JsExp -> Literal -> [JsStmt] -> Compile [JsStmt]Source
Compile a literal value from a pattern match.
compilePAsPat :: JsExp -> Name -> Pat -> [JsStmt] -> Compile [JsStmt]Source
Compile as binding in pattern match
compileRecConstr :: QName -> [FieldUpdate] -> Compile JsExpSource
Compile a record construction with named fields | GHC will warn on uninitialized fields, they will be undefined in JS.
equalExps :: JsExp -> JsExp -> JsExpSource
Equality test for two expressions, with some optimizations.
isConstant :: JsExp -> BoolSource
Is a JS expression a literal (constant)?
compilePApp :: QName -> [Pat] -> JsExp -> [JsStmt] -> Compile [JsStmt]Source
Compile a pattern application.
compileInfixPat :: JsExp -> Pat -> [JsStmt] -> Compile [JsStmt]Source
Compile an infix pattern (e.g. cons and tuples.)
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 :: FundamentalType -> JsExp -> JsExpSource
forceInlinable :: CompileConfig -> JsExp -> JsExpSource
Force an expression in a thunk.
resolveOpToVar :: QOp -> Compile ExpSource
Resolve operators to only built-in (for now) functions.
emitExport :: ExportSpec -> Compile ()Source
Emit exported names.
parseResult :: ((SrcLoc, String) -> b) -> (a -> b) -> ParseResult a -> bSource
Parse result.
config :: (CompileConfig -> a) -> Compile aSource
Get a config option.