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

Safe HaskellNone

Language.Fay.Compiler.Misc

Description

Miscellaneous functions used throughout the compiler.

Synopsis

Documentation

unname :: Name -> StringSource

Extra the string from an ident.

fayBuiltin :: String -> QNameSource

Make an identifier from the built-in HJ module.

thunk :: JsExp -> JsExpSource

Wrap an expression in a thunk.

stmtsThunk :: [JsStmt] -> JsExpSource

Wrap an expression in a thunk.

uniqueNames :: [JsName]Source

Generate unique names.

resolveName :: QName -> Compile QNameSource

Resolve a given maybe-qualified name to a fully qualifed name.

simpleImport :: NameScope -> BoolSource

Do have have a simple import X import on our hands?

qualify :: Name -> Compile QNameSource

Qualify a name for the current module.

bindToplevel :: SrcLoc -> Bool -> Name -> JsExp -> Compile JsStmtSource

Make a top-level binding.

withScope :: Compile a -> Compile aSource

Create a temporary scope and discard it after the given computation.

generateScope :: Compile a -> Compile ()Source

Run a compiler and just get the scope information.

bindVar :: Name -> Compile ()Source

Bind a variable in the current scope.

emitExport :: ExportSpec -> Compile ()Source

Emit exported names.

force :: JsExp -> JsExpSource

Force an expression in a thunk.

isConstant :: JsExp -> BoolSource

Is a JS expression a literal (constant)?

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

Extract the string from a qname. qname :: QName -> String qname (UnQual (Ident str)) = str qname (UnQual (Symbol sym)) = jsEncodeName sym qname i = error $ qname: Expected unqualified ident, found: ++ show i -- FIXME:

Deconstruct a parse result (a la maybe, foldr, either).

config :: (CompileConfig -> a) -> Compile aSource

Get a config option.

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?

withScopedTmpJsName :: (JsName -> Compile a) -> Compile aSource

Generate a temporary, SCOPED name for testing conditions and such.

withScopedTmpName :: (Name -> Compile a) -> Compile aSource

Generate a temporary, SCOPED name for testing conditions and such. We don't have name tracking yet, so instead we use this.