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

Safe HaskellNone
LanguageHaskell98

Fay.Types

Description

All Fay types and instances.

Synopsis

Documentation

data JsLit Source

Literal value type.

Instances

data JsName Source

A name of some kind.

class Printable a where Source

Print some value.

Methods

printJS :: a -> Printer Source

data Fay a Source

The JavaScript FFI interfacing monad.

data CompileReader Source

Configuration and globals for the compiler.

Constructors

CompileReader 

Fields

readerConfig :: Config

The compilation configuration.

readerCompileLit :: Sign -> Literal -> Compile JsExp
 
readerCompileDecls :: Bool -> [Decl] -> Compile [JsStmt]
 

data CompileWriter Source

Things written out by the compiler.

Constructors

CompileWriter 

Fields

writerCons :: [JsStmt]

Constructors.

writerFayToJs :: [(String, JsExp)]

Fay to JS dispatchers.

writerJsToFay :: [(String, JsExp)]

JS to Fay dispatchers.

data Config Source

Configuration of the compiler. The fields with a leading underscore

Instances

Show Config Source 
Default Config Source

Default configuration.

data CompileState Source

State of the compiler.

Constructors

CompileState 

Fields

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

data FundamentalType Source

These are the data types that are serializable directly to native JS data types. Strings, floating points and arrays. The others are: actions 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.

data PrintState Source

The state of the pretty printer.

Constructors

PrintState 

Fields

psLine :: Int

The current line.

psColumn :: Int

Current column.

psIndentLevel :: Int

Current indentation level.

psNewline :: Bool

Just outputted a newline?

data PrintReader Source

Global options of the printer

Constructors

PrintReader 

Fields

prPretty :: Bool

Are we to pretty print?

prPrettyThunks :: Bool

Use pretty thunk names?

prPrettyOperators :: Bool

Use pretty operators?

defaultPrintReader :: PrintReader Source

default printer options (non-pretty printing)

data PrintWriter Source

Output of printer

Constructors

PrintWriter 

Fields

pwMappings :: [Mapping]

Source mappings.

pwOutput :: ShowS

The current output.

Instances

Monoid PrintWriter Source

Output concatenation

newtype Printer Source

The printer.

Instances

IsString Printer Source

Write out a string, updating the current position information.

Monoid Printer Source 

indented :: Printer -> Printer Source

Print the given printer indented.

askIf :: (PrintReader -> Bool) -> Printer -> Printer -> Printer Source

exec one of Printers depending on PrintReader property.

newline :: Printer Source

Output a newline and makes next line indented when prPretty is True. Does nothing when prPretty is False

write :: String -> Printer Source

Write out a raw string, respecting the indentation Note: if you pass a string with newline characters, it will print them out even if prPretty is set to False. Also next line won't be indented. If you want write a smart newline (that is the one which will be written out only if prPretty is true, and after which the line will be indented) use newline)

mapping :: SrcSpan -> Printer Source

Generate a mapping from the Haskell location to the current point in the output.

data SerializeContext Source

The serialization context indicates whether we're currently serializing some value or a particular field in a user-defined data type.

data ModulePath Source

The name of a module split into a list for code generation.

mkModulePath :: ModuleName a -> ModulePath Source

Construct the complete ModulePath from a ModuleName.

mkModulePaths :: ModuleName a -> [ModulePath] Source

Construct intermediate module paths from a ModuleName. mkModulePaths A.B => [[A], [A,B]]

mkModulePathFromQName :: QName a -> ModulePath Source

Converting a QName to a ModulePath is only relevant for constructors since they can conflict with module names.