-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | PureScript Programming Language Compiler
--
-- A small compile-to-JS language with extensible records and type-safe
-- blocks
@package purescript
@version 0.4.19
-- | Common pretty-printing utility functions
module Language.PureScript.Pretty.Common
-- | Wrap a string in parentheses
parens :: String -> String
newtype PrinterState
PrinterState :: Int -> PrinterState
indent :: PrinterState -> Int
-- | Number of characters per identation level
blockIndent :: Int
-- | Pretty print with a new indentation level
withIndent :: StateT PrinterState Maybe String -> StateT PrinterState Maybe String
-- | Get the current indentation level
currentIndent :: StateT PrinterState Maybe String
-- | Print many lines
prettyPrintMany :: (a -> StateT PrinterState Maybe String) -> [a] -> StateT PrinterState Maybe String
instance Show PrinterState
instance Eq PrinterState
instance Ord PrinterState
-- | State for the parser monad
module Language.PureScript.Parser.State
-- | State for the parser monad
data ParseState
ParseState :: Column -> ParseState
-- | The most recently marked indentation level
indentationLevel :: ParseState -> Column
instance Show ParseState
-- | Code generation monad
--
-- This monad provides a supply of fresh names which can be used to
-- create variables.
module Language.PureScript.CodeGen.Monad
-- | Code generation monad data type
newtype Gen a
Gen :: State [String] a -> Gen a
unGen :: Gen a -> State [String] a
-- | Run a computation in the code generation monad
runGen :: [String] -> Gen a -> a
-- | Generate a fresh name
fresh :: Gen String
instance Functor Gen
instance Applicative Gen
instance Monad Gen
instance MonadState [String] Gen
-- | Common functions for implementing generic traversals
module Language.PureScript.Traversals
fstM :: Functor f => (a -> f c) -> (a, b) -> f (c, b)
sndM :: Functor f => (b -> f c) -> (a, b) -> f (a, c)
thirdM :: Functor f => (c -> f d) -> (a, b, c) -> f (a, b, d)
maybeM :: Applicative f => (a -> f b) -> Maybe a -> f (Maybe b)
defS :: Monad m => st -> val -> m (st, val)
-- | Data types for the intermediate simplified-Javascript AST
module Language.PureScript.CodeGen.JS.AST
-- | Built-in unary operators
data UnaryOperator
-- | Numeric negation
Negate :: UnaryOperator
-- | Boolean negation
Not :: UnaryOperator
-- | Bitwise negation
BitwiseNot :: UnaryOperator
-- | Numeric unary 'plus'
Positive :: UnaryOperator
-- | Built-in binary operators
data BinaryOperator
-- | Numeric addition
Add :: BinaryOperator
-- | Numeric subtraction
Subtract :: BinaryOperator
-- | Numeric multiplication
Multiply :: BinaryOperator
-- | Numeric division
Divide :: BinaryOperator
-- | Remainder
Modulus :: BinaryOperator
-- | Generic equality test
EqualTo :: BinaryOperator
-- | Generic inequality test
NotEqualTo :: BinaryOperator
-- | Numeric less-than
LessThan :: BinaryOperator
-- | Numeric less-than-or-equal
LessThanOrEqualTo :: BinaryOperator
-- | Numeric greater-than
GreaterThan :: BinaryOperator
-- | Numeric greater-than-or-equal
GreaterThanOrEqualTo :: BinaryOperator
-- | Boolean and
And :: BinaryOperator
-- | Boolean or
Or :: BinaryOperator
-- | Bitwise and
BitwiseAnd :: BinaryOperator
-- | Bitwise or
BitwiseOr :: BinaryOperator
-- | Bitwise xor
BitwiseXor :: BinaryOperator
-- | Bitwise left shift
ShiftLeft :: BinaryOperator
-- | Bitwise right shift
ShiftRight :: BinaryOperator
-- | Bitwise right shift with zero-fill
ZeroFillShiftRight :: BinaryOperator
-- | Data type for simplified Javascript expressions
data JS
-- | A numeric literal
JSNumericLiteral :: (Either Integer Double) -> JS
-- | A string literal
JSStringLiteral :: String -> JS
-- | A boolean literal
JSBooleanLiteral :: Bool -> JS
-- | A unary operator application
JSUnary :: UnaryOperator -> JS -> JS
-- | A binary operator application
JSBinary :: BinaryOperator -> JS -> JS -> JS
-- | An array literal
JSArrayLiteral :: [JS] -> JS
-- | An array indexer expression
JSIndexer :: JS -> JS -> JS
-- | An object literal
JSObjectLiteral :: [(String, JS)] -> JS
-- | An object property accessor expression
JSAccessor :: String -> JS -> JS
-- | A function introduction (optional name, arguments, body)
JSFunction :: (Maybe String) -> [String] -> JS -> JS
-- | Function application
JSApp :: JS -> [JS] -> JS
-- | Variable
JSVar :: String -> JS
-- | Conditional expression
JSConditional :: JS -> JS -> JS -> JS
-- | A block of expressions in braces
JSBlock :: [JS] -> JS
-- | A variable introduction and optional initialization
JSVariableIntroduction :: String -> (Maybe JS) -> JS
-- | A variable assignment
JSAssignment :: JS -> JS -> JS
-- | While loop
JSWhile :: JS -> JS -> JS
-- | For loop
JSFor :: String -> JS -> JS -> JS -> JS
-- | ForIn loop
JSForIn :: String -> JS -> JS -> JS
-- | If-then-else statement
JSIfElse :: JS -> JS -> (Maybe JS) -> JS
-- | Return statement
JSReturn :: JS -> JS
-- | Throw statement
JSThrow :: JS -> JS
-- | Type-Of operator
JSTypeOf :: JS -> JS
-- | Labelled statement
JSLabel :: String -> JS -> JS
-- | Break statement
JSBreak :: String -> JS
-- | Continue statement
JSContinue :: String -> JS
-- | Raw Javascript (generated when parsing fails for an inline foreign
-- import declaration)
JSRaw :: String -> JS
everywhereOnJS :: (JS -> JS) -> JS -> JS
everywhereOnJSTopDown :: (JS -> JS) -> JS -> JS
everythingOnJS :: (r -> r -> r) -> (JS -> r) -> JS -> r
instance Typeable UnaryOperator
instance Typeable BinaryOperator
instance Typeable JS
instance Show UnaryOperator
instance Eq UnaryOperator
instance Data UnaryOperator
instance Show BinaryOperator
instance Eq BinaryOperator
instance Data BinaryOperator
instance Show JS
instance Eq JS
instance Data JS
-- | Common functions used by the various optimizer phases
module Language.PureScript.Optimizer.Common
applyAll :: [a -> a] -> a -> a
replaceIdent :: String -> JS -> JS -> JS
replaceIdents :: [(String, JS)] -> JS -> JS
isReassigned :: String -> JS -> Bool
isRebound :: JS -> JS -> Bool
isUsed :: String -> JS -> Bool
targetVariable :: JS -> String
isUpdated :: String -> JS -> Bool
removeFromBlock :: ([JS] -> [JS]) -> JS -> JS
-- | Removes unused variables
module Language.PureScript.Optimizer.Unused
removeUnusedVariables :: JS -> JS
removeCodeAfterReturnStatements :: JS -> JS
-- | Optimizer steps for simplifying Javascript blocks
module Language.PureScript.Optimizer.Blocks
-- | Collapse blocks which appear nested directly below another block
collapseNestedBlocks :: JS -> JS
-- | Various constants which refer to things in the Prelude
module Language.PureScript.Constants
($) :: String
(#) :: String
(++) :: String
(>>=) :: String
(+) :: String
(-) :: String
(*) :: String
(/) :: String
(%) :: String
(<) :: String
(>) :: String
(<=) :: String
(>=) :: String
(==) :: String
(/=) :: String
(&) :: String
bar :: String
(^) :: String
(&&) :: String
(||) :: String
unsafeIndex :: String
negate :: String
shl :: String
shr :: String
zshr :: String
complement :: String
not :: String
return :: String
returnEscaped :: String
untilE :: String
whileE :: String
runST :: String
runSTArray :: String
stRefValue :: String
newSTRef :: String
readSTRef :: String
writeSTRef :: String
modifySTRef :: String
peekSTArray :: String
pokeSTArray :: String
monadEffDictionary :: String
bindEffDictionary :: String
numNumber :: String
ordNumber :: String
eqNumber :: String
eqString :: String
eqBoolean :: String
bitsNumber :: String
boolLikeBoolean :: String
semigroupString :: String
main :: String
__superclasses :: String
prim :: String
prelude :: String
preludeUnsafe :: String
eff :: String
st :: String
-- | The data type of compiler options
module Language.PureScript.Options
-- | The data type of compiler options
data Options
Options :: Bool -> Bool -> Bool -> Bool -> Maybe String -> Bool -> Maybe String -> [String] -> [String] -> Bool -> Options
-- | Disable inclusion of the built in Prelude
optionsNoPrelude :: Options -> Bool
-- | Disable tail-call elimination
optionsNoTco :: Options -> Bool
-- | Perform type checks at runtime
optionsPerformRuntimeTypeChecks :: Options -> Bool
-- | Disable inlining of calls to return and bind for the Eff monad
optionsNoMagicDo :: Options -> Bool
-- | When specified, checks the type of main in the module, and
-- generate a call to run main after the module definitions.
optionsMain :: Options -> Maybe String
-- | Skip all optimizations
optionsNoOptimizations :: Options -> Bool
-- | Specify the namespace that PureScript modules will be exported to when
-- running in the browser.
optionsBrowserNamespace :: Options -> Maybe String
-- | The modules to keep while enabling dead code elimination
optionsModules :: Options -> [String]
-- | The modules to code gen
optionsCodeGenModules :: Options -> [String]
-- | Verbose error message
optionsVerboseErrors :: Options -> Bool
-- | Default compiler options
defaultOptions :: Options
instance Show Options
-- | This module implements tail call elimination.
module Language.PureScript.Optimizer.TCO
-- | Eliminate tail calls
tco :: Options -> JS -> JS
-- | Data types for names
module Language.PureScript.Names
-- | Names for value identifiers
data Ident
-- | An alphanumeric identifier
Ident :: String -> Ident
-- | A symbolic name for an infix operator
Op :: String -> Ident
runIdent :: Ident -> String
-- | Proper names, i.e. capitalized names for e.g. module names,
-- typedata constructors.
newtype ProperName
ProperName :: String -> ProperName
runProperName :: ProperName -> String
-- | Module names
data ModuleName
ModuleName :: [ProperName] -> ModuleName
runModuleName :: ModuleName -> String
moduleNameFromString :: String -> ModuleName
-- | A qualified name, i.e. a name with an optional module name
data Qualified a
Qualified :: (Maybe ModuleName) -> a -> Qualified a
-- | Provide a default module name, if a name is unqualified
qualify :: ModuleName -> Qualified a -> (ModuleName, a)
instance Typeable Ident
instance Typeable ProperName
instance Typeable ModuleName
instance Typeable1 Qualified
instance Eq Ident
instance Ord Ident
instance Data Ident
instance Eq ProperName
instance Ord ProperName
instance Data ProperName
instance Eq ModuleName
instance Ord ModuleName
instance Data ModuleName
instance Eq a => Eq (Qualified a)
instance Ord a => Ord (Qualified a)
instance Data a => Data (Qualified a)
instance Show a => Show (Qualified a)
instance Show ModuleName
instance Show ProperName
instance Show Ident
-- | Common code generation utility functions
module Language.PureScript.CodeGen.Common
-- | Convert an Ident into a valid Javascript identifier:
--
--
-- - Alphanumeric characters are kept unmodified.
-- - Reserved javascript identifiers are prefixed with
-- $$.
-- - Symbols are prefixed with $ followed by a symbol name or
-- their ordinal value.
--
identToJs :: Ident -> String
-- | Attempts to find a human-readable name for a symbol, if none has been
-- specified returns the ordinal value.
identCharToString :: Char -> String
-- | Checks whether an identifier name is reserved in Javascript.
nameIsJsReserved :: String -> Bool
-- | Test if a string is a valid JS identifier (may return false negatives)
isIdent :: String -> Bool
moduleNameToJs :: ModuleName -> String
-- | This module implements the Magic Do optimization, which inlines
-- calls to return and bind for the Eff monad, as well as some of its
-- actions.
module Language.PureScript.Optimizer.MagicDo
magicDo :: Options -> JS -> JS
-- | This module provides basic inlining capabilities
module Language.PureScript.Optimizer.Inliner
inlineVariables :: JS -> JS
inlineOperator :: (String, String) -> (JS -> JS -> JS) -> JS -> JS
inlineCommonOperators :: JS -> JS
etaConvert :: JS -> JS
unThunk :: JS -> JS
evaluateIifes :: JS -> JS
-- | This module optimizes code in the simplified-Javascript intermediate
-- representation.
--
-- The following optimizations are supported:
--
--
-- - Collapsing nested blocks
-- - Tail call elimination
-- - Inlining of (>>=) and ret for the Eff monad
-- - Removal of unused variables
-- - Removal of unnecessary thunks
-- - Eta conversion
-- - Inlining variables
-- - Inline Prelude.($), Prelude.(#), Prelude.(++), Prelude.(!!)
-- - Inlining primitive Javascript operators
--
module Language.PureScript.Optimizer
-- | Apply a series of optimizer passes to simplified Javascript code
optimize :: Options -> JS -> JS
-- | Constants, and utility functions to be used when parsing
module Language.PureScript.Parser.Common
-- | A list of purescript reserved identifiers
reservedPsNames :: [String]
-- | A list of reserved identifiers for types
reservedTypeNames :: [String]
-- | A list of reserved operators
reservedOpNames :: [String]
-- | Valid first characters for an identifier
identStart :: Parsec String u Char
-- | Valid identifier characters
identLetter :: Parsec String u Char
-- | Valid first characters for an operator
opStart :: Parsec String u Char
-- | Valid operators characters
opLetter :: Parsec String u Char
-- | The PureScript language definition
langDef :: GenLanguageDef String u Identity
-- | A token parser based on the language definition
tokenParser :: GenTokenParser String u Identity
-- | Parse a token
lexeme :: Parsec String u a -> Parsec String u a
-- | Parse an identifier
identifier :: Parsec String u String
-- | Parse a reserved word
reserved :: String -> Parsec String u ()
-- | Parse a reserved operator
reservedOp :: String -> Parsec String u ()
-- | Parse an operator
operator :: Parsec String u String
-- | Parse a string literal
stringLiteral :: Parsec String u String
-- | Parse whitespace
whiteSpace :: Parsec String u ()
-- | Semicolon
semi :: Parsec String u String
-- | Colon
colon :: Parsec String u String
-- | Period
dot :: Parsec String u String
-- | Comma
comma :: Parsec String u String
-- | Backtick
tick :: Parsec String u Char
-- | Pipe character
pipe :: Parsec String u Char
-- | Natural number
natural :: Parsec String u Integer
-- | Parse a proper name
properName :: Parsec String u ProperName
-- | Parse a module name
moduleName :: Parsec String ParseState ModuleName
-- | Parse a qualified name, i.e. M.name or just name
parseQualified :: Parsec String ParseState a -> Parsec String ParseState (Qualified a)
-- | Parse an integer or floating point value
integerOrFloat :: Parsec String u (Either Integer Double)
-- | Parse an identifier or parenthesized operator
parseIdent :: Parsec String ParseState Ident
-- | Parse a token inside square brackets
squares :: Parsec String ParseState a -> Parsec String ParseState a
-- | Parse a token inside parentheses
parens :: Parsec String ParseState a -> Parsec String ParseState a
-- | Parse a token inside braces
braces :: Parsec String ParseState a -> Parsec String ParseState a
-- | Parse a token inside angle brackets
angles :: Parsec String ParseState a -> Parsec String ParseState a
-- | Parse zero or more values separated by a separator token
sepBy :: Parsec String ParseState a -> Parsec String ParseState sep -> Parsec String ParseState [a]
-- | Parse one or more values separated by a separator token
sepBy1 :: Parsec String ParseState a -> Parsec String ParseState sep -> Parsec String ParseState [a]
-- | Parse zero or more values separated by semicolons
semiSep :: Parsec String ParseState a -> Parsec String ParseState [a]
-- | Parse one or more values separated by semicolons
semiSep1 :: Parsec String ParseState a -> Parsec String ParseState [a]
-- | Parse zero or more values separated by commas
commaSep :: Parsec String ParseState a -> Parsec String ParseState [a]
-- | Parse one or more values separated by commas
commaSep1 :: Parsec String ParseState a -> Parsec String ParseState [a]
-- | Run the first parser, then match the second if possible, applying the
-- specified function on a successful match
augment :: Stream s m t => ParsecT s u m a -> ParsecT s u m b -> (a -> b -> a) -> ParsecT s u m a
-- | Run the first parser, then match the second zero or more times,
-- applying the specified function for each match
fold :: Stream s m t => ParsecT s u m a -> ParsecT s u m b -> (a -> b -> a) -> ParsecT s u m a
-- | Build a parser from a smaller parser and a list of parsers for postfix
-- operators
buildPostfixParser :: Stream s m t => [a -> ParsecT s u m a] -> ParsecT s u m a -> ParsecT s u m a
-- | Parse an identifier in backticks or an operator
parseIdentInfix :: Parsec String ParseState (Qualified Ident)
-- | Mark the current indentation level
mark :: Parsec String ParseState a -> Parsec String ParseState a
-- | Check that the current identation level matches a predicate
checkIndentation :: (Column -> Column -> Bool) -> Parsec String ParseState ()
-- | Check that the current indentation level is past the current mark
indented :: Parsec String ParseState ()
-- | Check that the current indentation level is at the same indentation as
-- the current mark
same :: Parsec String ParseState ()
-- | Run a parser which supports indentation
runIndentParser :: FilePath -> Parsec String ParseState a -> String -> Either ParseError a
module Language.PureScript.Kinds
-- | The data type of kinds
data Kind
-- | Unification variable of type Kind
KUnknown :: Unknown -> Kind
-- | The kind of types
Star :: Kind
-- | The kind of effects
Bang :: Kind
-- | Kinds for labelled, unordered rows without duplicates
Row :: Kind -> Kind
-- | Function kinds
FunKind :: Kind -> Kind -> Kind
everywhereOnKinds :: (Kind -> Kind) -> Kind -> Kind
everythingOnKinds :: (r -> r -> r) -> (Kind -> r) -> Kind -> r
instance Typeable Kind
instance Show Kind
instance Eq Kind
instance Data Kind
-- | A parser for kinds
module Language.PureScript.Parser.Kinds
-- | Parse a kind
parseKind :: Parsec String ParseState Kind
-- | Pretty printer for kinds
module Language.PureScript.Pretty.Kinds
-- | Generate a pretty-printed string representing a Kind
prettyPrintKind :: Kind -> String
-- | Data types for types
module Language.PureScript.Types
-- | An identifier for the scope of a skolem variable
newtype SkolemScope
SkolemScope :: Int -> SkolemScope
runSkolemScope :: SkolemScope -> Int
-- | The type of types
data Type
-- | A unification variable of type Type
TUnknown :: Unknown -> Type
-- | A named type variable
TypeVar :: String -> Type
-- | A type constructor
TypeConstructor :: (Qualified ProperName) -> Type
-- | A type application
TypeApp :: Type -> Type -> Type
-- | A type synonym which is "saturated", i.e. fully applied
SaturatedTypeSynonym :: (Qualified ProperName) -> [Type] -> Type
-- | Forall quantifier
ForAll :: String -> Type -> (Maybe SkolemScope) -> Type
-- | A type with a set of type class constraints
ConstrainedType :: [(Qualified ProperName, [Type])] -> Type -> Type
-- | A skolem constant
Skolem :: String -> Int -> SkolemScope -> Type
-- | An empty row
REmpty :: Type
-- | A non-empty row
RCons :: String -> Type -> Type -> Type
-- | A placeholder used in pretty printing
PrettyPrintFunction :: Type -> Type -> Type
-- | A placeholder used in pretty printing
PrettyPrintArray :: Type -> Type
-- | A placeholder used in pretty printing
PrettyPrintObject :: Type -> Type
-- | A placeholder used in pretty printing
PrettyPrintForAll :: [String] -> Type -> Type
-- | Convert a row to a list of pairs of labels and types
rowToList :: Type -> ([(String, Type)], Type)
-- | Convert a list of labels and types to a row
rowFromList :: ([(String, Type)], Type) -> Type
-- | Check whether a type is a monotype
isMonoType :: Type -> Bool
-- | Universally quantify a type
mkForAll :: [String] -> Type -> Type
-- | Replace a type variable, taking into account variable shadowing
replaceTypeVars :: String -> Type -> Type -> Type
-- | Replace named type variables with types
replaceAllTypeVars :: [(String, Type)] -> Type -> Type
-- | Collect all type variables appearing in a type
usedTypeVariables :: Type -> [String]
-- | Collect all free type variables appearing in a type
freeTypeVariables :: Type -> [String]
-- | Universally quantify over all type variables appearing free in a type
quantify :: Type -> Type
-- | Move all universal quantifiers to the front of a type
moveQuantifiersToFront :: Type -> Type
everywhereOnTypes :: (Type -> Type) -> Type -> Type
everywhereOnTypesTopDown :: (Type -> Type) -> Type -> Type
everywhereOnTypesM :: (Functor m, Applicative m, Monad m) => (Type -> m Type) -> Type -> m Type
everywhereOnTypesTopDownM :: (Functor m, Applicative m, Monad m) => (Type -> m Type) -> Type -> m Type
everythingOnTypes :: (r -> r -> r) -> (Type -> r) -> Type -> r
instance Typeable SkolemScope
instance Typeable Type
instance Show SkolemScope
instance Eq SkolemScope
instance Ord SkolemScope
instance Data SkolemScope
instance Show Type
instance Eq Type
instance Data Type
module Language.PureScript.TypeClassDictionaries
-- | Data representing a type class dictionary which is in scope
data TypeClassDictionaryInScope
TypeClassDictionaryInScope :: Qualified Ident -> Qualified ProperName -> [Type] -> Maybe [(Qualified ProperName, [Type])] -> TypeClassDictionaryType -> TypeClassDictionaryInScope
-- | The identifier with which the dictionary can be accessed at runtime
tcdName :: TypeClassDictionaryInScope -> Qualified Ident
-- | The name of the type class to which this type class instance applies
tcdClassName :: TypeClassDictionaryInScope -> Qualified ProperName
-- | The types to which this type class instance applies
tcdInstanceTypes :: TypeClassDictionaryInScope -> [Type]
-- | Type class dependencies which must be satisfied to construct this
-- dictionary
tcdDependencies :: TypeClassDictionaryInScope -> Maybe [(Qualified ProperName, [Type])]
-- | The type of this dictionary
tcdType :: TypeClassDictionaryInScope -> TypeClassDictionaryType
-- | The type of a type class dictionary
data TypeClassDictionaryType
-- | A regular type class dictionary
TCDRegular :: TypeClassDictionaryType
-- | A type class dictionary which is an alias for an imported dictionary
-- from another module
TCDAlias :: (Qualified Ident) -> TypeClassDictionaryType
instance Typeable TypeClassDictionaryType
instance Typeable TypeClassDictionaryInScope
instance Show TypeClassDictionaryType
instance Eq TypeClassDictionaryType
instance Data TypeClassDictionaryType
instance Show TypeClassDictionaryInScope
instance Data TypeClassDictionaryInScope
module Language.PureScript.Environment
-- | The Environment defines all values and types which are
-- currently in scope:
data Environment
Environment :: Map (ModuleName, Ident) (Type, NameKind) -> Map (Qualified ProperName) (Kind, TypeKind) -> Map (Qualified ProperName) (ProperName, Type) -> Map (Qualified ProperName) ([String], Type) -> [TypeClassDictionaryInScope] -> Map (Qualified ProperName) ([String], [(Ident, Type)], [(Qualified ProperName, [Type])]) -> Environment
-- | Value names currently in scope
names :: Environment -> Map (ModuleName, Ident) (Type, NameKind)
-- | Type names currently in scope
types :: Environment -> Map (Qualified ProperName) (Kind, TypeKind)
-- | Data constructors currently in scope, along with their associated data
-- type constructors
dataConstructors :: Environment -> Map (Qualified ProperName) (ProperName, Type)
-- | Type synonyms currently in scope
typeSynonyms :: Environment -> Map (Qualified ProperName) ([String], Type)
-- | Available type class dictionaries
typeClassDictionaries :: Environment -> [TypeClassDictionaryInScope]
-- | Type classes
typeClasses :: Environment -> Map (Qualified ProperName) ([String], [(Ident, Type)], [(Qualified ProperName, [Type])])
-- | The initial environment with no values and only the default javascript
-- types defined
initEnvironment :: Environment
-- | The type of a foreign import
data ForeignImportType
-- | A regular foreign import
ForeignImport :: ForeignImportType
-- | A foreign import which contains inline Javascript as a string literal
InlineJavascript :: ForeignImportType
-- | A type class dictionary member accessor import, generated during
-- desugaring of type class declarations
TypeClassAccessorImport :: ForeignImportType
-- | The kind of a name
data NameKind
-- | A value introduced as a binding in a module
Value :: NameKind
-- | A foreign import
Extern :: ForeignImportType -> NameKind
-- | A local name introduced using a lambda abstraction, variable
-- introduction or binder
LocalVariable :: NameKind
-- | A data constructor
DataConstructor :: NameKind
-- | A type class dictionary, generated during desugaring of type class
-- declarations
TypeInstanceDictionaryValue :: NameKind
-- | The kinds of a type
data TypeKind
-- | Data type
DataType :: [String] -> [(ProperName, [Type])] -> TypeKind
-- | Type synonym
TypeSynonym :: TypeKind
-- | Foreign data
ExternData :: TypeKind
-- | A local type variable
LocalTypeVariable :: TypeKind
-- | Construct a ProperName in the Prim module
primName :: String -> Qualified ProperName
-- | Construct a type in the Prim module
primTy :: String -> Type
-- | Type constructor for functions
tyFunction :: Type
-- | Type constructor for strings
tyString :: Type
-- | Type constructor for numbers
tyNumber :: Type
-- | Type constructor for booleans
tyBoolean :: Type
-- | Type constructor for arrays
tyArray :: Type
-- | Type constructor for objects
tyObject :: Type
-- | Smart constructor for function types
function :: Type -> Type -> Type
-- | The primitive types in the external javascript environment with their
-- associated kinds.
primTypes :: Map (Qualified ProperName) (Kind, TypeKind)
instance Typeable ForeignImportType
instance Typeable NameKind
instance Typeable TypeKind
instance Show ForeignImportType
instance Eq ForeignImportType
instance Data ForeignImportType
instance Show NameKind
instance Eq NameKind
instance Data NameKind
instance Show TypeKind
instance Eq TypeKind
instance Data TypeKind
instance Show Environment
-- | Data types for modules and declarations
module Language.PureScript.Declarations
-- | A precedence level for an infix operator
type Precedence = Integer
-- | Associativity for infix operators
data Associativity
Infixl :: Associativity
Infixr :: Associativity
Infix :: Associativity
-- | Source position information
data SourcePos
SourcePos :: String -> Int -> Int -> SourcePos
-- | Source name
sourceName :: SourcePos -> String
-- | Line number
sourcePosLine :: SourcePos -> Int
-- | Column number
sourcePosColumn :: SourcePos -> Int
-- | Fixity data for infix operators
data Fixity
Fixity :: Associativity -> Precedence -> Fixity
-- | A module declaration, consisting of a module name, a list of
-- declarations, and a list of the declarations that are explicitly
-- exported. If the export list is Nothing, everything is exported.
data Module
Module :: ModuleName -> [Declaration] -> (Maybe [DeclarationRef]) -> Module
-- | An item in a list of explicit imports or exports
data DeclarationRef
-- | A type constructor with data constructors
TypeRef :: ProperName -> (Maybe [ProperName]) -> DeclarationRef
-- | A value
ValueRef :: Ident -> DeclarationRef
-- | A type class
TypeClassRef :: ProperName -> DeclarationRef
-- | A type class instance, created during typeclass desugaring (name,
-- class name, instance types)
TypeInstanceRef :: Ident -> DeclarationRef
-- | A declaration reference with source position information
PositionedDeclarationRef :: SourcePos -> DeclarationRef -> DeclarationRef
-- | The data type of declarations
data Declaration
-- | A data type declaration (name, arguments, data constructors)
DataDeclaration :: ProperName -> [String] -> [(ProperName, [Type])] -> Declaration
-- | A minimal mutually recursive set of data type declarations
DataBindingGroupDeclaration :: [Declaration] -> Declaration
-- | A type synonym declaration (name, arguments, type)
TypeSynonymDeclaration :: ProperName -> [String] -> Type -> Declaration
-- | A type declaration for a value (name, ty)
TypeDeclaration :: Ident -> Type -> Declaration
-- | A value declaration (name, top-level binders, optional guard, value)
ValueDeclaration :: Ident -> NameKind -> [Binder] -> (Maybe Guard) -> Value -> Declaration
-- | A minimal mutually recursive set of value declarations
BindingGroupDeclaration :: [(Ident, NameKind, Value)] -> Declaration
-- | A foreign import declaration (type, name, optional inline Javascript,
-- type)
ExternDeclaration :: ForeignImportType -> Ident -> (Maybe JS) -> Type -> Declaration
-- | A data type foreign import (name, kind)
ExternDataDeclaration :: ProperName -> Kind -> Declaration
-- | A type class instance foreign import
ExternInstanceDeclaration :: Ident -> [(Qualified ProperName, [Type])] -> (Qualified ProperName) -> [Type] -> Declaration
-- | A fixity declaration (fixity data, operator name)
FixityDeclaration :: Fixity -> String -> Declaration
-- | A module import (module name, optional set of identifiers to import,
-- optional qualified as name)
ImportDeclaration :: ModuleName -> (Maybe [DeclarationRef]) -> (Maybe ModuleName) -> Declaration
-- | A type class declaration (name, argument, implies, member
-- declarations)
TypeClassDeclaration :: ProperName -> [String] -> [(Qualified ProperName, [Type])] -> [Declaration] -> Declaration
-- | A type instance declaration (name, dependencies, class name, instance
-- types, member declarations)
TypeInstanceDeclaration :: Ident -> [(Qualified ProperName, [Type])] -> (Qualified ProperName) -> [Type] -> [Declaration] -> Declaration
-- | A declaration with source position information
PositionedDeclaration :: SourcePos -> Declaration -> Declaration
-- | Test if a declaration is a value declaration
isValueDecl :: Declaration -> Bool
-- | Test if a declaration is a data type or type synonym declaration
isDataDecl :: Declaration -> Bool
-- | Test if a declaration is a module import
isImportDecl :: Declaration -> Bool
-- | Test if a declaration is a data type foreign import
isExternDataDecl :: Declaration -> Bool
-- | Test if a declaration is a type class instance foreign import
isExternInstanceDecl :: Declaration -> Bool
-- | Test if a declaration is a fixity declaration
isFixityDecl :: Declaration -> Bool
-- | Test if a declaration is a foreign import
isExternDecl :: Declaration -> Bool
-- | Test if a declaration is a type class or instance declaration
isTypeClassDeclaration :: Declaration -> Bool
-- | A guard is just a boolean-valued expression that appears alongside a
-- set of binders
type Guard = Value
-- | Data type for values
data Value
-- | A numeric literal
NumericLiteral :: (Either Integer Double) -> Value
-- | A string literal
StringLiteral :: String -> Value
-- | A boolean literal
BooleanLiteral :: Bool -> Value
-- | A prefix -, will be desugared
UnaryMinus :: Value -> Value
-- | Binary operator application. During the rebracketing phase of
-- desugaring, this data constructor will be removed.
BinaryNoParens :: (Qualified Ident) -> Value -> Value -> Value
-- | Explicit parentheses. During the rebracketing phase of desugaring,
-- this data constructor will be removed.
Parens :: Value -> Value
-- | An array literal
ArrayLiteral :: [Value] -> Value
-- | An object literal
ObjectLiteral :: [(String, Value)] -> Value
-- | An record property accessor expression
Accessor :: String -> Value -> Value
-- | Partial record update
ObjectUpdate :: Value -> [(String, Value)] -> Value
-- | Function introduction
Abs :: (Either Ident Binder) -> Value -> Value
-- | Function application
App :: Value -> Value -> Value
-- | Variable
Var :: (Qualified Ident) -> Value
-- | Conditional (if-then-else expression)
IfThenElse :: Value -> Value -> Value -> Value
-- | A data constructor
Constructor :: (Qualified ProperName) -> Value
-- | A case expression. During the case expansion phase of desugaring,
-- top-level binders will get desugared into case expressions, hence the
-- need for guards and multiple binders per branch here.
Case :: [Value] -> [CaseAlternative] -> Value
-- | A value with a type annotation
TypedValue :: Bool -> Value -> Type -> Value
-- | A let binding
Let :: [Declaration] -> Value -> Value
-- | A do-notation block
Do :: [DoNotationElement] -> Value
-- | A placeholder for a type class dictionary to be inserted later. At the
-- end of type checking, these placeholders will be replaced with actual
-- expressions representing type classes dictionaries which can be
-- evaluated at runtime. The constructor arguments represent (in order):
-- whether or not to look at superclass implementations when searching
-- for a dictionary, the type class name and instance type, and the type
-- class dictionaries in scope.
TypeClassDictionary :: Bool -> (Qualified ProperName, [Type]) -> [TypeClassDictionaryInScope] -> Value
-- | A placeholder for a superclass dictionary to be turned into a
-- TypeClassDictionary during typechecking
SuperClassDictionary :: (Qualified ProperName) -> [Type] -> Value
-- | A value with source position information
PositionedValue :: SourcePos -> Value -> Value
-- | An alternative in a case statement
data CaseAlternative
CaseAlternative :: [Binder] -> Maybe Guard -> Value -> CaseAlternative
-- | A collection of binders with which to match the inputs
caseAlternativeBinders :: CaseAlternative -> [Binder]
-- | An optional guard
caseAlternativeGuard :: CaseAlternative -> Maybe Guard
-- | The result expression
caseAlternativeResult :: CaseAlternative -> Value
-- | Find the original dictionary which a type class dictionary in scope
-- refers to
canonicalizeDictionary :: TypeClassDictionaryInScope -> Qualified Ident
-- | A statement in a do-notation block
data DoNotationElement
-- | A monadic value without a binder
DoNotationValue :: Value -> DoNotationElement
-- | A monadic value with a binder
DoNotationBind :: Binder -> Value -> DoNotationElement
-- | A let statement, i.e. a pure value with a binder
DoNotationLet :: [Declaration] -> DoNotationElement
-- | A do notation element with source position information
PositionedDoNotationElement :: SourcePos -> DoNotationElement -> DoNotationElement
-- | Data type for binders
data Binder
-- | Wildcard binder
NullBinder :: Binder
-- | A binder which matches a boolean literal
BooleanBinder :: Bool -> Binder
-- | A binder which matches a string literal
StringBinder :: String -> Binder
-- | A binder which matches a numeric literal
NumberBinder :: (Either Integer Double) -> Binder
-- | A binder which binds an identifier
VarBinder :: Ident -> Binder
-- | A binder which matches a data constructor
ConstructorBinder :: (Qualified ProperName) -> [Binder] -> Binder
-- | A binder which matches a record and binds its properties
ObjectBinder :: [(String, Binder)] -> Binder
-- | A binder which matches an array and binds its elements
ArrayBinder :: [Binder] -> Binder
-- | A binder which matches an array and binds its head and tail
ConsBinder :: Binder -> Binder -> Binder
-- | A binder which binds its input to an identifier
NamedBinder :: Ident -> Binder -> Binder
-- | A binder with source position information
PositionedBinder :: SourcePos -> Binder -> Binder
-- | Collect all names introduced in binders in an expression
binderNames :: Binder -> [Ident]
everywhereOnValues :: (Declaration -> Declaration) -> (Value -> Value) -> (Binder -> Binder) -> (Declaration -> Declaration, Value -> Value, Binder -> Binder)
everywhereOnValuesTopDownM :: (Functor m, Applicative m, Monad m) => (Declaration -> m Declaration) -> (Value -> m Value) -> (Binder -> m Binder) -> (Declaration -> m Declaration, Value -> m Value, Binder -> m Binder)
everywhereOnValuesM :: (Functor m, Applicative m, Monad m) => (Declaration -> m Declaration) -> (Value -> m Value) -> (Binder -> m Binder) -> (Declaration -> m Declaration, Value -> m Value, Binder -> m Binder)
everythingOnValues :: (r -> r -> r) -> (Declaration -> r) -> (Value -> r) -> (Binder -> r) -> (CaseAlternative -> r) -> (DoNotationElement -> r) -> (Declaration -> r, Value -> r, Binder -> r, CaseAlternative -> r, DoNotationElement -> r)
everythingWithContextOnValues :: s -> r -> (r -> r -> r) -> (s -> Declaration -> (s, r)) -> (s -> Value -> (s, r)) -> (s -> Binder -> (s, r)) -> (s -> CaseAlternative -> (s, r)) -> (s -> DoNotationElement -> (s, r)) -> (Declaration -> r, Value -> r, Binder -> r, CaseAlternative -> r, DoNotationElement -> r)
everywhereWithContextOnValuesM :: (Functor m, Applicative m, Monad m) => s -> (s -> Declaration -> m (s, Declaration)) -> (s -> Value -> m (s, Value)) -> (s -> Binder -> m (s, Binder)) -> (s -> CaseAlternative -> m (s, CaseAlternative)) -> (s -> DoNotationElement -> m (s, DoNotationElement)) -> (Declaration -> m Declaration, Value -> m Value, Binder -> m Binder, CaseAlternative -> m CaseAlternative, DoNotationElement -> m DoNotationElement)
accumTypes :: Monoid r => (Type -> r) -> (Declaration -> r, Value -> r, Binder -> r, CaseAlternative -> r, DoNotationElement -> r)
instance Typeable Associativity
instance Typeable SourcePos
instance Typeable Fixity
instance Typeable DeclarationRef
instance Typeable Binder
instance Typeable Declaration
instance Typeable Value
instance Typeable DoNotationElement
instance Typeable CaseAlternative
instance Typeable Module
instance Data Associativity
instance Data SourcePos
instance Show Fixity
instance Data Fixity
instance Show DeclarationRef
instance Data DeclarationRef
instance Show Binder
instance Data Binder
instance Show Declaration
instance Data Declaration
instance Show Value
instance Data Value
instance Show DoNotationElement
instance Data DoNotationElement
instance Show CaseAlternative
instance Data CaseAlternative
instance Show Module
instance Data Module
instance Eq DeclarationRef
instance Show SourcePos
instance Show Associativity
-- | Provides the ability to sort modules based on module dependencies
module Language.PureScript.ModuleDependencies
-- | Sort a collection of modules based on module dependencies.
--
-- Reports an error if the module graph contains a cycle.
sortModules :: [Module] -> Either String ([Module], ModuleGraph)
-- | A list of modules with their dependencies
type ModuleGraph = [(ModuleName, [ModuleName])]
module Language.PureScript.DeadCodeElimination
-- | Eliminate all declarations which are not a transitive dependency of
-- the entry point module
eliminateDeadCode :: [ModuleName] -> [Module] -> [Module]
-- | Utility functions for working with names in scope
module Language.PureScript.Scope
-- | Gather all used names appearing inside a declaration
usedNamesDecl :: Declaration -> [Ident]
-- | Gather all used names appearing inside a value
usedNamesValue :: Value -> [Ident]
-- | Gather all used names appearing inside a binder
usedNamesBinder :: Binder -> [Ident]
-- | Gather all used names appearing inside a case alternative
usedNamesCaseAlternative :: CaseAlternative -> [Ident]
-- | Gather all used names appearing inside a do notation element
usedNamesDoNotationElement :: DoNotationElement -> [Ident]
-- | Generate a set of names which are unused inside a value, of the form
-- _{n} for an integer n
unusedNames :: [Ident] -> [Ident]
-- | This module generates code in the simplified Javascript intermediate
-- representation from Purescript code
module Language.PureScript.CodeGen.JS
-- | Different types of modules which are supported
data ModuleType
CommonJS :: ModuleType
Globals :: ModuleType
-- | Generate code in the simplified Javascript intermediate representation
-- for a declaration
declToJs :: Options -> ModuleName -> Declaration -> Environment -> Maybe [JS]
-- | Generate code in the simplified Javascript intermediate representation
-- for all declarations in a module.
moduleToJs :: ModuleType -> Options -> Module -> Environment -> [JS]
-- | Test if a string is a valid JS identifier (may return false negatives)
isIdent :: String -> Bool
-- | Pretty printer for the Javascript AST
module Language.PureScript.Pretty.JS
-- | Generate a pretty-printed string representing a collection of
-- Javascript expressions at the same indentation level
prettyPrintJS :: [JS] -> String
-- | Pretty printer for Types
module Language.PureScript.Pretty.Types
-- | Generate a pretty-printed string representing a Type
prettyPrintType :: Type -> String
-- | Generate a pretty-printed string representing a Type, as it should
-- appear inside parentheses
prettyPrintTypeAtom :: Type -> String
-- | Generate a pretty-printed string representing a Row
prettyPrintRow :: Type -> String
-- | Pretty printer for values
module Language.PureScript.Pretty.Values
-- | Generate a pretty-printed string representing an expression
prettyPrintValue :: Value -> String
-- | Generate a pretty-printed string representing a Binder
prettyPrintBinder :: Binder -> String
-- | A collection of pretty printers for core data types:
--
--
-- - Language.PureScript.Pretty.Kinds Pretty printer
-- for kinds
-- - Language.PureScript.Pretty.Values Pretty printer
-- for values
-- - Language.PureScript.Pretty.Types Pretty printer
-- for types
-- - Language.PureScript.Pretty.JS Pretty printer for
-- values, used for code generation
--
module Language.PureScript.Pretty
module Language.PureScript.Errors
-- | Type for sources of type checking errors
data ErrorSource
-- | An error which originated at a Value
ValueError :: Value -> ErrorSource
-- | An error which originated at a Type
TypeError :: Type -> ErrorSource
-- | Compilation errors
data CompileError
CompileError :: String -> Maybe ErrorSource -> Maybe SourcePos -> CompileError
-- | Error message
compileErrorMessage :: CompileError -> String
-- | The value where the error occurred
compileErrorValue :: CompileError -> Maybe ErrorSource
-- | Optional source position information
compileErrorPosition :: CompileError -> Maybe SourcePos
-- | A stack trace for an error
newtype ErrorStack
ErrorStack :: [CompileError] -> ErrorStack
runErrorStack :: ErrorStack -> [CompileError]
prettyPrintErrorStack :: Bool -> ErrorStack -> String
stringifyErrorStack :: Bool -> Either ErrorStack a -> Either String a
isErrorNonEmpty :: CompileError -> Bool
showError :: CompileError -> String
mkErrorStack :: String -> Maybe ErrorSource -> ErrorStack
positionError :: SourcePos -> ErrorStack
-- | Rethrow an error with a more detailed error message in the case of
-- failure
rethrow :: MonadError e m => (e -> e) -> m a -> m a
-- | Rethrow an error with source position information
rethrowWithPosition :: MonadError ErrorStack m => SourcePos -> m a -> m a
instance Show ErrorSource
instance Show CompileError
instance Show ErrorStack
instance Monoid ErrorStack
instance Error ErrorStack
-- | This module implements the desugaring pass which reapplies binary
-- operators based on their fixity data and removes explicit parentheses.
--
-- The value parser ignores fixity data when parsing binary operator
-- applications, so it is necessary to reorder them here.
module Language.PureScript.Sugar.Operators
-- | Remove explicit parentheses and reorder binary operator applications
rebracket :: [Module] -> Either ErrorStack [Module]
removeSignedLiterals :: Module -> Module
-- | This module implements the desugaring pass which replaces do-notation
-- statements with appropriate calls to (>>=) from the
-- Prelude.Monad type class.
module Language.PureScript.Sugar.DoNotation
-- | Replace all DoNotationBind and DoNotationValue
-- constructors with applications of the Prelude.(>>=) function,
-- and all DoNotationLet constructors with let expressions.
desugarDoModule :: Module -> Either ErrorStack Module
-- | This module implements the desugaring pass which replaces top-level
-- binders with case expressions.
module Language.PureScript.Sugar.CaseDeclarations
-- | Replace all top-level binders with case expressions.
desugarCases :: [Declaration] -> Either ErrorStack [Declaration]
-- | Replace all top-level binders in a module with case expressions.
desugarCasesModule :: [Module] -> Either ErrorStack [Module]
-- | This module implements the desugaring pass which replaces top-level
-- type declarations with type annotations on the corresponding
-- expression.
module Language.PureScript.Sugar.TypeDeclarations
-- | Replace all top level type declarations with type annotations
desugarTypeDeclarations :: [Declaration] -> Either ErrorStack [Declaration]
-- | Replace all top level type declarations in a module with type
-- annotations
desugarTypeDeclarationsModule :: [Module] -> Either ErrorStack [Module]
-- | This module implements the desugaring pass which creates binding
-- groups from sets of mutually-recursive value declarations and
-- mutually-recursive type declarations.
module Language.PureScript.Sugar.BindingGroups
-- | Replace all sets of mutually-recursive declarations with binding
-- groups
createBindingGroups :: ModuleName -> [Declaration] -> Either ErrorStack [Declaration]
-- | Replace all sets of mutually-recursive declarations in a module with
-- binding groups
createBindingGroupsModule :: [Module] -> Either ErrorStack [Module]
-- | Collapse all binding groups to individual declarations
collapseBindingGroups :: [Declaration] -> [Declaration]
-- | Collapse all binding groups in a module to individual declarations
collapseBindingGroupsModule :: [Module] -> [Module]
-- | This module implements the desugaring pass which creates type synonyms
-- for type class dictionaries and dictionary expressions for type class
-- instances.
module Language.PureScript.Sugar.TypeClasses
-- | Add type synonym declarations for type class dictionary types, and
-- value declarations for type class instance dictionary expressions.
desugarTypeClasses :: [Module] -> Either ErrorStack [Module]
module Language.PureScript.Sugar.Names
-- | Replaces all local names with qualified names within a set of modules.
desugarImports :: [Module] -> Either ErrorStack [Module]
instance Show Exports
instance Show ImportEnvironment
-- | Desugaring passes
module Language.PureScript.Sugar
-- | The desugaring pipeline proceeds as follows:
--
--
-- - Introduce type synonyms for type class dictionaries
-- - Rebracket user-defined binary operators
-- - Desugar do-notation using the Prelude.Monad type
-- class
-- - Desugar top-level case declarations into explicit case
-- expressions
-- - Desugar type declarations into value declarations with explicit
-- type annotations
-- - Group mutually recursive value and data declarations into binding
-- groups.
-- - Qualify any unqualified names and types
--
desugar :: [Module] -> Either ErrorStack [Module]
-- | This module generates code for "externs" files, i.e. files containing
-- only foreign import declarations.
module Language.PureScript.CodeGen.Externs
-- | Generate foreign imports for all declarations in a module
moduleToPs :: Module -> Environment -> String
-- | A collection of modules related to code generation:
--
--
-- - Language.PureScript.CodeGen.JS Code generator for
-- Javascript
-- - Language.PureScript.CodeGen.Externs Code generator
-- for extern (foreign import) files
-- - Language.PureScript.CodeGen.Optimize Optimization
-- passes for generated Javascript
--
module Language.PureScript.CodeGen
-- | Parsers for types
module Language.PureScript.Parser.Types
-- | Parse a monotype
parseType :: Parsec String ParseState Type
-- | Parse a polytype
parsePolyType :: Parsec String ParseState Type
-- | Parse a type as it appears in e.g. a data constructor
parseTypeAtom :: Parsec String ParseState Type
-- | Parsers for module definitions and declarations
module Language.PureScript.Parser.Declarations
-- | Parse a single declaration
parseDeclaration :: Parsec String ParseState Declaration
-- | Parse a module header and a collection of declarations
parseModule :: Parsec String ParseState Module
-- | Parse a collection of modules
parseModules :: Parsec String ParseState [Module]
-- | Parse a value
parseValue :: Parsec String ParseState Value
-- | Parse a guard
parseGuard :: Parsec String ParseState Guard
-- | Parse a binder
parseBinder :: Parsec String ParseState Binder
-- | Parse a binder as it would appear in a top level declaration
parseBinderNoParens :: Parsec String ParseState Binder
-- | A collection of parsers for core data types:
--
--
-- - Language.PureScript.Parser.Kinds Parser for
-- kinds
-- - Language.PureScript.Parser.Values Parser for
-- values
-- - Language.PureScript.Parser.Types Parser for
-- types
-- - Language.PureScript.Parser.Declaration Parsers for
-- declarations and modules
-- - Language.PureScript.Parser.State Parser state,
-- including indentation
-- - Language.PureScript.Parser.Common Common parsing
-- utility functions
--
module Language.PureScript.Parser
-- | Monads for type checking and type inference and associated data types
module Language.PureScript.TypeChecker.Monad
-- | Temporarily bind a collection of names to values
bindNames :: MonadState CheckState m => Map (ModuleName, Ident) (Type, NameKind) -> m a -> m a
-- | Temporarily bind a collection of names to types
bindTypes :: MonadState CheckState m => Map (Qualified ProperName) (Kind, TypeKind) -> m a -> m a
-- | Temporarily make a collection of type class dictionaries available
withTypeClassDictionaries :: MonadState CheckState m => [TypeClassDictionaryInScope] -> m a -> m a
-- | Get the currently available list of type class dictionaries
getTypeClassDictionaries :: (Functor m, MonadState CheckState m) => m [TypeClassDictionaryInScope]
-- | Temporarily bind a collection of names to local variables
bindLocalVariables :: (Functor m, MonadState CheckState m) => ModuleName -> [(Ident, Type)] -> m a -> m a
-- | Temporarily bind a collection of names to local type variables
bindLocalTypeVariables :: (Functor m, MonadState CheckState m) => ModuleName -> [(ProperName, Kind)] -> m a -> m a
-- | Lookup the type of a value by name in the Environment
lookupVariable :: (Error e, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m Type
-- | Lookup the kind of a type by name in the Environment
lookupTypeVariable :: (Error e, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified ProperName -> m Kind
-- | State required for type checking:
data CheckState
CheckState :: Environment -> Int -> Int -> Maybe ModuleName -> CheckState
-- | The current Environment
checkEnv :: CheckState -> Environment
-- | The next fresh unification variable name
checkNextVar :: CheckState -> Int
-- | The next type class dictionary name
checkNextDictName :: CheckState -> Int
-- | The current module
checkCurrentModule :: CheckState -> Maybe ModuleName
-- | The type checking monad, which provides the state of the type checker,
-- and error reporting capabilities
newtype Check a
Check :: StateT CheckState (Either ErrorStack) a -> Check a
unCheck :: Check a -> StateT CheckState (Either ErrorStack) a
-- | Get the current Environment
getEnv :: (Functor m, MonadState CheckState m) => m Environment
-- | Update the Environment
putEnv :: MonadState CheckState m => Environment -> m ()
-- | Modify the Environment
modifyEnv :: MonadState CheckState m => (Environment -> Environment) -> m ()
-- | Run a computation in the Check monad, starting with an empty
-- Environment
runCheck :: Options -> Check a -> Either String (a, Environment)
-- | Run a computation in the Check monad, failing with an error, or
-- succeeding with a return value and the final Environment.
runCheck' :: Options -> Environment -> Check a -> Either String (a, Environment)
-- | Make an assertion, failing with an error message
guardWith :: MonadError e m => e -> Bool -> m ()
-- | Generate new type class dictionary name
freshDictionaryName :: Check Int
-- | Lift a computation in the Check monad into the substitution
-- monad.
liftCheck :: Check a -> UnifyT t Check a
-- | Run a computation in the substitution monad, generating a return value
-- and the final substitution.
liftUnify :: Partial t => UnifyT t Check a -> Check (a, Substitution t)
instance Functor Check
instance Monad Check
instance Applicative Check
instance MonadPlus Check
instance MonadState CheckState Check
instance MonadError ErrorStack Check
-- | This module implements the kind checker
module Language.PureScript.TypeChecker.Kinds
-- | Infer the kind of a single type
kindOf :: ModuleName -> Type -> Check Kind
-- | Infer the kind of a type constructor with a collection of arguments
-- and a collection of associated data constructors
kindsOf :: Bool -> ModuleName -> ProperName -> [String] -> [Type] -> Check Kind
-- | Simultaneously infer the kinds of several mutually recursive type
-- constructors
kindsOfAll :: ModuleName -> [(ProperName, [String], Type)] -> [(ProperName, [String], [Type])] -> Check ([Kind], [Kind])
instance Unifiable Check Kind
instance Partial Kind
-- | Functions for replacing fully applied type synonyms with the
-- SaturatedTypeSynonym data constructor
module Language.PureScript.TypeChecker.Synonyms
-- | Replace all type synonyms with the SaturatedTypeSynonym data
-- constructor
saturateAllTypeSynonyms :: [(Qualified ProperName, Int)] -> Type -> Either String Type
-- | This module implements the type checker
module Language.PureScript.TypeChecker.Types
-- | Infer the types of multiple mutually-recursive values, and return
-- elaborated values including type class dictionaries and type
-- annotations.
typesOf :: Maybe ModuleName -> ModuleName -> [(Ident, Value)] -> Check [(Ident, (Value, Type))]
instance Show DictionaryValue
instance Ord DictionaryValue
instance Eq DictionaryValue
instance Unifiable Check Type
instance Partial Type
-- | The top-level type checker, which checks all declarations in a module.
module Language.PureScript.TypeChecker
-- | Type check all declarations in a module
--
-- At this point, many declarations will have been desugared, but it is
-- still necessary to
--
--
-- - Kind-check all types and add them to the Environment
-- - Type-check all values and add them to the
-- Environment
-- - Bring type class instances into scope
-- - Process module imports
--
typeCheckAll :: Maybe ModuleName -> ModuleName -> [Declaration] -> Check [Declaration]
-- | The main compiler module
module Language.PureScript
-- | Compile a collection of modules
--
-- The compilation pipeline proceeds as follows:
--
--
-- - Sort the modules based on module dependencies, checking for cyclic
-- dependencies.
-- - Perform a set of desugaring passes.
-- - Type check, and elaborate values to include type annotations and
-- type class dictionaries.
-- - Regroup values to take into account new value dependencies
-- introduced by elaboration.
-- - Eliminate dead code.
-- - Generate Javascript, and perform optimization passes.
-- - Pretty-print the generated Javascript
--
compile :: Options -> [Module] -> Either String (String, String, Environment)
compile' :: Environment -> Options -> [Module] -> Either String (String, String, Environment)
-- | A type class which collects the IO actions we need to be able to run
-- in make mode
class MonadMake m
getTimestamp :: MonadMake m => FilePath -> m (Maybe UTCTime)
readTextFile :: MonadMake m => FilePath -> m String
writeTextFile :: MonadMake m => FilePath -> String -> m ()
liftError :: MonadMake m => Either String a -> m a
progress :: MonadMake m => String -> m ()
-- | Compiles in make mode, compiling each module separately to a js
-- files and an externs file
--
-- If timestamps have not changed, the externs file can be used to
-- provide the module's types without having to typecheck the module
-- again.
make :: (Functor m, Monad m, MonadMake m) => FilePath -> Options -> [(FilePath, Module)] -> m Environment