fay-0.1.1.0: A compiler for Fay, a Haskell subset that compiles to JavaScript.

Safe HaskellSafe-Infered

Language.Fay

Description

The Haskell→Javascript compiler.

Synopsis

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.

compileFFI :: Type -> Name -> (String, String, String) -> JsExp -> [JsName] -> [JsName] -> Compile [JsStmt]Source

Compile an FFI call.

data ArgType Source

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.

Instances

serialize :: ArgType -> JsExp -> JsExpSource

Serialize a value to native JS, if possible.

functionTypeArgs :: Type -> [ArgType]Source

Get arg types of a function type.

typeArity :: Type -> IntegerSource

Get the arity of a type.

compileFunCase :: [Match] -> Compile [JsStmt]Source

Compile a function which pattern matches (causing a case analysis).

optimizeTailCallsSource

Arguments

:: [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.

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.

compileGuardedAlt :: GuardedAlts -> Compile JsExpSource

Compile a guarded alt.

compileLet :: [Decl] -> Exp -> Compile JsExpSource

Compile a let expression.

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.

throw :: String -> JsExp -> JsStmtSource

Throw a JS exception.

throwExp :: String -> JsExp -> JsExpSource

Throw a JS exception (in an expression).

isWildCardAlt :: Alt -> BoolSource

Is an alt a wildcard?

isWildCardPat :: Pat -> BoolSource

Is a pattern a wildcard?

tmpName :: JsExp -> JsNameSource

A temporary name for testing conditions and such.

thunk :: JsExp -> JsExpSource

Wrap an expression in a thunk.

monad :: JsExp -> JsExpSource

Wrap an expression in a thunk.

stmtsThunk :: [JsStmt] -> JsExpSource

Wrap an expression in a thunk.

force :: JsExp -> JsExpSource

Force an expression in a thunk.

forceInlinable :: Config -> JsExp -> JsExpSource

Force an expression in a thunk.

resolveOpToVar :: QOp -> Compile ExpSource

Resolve operators to only built-in (for now) functions.

hjIdent :: String -> QNameSource

Make an identifier from the built-in HJ module.

parseResult :: ((SrcLoc, String) -> b) -> (a -> b) -> ParseResult a -> bSource

Parse result.