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

Safe HaskellNone



Main library entry point.



module Fay.Config

data CompileState Source

State of the compiler.




stateInterfaces :: Map ModuleName Symbols

Exported identifiers for all modules

stateRecordTypes :: [(QName, [QName])]

Map types to constructors

stateRecords :: [(QName, [Name])]

Map constructors to fields

stateNewtypes :: [(QName, Maybe QName, Type)]

Newtype constructor, destructor, wrapped type tuple

stateImported :: [(ModuleName, FilePath)]

Map of all imported modules and their source locations.

stateNameDepth :: Integer

Depth of the current lexical scope, used for creating unshadowing variables.

stateModuleName :: ModuleName

Name of the module currently being compiled.

stateJsModulePaths :: Set ModulePath

Module paths that have code generated for them.

stateUseFromString :: Bool

Use JS Strings instead of [Char] for string literals?

stateTypeSigs :: Map QName Type

Module level declarations having explicit type signatures

compileFile :: Config -> FilePath -> IO (Either CompileError String) Source

Compile the given file.

compileFileWithState :: Config -> FilePath -> IO (Either CompileError (String, Maybe [Mapping], CompileState)) Source

Compile a file returning the resulting internal state of the compiler. Don't use this directly, it's only exposed for the test suite.

compileFileWithResult :: Config -> FilePath -> IO (Either CompileError CompileResult) Source

Compile a file returning additional generated metadata.

compileFromTo :: Config -> FilePath -> Maybe FilePath -> IO () Source

Compile the given file and write the output to the given path, or if nothing given, stdout.

compileFromToAndGenerateHtml :: Config -> FilePath -> FilePath -> IO (Either CompileError String) Source

Compile the given file and write to the output, also generates HTML and sourcemap files if configured.

toJsName :: String -> String Source

Convert a Haskell filename to a JS filename.

showCompileError :: CompileError -> String Source

Print a compile error for human consumption.

getConfigRuntime :: Config -> IO String Source

Get the JS runtime source. This will return the user supplied runtime if it exists.

getRuntime :: IO String Source

Get the default JS runtime source.