-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | PureScript Programming Language Compiler
--
@package purescript
@version 0.6.5
-- | 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
-- | Metadata annotations for core functional representation
module Language.PureScript.CoreFn.Meta
-- | Metadata annotations
data Meta
-- | The contained value is a data constructor
IsConstructor :: ConstructorType -> Arity -> Meta
-- | The contained value is a newtype
IsNewtype :: Meta
-- | The contained value is a typeclass dictionary constructor
IsTypeClassConstructor :: Meta
-- | Type alias for constructor arity
type Arity = Int
-- | Data constructor metadata
data ConstructorType
-- | The constructor is for a type with a single construcor
ProductType :: ConstructorType
-- | The constructor is for a type with multiple construcors
SumType :: ConstructorType
instance Typeable ConstructorType
instance Typeable Meta
instance Show ConstructorType
instance Data ConstructorType
instance Show Meta
instance Data Meta
-- | The core functional representation for literal values.
module Language.PureScript.CoreFn.Literals
-- | Data type for literal values. Parameterised so it can be used for
-- Exprs and Binders.
data Literal a
-- | A numeric literal
NumericLiteral :: (Either Integer Double) -> Literal a
-- | A string literal
StringLiteral :: String -> Literal a
-- | A boolean literal
BooleanLiteral :: Bool -> Literal a
-- | An array literal
ArrayLiteral :: [a] -> Literal a
-- | An object literal
ObjectLiteral :: [(String, a)] -> Literal a
instance Typeable Literal
instance Show a => Show (Literal a)
instance Data a => Data (Literal a)
-- | 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)
pairM :: Applicative f => (a -> f c) -> (b -> f d) -> (a, b) -> f (c, d)
maybeM :: Applicative f => (a -> f b) -> Maybe a -> f (Maybe b)
eitherM :: Applicative f => (a -> f c) -> (b -> f d) -> Either a b -> f (Either c d)
defS :: Monad m => st -> val -> m (st, val)
-- | Source position information
module Language.PureScript.AST.SourcePos
-- | Source position information
data SourcePos
SourcePos :: Int -> Int -> SourcePos
-- | Line number
sourcePosLine :: SourcePos -> Int
-- | Column number
sourcePosColumn :: SourcePos -> Int
data SourceSpan
SourceSpan :: String -> SourcePos -> SourcePos -> SourceSpan
-- | Source name
spanName :: SourceSpan -> String
-- | Start of the span
spanStart :: SourceSpan -> SourcePos
spanEnd :: SourceSpan -> SourcePos
instance Typeable SourcePos
instance Typeable SourceSpan
instance Data SourcePos
instance Data SourceSpan
instance Show SourceSpan
instance Show SourcePos
-- | Operators fixity and associativity
module Language.PureScript.AST.Operators
-- | A precedence level for an infix operator
type Precedence = Integer
-- | Associativity for infix operators
data Associativity
Infixl :: Associativity
Infixr :: Associativity
Infix :: Associativity
-- | Fixity data for infix operators
data Fixity
Fixity :: Associativity -> Precedence -> Fixity
instance Typeable Associativity
instance Typeable Fixity
instance Data Associativity
instance Show Fixity
instance Data Fixity
instance Show Associativity
-- | 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
(.&.) :: String
(.|.) :: String
(.^.) :: String
(&&) :: String
(||) :: String
unsafeIndex :: String
negate :: String
shl :: String
shr :: String
zshr :: String
complement :: String
not :: String
return :: String
pure' :: String
returnEscaped :: String
untilE :: String
whileE :: String
runST :: String
stRefValue :: String
newSTRef :: String
readSTRef :: String
writeSTRef :: String
modifySTRef :: String
mkFn :: String
runFn :: String
unit :: String
undefined :: String
monadEffDictionary :: String
applicativeEffDictionary :: String
bindEffDictionary :: String
numNumber :: String
ordNumber :: String
eqNumber :: String
eqString :: String
eqBoolean :: String
bitsNumber :: String
boolLikeBoolean :: String
semigroupString :: String
semigroupoidArr :: String
main :: String
__superclass_ :: String
__unused :: String
prim :: String
prelude :: String
preludeUnsafe :: String
eff :: String
st :: String
dataFunction :: String
-- | Fresh variable supply
module Language.PureScript.Supply
newtype SupplyT m a
SupplyT :: StateT Integer m a -> SupplyT m a
unSupplyT :: SupplyT m a -> StateT Integer m a
runSupplyT :: Integer -> SupplyT m a -> m (a, Integer)
evalSupplyT :: Functor m => Integer -> SupplyT m a -> m a
type Supply = SupplyT Identity
runSupply :: Integer -> Supply a -> (a, Integer)
evalSupply :: Integer -> Supply a -> a
fresh :: Monad m => SupplyT m Integer
freshName :: (Functor m, Monad m) => SupplyT m String
instance Functor m => Functor (SupplyT m)
instance (Monad m, Functor m) => Applicative (SupplyT m)
instance Monad m => Monad (SupplyT m)
instance MonadTrans SupplyT
instance MonadError e m => MonadError e (SupplyT m)
-- | The data type of compiler options
module Language.PureScript.Options
-- | Indicates the mode of the compiler. Lifted using DataKinds to refine
-- the Options type.
data Mode
Compile :: Mode
Make :: Mode
-- | Per-mode options
data ModeOptions mode
CompileOptions :: String -> [String] -> [String] -> ModeOptions Compile
MakeOptions :: ModeOptions Make
browserNamespace :: ModeOptions Compile -> String
entryPointModules :: ModeOptions Compile -> [String]
codeGenModules :: ModeOptions Compile -> [String]
-- | The data type of compiler options
data Options mode
Options :: Bool -> Bool -> Bool -> Maybe String -> Bool -> Bool -> ModeOptions mode -> Options mode
-- | Disable inclusion of the built in Prelude
optionsNoPrelude :: Options mode -> Bool
-- | Disable tail-call elimination
optionsNoTco :: Options mode -> Bool
-- | Disable inlining of calls to return and bind for the Eff monad
optionsNoMagicDo :: Options mode -> Bool
-- | When specified, checks the type of main in the module, and
-- generate a call to run main after the module definitions.
optionsMain :: Options mode -> Maybe String
-- | Skip all optimizations
optionsNoOptimizations :: Options mode -> Bool
-- | Verbose error message
optionsVerboseErrors :: Options mode -> Bool
-- | Specify the namespace that PureScript modules will be exported to when
-- running in the browser.
optionsAdditional :: Options mode -> ModeOptions mode
-- | Default compiler options
defaultCompileOptions :: Options Compile
-- | Default make options
defaultMakeOptions :: Options Make
instance Show (ModeOptions mode)
instance Show (Options mode)
-- | 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, type//data
-- 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 Typeable 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 Functor Qualified
instance Show a => Show (Qualified a)
instance Show ModuleName
instance Show ProperName
instance Show Ident
-- | Common code generation utility functions
module Language.PureScript.CodeGen.JS.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
-- | Test if a string is a valid JS identifier without escaping.
identNeedsEscaping :: String -> Bool
-- | 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
moduleNameToJs :: ModuleName -> String
-- | The core functional representation for binders
module Language.PureScript.CoreFn.Binders
-- | Data type for binders
data Binder a
-- | Wildcard binder
NullBinder :: a -> Binder a
-- | A binder which matches a literal value
LiteralBinder :: a -> (Literal (Binder a)) -> Binder a
-- | A binder which binds an identifier
VarBinder :: a -> Ident -> Binder a
-- | A binder which matches a data constructor (type name, constructor
-- name, binders)
ConstructorBinder :: a -> (Qualified ProperName) -> (Qualified ProperName) -> [Binder a] -> Binder a
-- | A binder which binds its input to an identifier
NamedBinder :: a -> Ident -> (Binder a) -> Binder a
instance Typeable Binder
instance Show a => Show (Binder a)
instance Data a => Data (Binder a)
-- | The core functional representation
module Language.PureScript.CoreFn.Expr
-- | Data type for expressions and terms
data Expr a
-- | A literal value
Literal :: a -> (Literal (Expr a)) -> Expr a
-- | A data constructor (type name, constructor name, arity)
Constructor :: a -> ProperName -> ProperName -> Arity -> Expr a
-- | A record property accessor
Accessor :: a -> String -> (Expr a) -> Expr a
-- | Partial record update
ObjectUpdate :: a -> (Expr a) -> [(String, Expr a)] -> Expr a
-- | Function introduction
Abs :: a -> Ident -> (Expr a) -> Expr a
-- | Function application
App :: a -> (Expr a) -> (Expr a) -> Expr a
-- | Variable
Var :: a -> (Qualified Ident) -> Expr a
-- | A case expression
Case :: a -> [Expr a] -> [CaseAlternative a] -> Expr a
-- | A let binding
Let :: a -> [Bind a] -> (Expr a) -> Expr a
-- | A let or module binding.
data Bind a
-- | Non-recursive binding for a single value
NonRec :: Ident -> (Expr a) -> Bind a
-- | Mutually recursive binding group for several values
Rec :: [(Ident, Expr a)] -> Bind a
-- | A guard is just a boolean-valued expression that appears alongside a
-- set of binders
type Guard a = Expr a
-- | An alternative in a case statement
data CaseAlternative a
CaseAlternative :: [Binder a] -> Either [(Guard a, Expr a)] (Expr a) -> CaseAlternative a
-- | A collection of binders with which to match the inputs
caseAlternativeBinders :: CaseAlternative a -> [Binder a]
-- | The result expression or a collect of guarded expressions
caseAlternativeResult :: CaseAlternative a -> Either [(Guard a, Expr a)] (Expr a)
-- | Extract the annotation from a term
extractAnn :: Expr a -> a
-- | Modify the annotation on a term
modifyAnn :: (a -> a) -> Expr a -> Expr a
instance Typeable CaseAlternative
instance Typeable Expr
instance Typeable Bind
instance Show a => Show (CaseAlternative a)
instance Data a => Data (CaseAlternative a)
instance Show a => Show (Expr a)
instance Data a => Data (Expr a)
instance Show a => Show (Bind a)
instance Data a => Data (Bind a)
-- | CoreFn traversal helpers
module Language.PureScript.CoreFn.Traversals
everywhereOnValues :: (Bind a -> Bind a) -> (Expr a -> Expr a) -> (Binder a -> Binder a) -> (Bind a -> Bind a, Expr a -> Expr a, Binder a -> Binder a)
everythingOnValues :: (r -> r -> r) -> (Bind a -> r) -> (Expr a -> r) -> (Binder a -> r) -> (CaseAlternative a -> r) -> (Bind a -> r, Expr a -> r, Binder a -> r, CaseAlternative a -> r)
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
-- | 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 wildcard, as would appear in a partial type synonym
TypeWildcard :: 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 :: [Constraint] -> 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 type with a kind annotation
KindedType :: Type -> Kind -> 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
-- | A typeclass constraint
type Constraint = (Qualified ProperName, [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
-- | Check if a type contains wildcards
containsWildcards :: Type -> Bool
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 [Constraint] -> TypeClassDictionaryType -> Bool -> 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 [Constraint]
-- | The type of this dictionary
tcdType :: TypeClassDictionaryInScope -> TypeClassDictionaryType
-- | Is this instance exported by its module?
tcdExported :: TypeClassDictionaryInScope -> Bool
-- | 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
-- | Find the original dictionary which a type class dictionary in scope
-- refers to
canonicalizeDictionary :: TypeClassDictionaryInScope -> Qualified Ident
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, NameVisibility) -> Map (Qualified ProperName) (Kind, TypeKind) -> Map (Qualified ProperName) (DataDeclType, ProperName, Type) -> Map (Qualified ProperName) ([(String, Maybe Kind)], Type) -> Map (Qualified Ident, Maybe ModuleName) TypeClassDictionaryInScope -> Map (Qualified ProperName) ([(String, Maybe Kind)], [(Ident, Type)], [Constraint]) -> Environment
-- | Value names currently in scope
names :: Environment -> Map (ModuleName, Ident) (Type, NameKind, NameVisibility)
-- | 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) (DataDeclType, ProperName, Type)
-- | Type synonyms currently in scope
typeSynonyms :: Environment -> Map (Qualified ProperName) ([(String, Maybe Kind)], Type)
-- | Available type class dictionaries
typeClassDictionaries :: Environment -> Map (Qualified Ident, Maybe ModuleName) TypeClassDictionaryInScope
-- | Type classes
typeClasses :: Environment -> Map (Qualified ProperName) ([(String, Maybe Kind)], [(Ident, Type)], [Constraint])
-- | 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
-- | The visibility of a name in scope
data NameVisibility
-- | The name is defined in the current binding group, but is not visible
Undefined :: NameVisibility
-- | The name is defined in the another binding group, or has been made
-- visible by a function binder
Defined :: NameVisibility
-- | The kind of a name
data NameKind
-- | A value introduced as a binding in a module
Value :: NameKind
-- | A type class dictionary member accessor import, generated during
-- desugaring of type class declarations
TypeClassAccessorImport :: 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, Maybe Kind)] -> [(ProperName, [Type])] -> TypeKind
-- | Type synonym
TypeSynonym :: TypeKind
-- | Foreign data
ExternData :: TypeKind
-- | A local type variable
LocalTypeVariable :: TypeKind
-- | The type ('data' or 'newtype') of a data type declaration
data DataDeclType
-- | A standard data constructor
Data :: DataDeclType
-- | A newtype constructor
Newtype :: DataDeclType
-- | 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)
-- | Finds information about data constructors from the current
-- environment.
lookupConstructor :: Environment -> Qualified ProperName -> (DataDeclType, ProperName, Type)
-- | Checks whether a data constructor is for a newtype.
isNewtypeConstructor :: Environment -> Qualified ProperName -> Bool
instance Typeable ForeignImportType
instance Typeable NameKind
instance Typeable TypeKind
instance Typeable DataDeclType
instance Show ForeignImportType
instance Eq ForeignImportType
instance Data ForeignImportType
instance Show NameVisibility
instance Eq NameVisibility
instance Show NameKind
instance Eq NameKind
instance Data NameKind
instance Show TypeKind
instance Eq TypeKind
instance Data TypeKind
instance Eq DataDeclType
instance Ord DataDeclType
instance Data DataDeclType
instance Show Environment
instance Show DataDeclType
-- | Defines the types of source code comments
module Language.PureScript.Comments
data Comment
LineComment :: String -> Comment
BlockComment :: String -> Comment
instance Typeable Comment
instance Show Comment
instance Eq Comment
instance Ord Comment
instance Data Comment
-- | Case binders
module Language.PureScript.AST.Binders
-- | 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 :: SourceSpan -> [Comment] -> Binder -> Binder
-- | Collect all names introduced in binders in an expression
binderNames :: Binder -> [Ident]
instance Typeable Binder
instance Show Binder
instance Data Binder
-- | 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
-- | Constructor
JSNew :: 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
-- | InstanceOf test
JSInstanceOf :: JS -> 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
-- | Commented Javascript
JSComment :: [Comment] -> JS -> 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
-- | Data types for modules and declarations
module Language.PureScript.AST.Declarations
-- | 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
-- | Return a module's name.
getModuleName :: Module -> ModuleName
-- | Test if a declaration is exported, given a module's export list.
isExported :: Maybe [DeclarationRef] -> Declaration -> Bool
exportedDeclarations :: Module -> [Declaration]
-- | Test if a data constructor for a given type is exported, given a
-- module's export list.
isDctorExported :: ProperName -> Maybe [DeclarationRef] -> ProperName -> Bool
-- | Return the exported data constructors for a given type.
exportedDctors :: Module -> ProperName -> [ProperName]
-- | 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 :: SourceSpan -> [Comment] -> DeclarationRef -> DeclarationRef
-- | The data type which specifies type of import declaration
data ImportDeclarationType
-- | Unqualified import
Unqualified :: ImportDeclarationType
-- | Qualified import with a list of references to import
Qualifying :: [DeclarationRef] -> ImportDeclarationType
-- | Import with hiding clause with a list of references to hide
Hiding :: [DeclarationRef] -> ImportDeclarationType
-- | The data type of declarations
data Declaration
-- | A data type declaration (data or newtype, name, arguments, data
-- constructors)
DataDeclaration :: DataDeclType -> ProperName -> [(String, Maybe Kind)] -> [(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, Maybe Kind)] -> 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] -> (Either [(Guard, Expr)] Expr) -> Declaration
-- | A minimal mutually recursive set of value declarations
BindingGroupDeclaration :: [(Ident, NameKind, Expr)] -> 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 -> [Constraint] -> (Qualified ProperName) -> [Type] -> Declaration
-- | A fixity declaration (fixity data, operator name)
FixityDeclaration :: Fixity -> String -> Declaration
-- | A module import (module name, qualifiedunqualifiedhiding,
-- optional "qualified as" name)
ImportDeclaration :: ModuleName -> ImportDeclarationType -> (Maybe ModuleName) -> Declaration
-- | A type class declaration (name, argument, implies, member
-- declarations)
TypeClassDeclaration :: ProperName -> [(String, Maybe Kind)] -> [Constraint] -> [Declaration] -> Declaration
-- | A type instance declaration (name, dependencies, class name, instance
-- types, member declarations)
TypeInstanceDeclaration :: Ident -> [Constraint] -> (Qualified ProperName) -> [Type] -> [Declaration] -> Declaration
-- | A declaration with source position information
PositionedDeclaration :: SourceSpan -> [Comment] -> 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
-- | Recursively flatten data binding groups in the list of declarations
flattenDecls :: [Declaration] -> [Declaration]
-- | A guard is just a boolean-valued expression that appears alongside a
-- set of binders
type Guard = Expr
-- | Data type for expressions and terms
data Expr
-- | A numeric literal
NumericLiteral :: (Either Integer Double) -> Expr
-- | A string literal
StringLiteral :: String -> Expr
-- | A boolean literal
BooleanLiteral :: Bool -> Expr
-- | A prefix -, will be desugared
UnaryMinus :: Expr -> Expr
-- | Binary operator application. During the rebracketing phase of
-- desugaring, this data constructor will be removed.
BinaryNoParens :: (Qualified Ident) -> Expr -> Expr -> Expr
-- | Explicit parentheses. During the rebracketing phase of desugaring,
-- this data constructor will be removed.
Parens :: Expr -> Expr
-- | Operator section. This will be removed during desugaring and replaced
-- with a partially applied operator or lambda to flip the arguments.
OperatorSection :: (Qualified Ident) -> (Either Expr Expr) -> Expr
-- | An array literal
ArrayLiteral :: [Expr] -> Expr
-- | An object literal
ObjectLiteral :: [(String, Expr)] -> Expr
-- | An object constructor (object literal with underscores). This will be
-- removed during desugaring and expanded into a lambda that returns an
-- object literal.
ObjectConstructor :: [(String, Maybe Expr)] -> Expr
-- | An object property getter (e.g. `_.x`). This will be removed during
-- desugaring and expanded into a lambda that reads a property from an
-- object.
ObjectGetter :: String -> Expr
-- | An record property accessor expression
Accessor :: String -> Expr -> Expr
-- | Partial record update
ObjectUpdate :: Expr -> [(String, Expr)] -> Expr
-- | Partial record updater. This will be removed during desugaring and
-- expanded into a lambda that returns an object update.
ObjectUpdater :: Expr -> [(String, Maybe Expr)] -> Expr
-- | Function introduction
Abs :: (Either Ident Binder) -> Expr -> Expr
-- | Function application
App :: Expr -> Expr -> Expr
-- | Variable
Var :: (Qualified Ident) -> Expr
-- | Conditional (if-then-else expression)
IfThenElse :: Expr -> Expr -> Expr -> Expr
-- | A data constructor
Constructor :: (Qualified ProperName) -> Expr
-- | 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 :: [Expr] -> [CaseAlternative] -> Expr
-- | A value with a type annotation
TypedValue :: Bool -> Expr -> Type -> Expr
-- | A let binding
Let :: [Declaration] -> Expr -> Expr
-- | A do-notation block
Do :: [DoNotationElement] -> Expr
-- | An application of a typeclass dictionary constructor. The value should
-- be an ObjectLiteral.
TypeClassDictionaryConstructorApp :: (Qualified ProperName) -> Expr -> Expr
-- | 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 -> Constraint -> [TypeClassDictionaryInScope] -> Expr
-- | A placeholder for a superclass dictionary to be turned into a
-- TypeClassDictionary during typechecking
SuperClassDictionary :: (Qualified ProperName) -> [Type] -> Expr
-- | A value with source position information
PositionedValue :: SourceSpan -> [Comment] -> Expr -> Expr
-- | An alternative in a case statement
data CaseAlternative
CaseAlternative :: [Binder] -> Either [(Guard, Expr)] Expr -> CaseAlternative
-- | A collection of binders with which to match the inputs
caseAlternativeBinders :: CaseAlternative -> [Binder]
-- | The result expression or a collect of guarded expressions
caseAlternativeResult :: CaseAlternative -> Either [(Guard, Expr)] Expr
-- | A statement in a do-notation block
data DoNotationElement
-- | A monadic value without a binder
DoNotationValue :: Expr -> DoNotationElement
-- | A monadic value with a binder
DoNotationBind :: Binder -> Expr -> DoNotationElement
-- | A let statement, i.e. a pure value with a binder
DoNotationLet :: [Declaration] -> DoNotationElement
-- | A do notation element with source position information
PositionedDoNotationElement :: SourceSpan -> [Comment] -> DoNotationElement -> DoNotationElement
instance Typeable DeclarationRef
instance Typeable ImportDeclarationType
instance Typeable DoNotationElement
instance Typeable Expr
instance Typeable CaseAlternative
instance Typeable Declaration
instance Typeable Module
instance Show DeclarationRef
instance Data DeclarationRef
instance Show ImportDeclarationType
instance Data ImportDeclarationType
instance Show DoNotationElement
instance Data DoNotationElement
instance Show Expr
instance Data Expr
instance Show CaseAlternative
instance Data CaseAlternative
instance Show Declaration
instance Data Declaration
instance Show Module
instance Data Module
instance Eq DeclarationRef
-- | AST traversal helpers
module Language.PureScript.AST.Traversals
everywhereOnValues :: (Declaration -> Declaration) -> (Expr -> Expr) -> (Binder -> Binder) -> (Declaration -> Declaration, Expr -> Expr, Binder -> Binder)
everywhereOnValuesTopDownM :: (Functor m, Applicative m, Monad m) => (Declaration -> m Declaration) -> (Expr -> m Expr) -> (Binder -> m Binder) -> (Declaration -> m Declaration, Expr -> m Expr, Binder -> m Binder)
everywhereOnValuesM :: (Functor m, Applicative m, Monad m) => (Declaration -> m Declaration) -> (Expr -> m Expr) -> (Binder -> m Binder) -> (Declaration -> m Declaration, Expr -> m Expr, Binder -> m Binder)
everythingOnValues :: (r -> r -> r) -> (Declaration -> r) -> (Expr -> r) -> (Binder -> r) -> (CaseAlternative -> r) -> (DoNotationElement -> r) -> (Declaration -> r, Expr -> r, Binder -> r, CaseAlternative -> r, DoNotationElement -> r)
everythingWithContextOnValues :: s -> r -> (r -> r -> r) -> (s -> Declaration -> (s, r)) -> (s -> Expr -> (s, r)) -> (s -> Binder -> (s, r)) -> (s -> CaseAlternative -> (s, r)) -> (s -> DoNotationElement -> (s, r)) -> (Declaration -> r, Expr -> r, Binder -> r, CaseAlternative -> r, DoNotationElement -> r)
everywhereWithContextOnValuesM :: (Functor m, Applicative m, Monad m) => s -> (s -> Declaration -> m (s, Declaration)) -> (s -> Expr -> m (s, Expr)) -> (s -> Binder -> m (s, Binder)) -> (s -> CaseAlternative -> m (s, CaseAlternative)) -> (s -> DoNotationElement -> m (s, DoNotationElement)) -> (Declaration -> m Declaration, Expr -> m Expr, Binder -> m Binder, CaseAlternative -> m CaseAlternative, DoNotationElement -> m DoNotationElement)
accumTypes :: Monoid r => (Type -> r) -> (Declaration -> r, Expr -> r, Binder -> r, CaseAlternative -> r, DoNotationElement -> r)
-- | Common functions used by the various optimizer phases
module Language.PureScript.CodeGen.JS.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
-- | This module implements tail call elimination.
module Language.PureScript.CodeGen.JS.Optimizer.TCO
-- | Eliminate tail calls
tco :: Options mode -> JS -> JS
-- | 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.CodeGen.JS.Optimizer.MagicDo
magicDo :: Options mode -> JS -> JS
-- | This module provides basic inlining capabilities
module Language.PureScript.CodeGen.JS.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
-- | Removes unused variables
module Language.PureScript.CodeGen.JS.Optimizer.Unused
removeCodeAfterReturnStatements :: JS -> JS
removeUnusedArg :: JS -> JS
removeUndefinedApp :: JS -> JS
-- | Optimizer steps for simplifying Javascript blocks
module Language.PureScript.CodeGen.JS.Optimizer.Blocks
-- | Collapse blocks which appear nested directly below another block
collapseNestedBlocks :: JS -> JS
collapseNestedIfs :: 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 unnecessary thunks
-- - Eta conversion
-- - Inlining variables
-- - Inline Prelude.($), Prelude.(#), Prelude.(++), Prelude.(!!)
-- - Inlining primitive Javascript operators
--
module Language.PureScript.CodeGen.JS.Optimizer
-- | Apply a series of optimizer passes to simplified Javascript code
optimize :: Options mode -> JS -> JS
-- | The CoreFn module representation
module Language.PureScript.CoreFn.Module
data Module a
Module :: ModuleName -> [ModuleName] -> [Ident] -> [ForeignDecl] -> [Bind a] -> Module a
moduleName :: Module a -> ModuleName
moduleImports :: Module a -> [ModuleName]
moduleExports :: Module a -> [Ident]
moduleForeign :: Module a -> [ForeignDecl]
moduleDecls :: Module a -> [Bind a]
type ForeignDecl = (Ident, Maybe JS, Type)
instance Show a => Show (Module a)
-- | Type alias for basic annotations
module Language.PureScript.CoreFn.Ann
-- | Type alias for basic annotations
type Ann = (Maybe SourceSpan, [Comment], Maybe Type, Maybe Meta)
-- | Initial annotation with no metadata
nullAnn :: Ann
-- | Remove the comments from an annotation
removeComments :: Ann -> Ann
-- | The first step in the parsing process - turns source code into a list
-- of lexemes
module Language.PureScript.Parser.Lexer
data PositionedToken
PositionedToken :: SourcePos -> Token -> [Comment] -> PositionedToken
ptSourcePos :: PositionedToken -> SourcePos
ptToken :: PositionedToken -> Token
ptComments :: PositionedToken -> [Comment]
data Token
type TokenParser a = Parsec [PositionedToken] ParseState a
lex :: FilePath -> String -> Either ParseError [PositionedToken]
anyToken :: TokenParser PositionedToken
token :: (Token -> Maybe a) -> TokenParser a
match :: Token -> TokenParser ()
lparen :: TokenParser ()
rparen :: TokenParser ()
parens :: TokenParser a -> TokenParser a
lbrace :: TokenParser ()
rbrace :: TokenParser ()
braces :: TokenParser a -> TokenParser a
lsquare :: TokenParser ()
rsquare :: TokenParser ()
squares :: TokenParser a -> TokenParser a
indent :: TokenParser Int
indentAt :: Column -> TokenParser ()
larrow :: TokenParser ()
rarrow :: TokenParser ()
lfatArrow :: TokenParser ()
rfatArrow :: TokenParser ()
colon :: TokenParser ()
doubleColon :: TokenParser ()
equals :: TokenParser ()
pipe :: TokenParser ()
tick :: TokenParser ()
dot :: TokenParser ()
comma :: TokenParser ()
semi :: TokenParser ()
at :: TokenParser ()
underscore :: TokenParser ()
-- | Parse zero or more values separated by semicolons
semiSep :: TokenParser a -> TokenParser [a]
-- | Parse one or more values separated by semicolons
semiSep1 :: TokenParser a -> TokenParser [a]
-- | Parse zero or more values separated by commas
commaSep :: TokenParser a -> TokenParser [a]
-- | Parse one or more values separated by commas
commaSep1 :: TokenParser a -> TokenParser [a]
lname :: TokenParser String
qualifier :: TokenParser String
uname :: TokenParser String
uname' :: String -> TokenParser ()
mname :: TokenParser String
reserved :: String -> TokenParser ()
symbol :: TokenParser String
symbol' :: String -> TokenParser ()
identifier :: TokenParser String
stringLiteral :: TokenParser String
number :: TokenParser (Either Integer Double)
natural :: TokenParser Integer
-- | A list of purescript reserved identifiers
reservedPsNames :: [String]
reservedTypeNames :: [String]
-- | The characters allowed for use in operators
opChars :: [Char]
instance Show Token
instance Eq Token
instance Ord Token
instance Eq PositionedToken
instance Show PositionedToken
-- | Constants, and utility functions to be used when parsing
module Language.PureScript.Parser.Common
properName :: TokenParser ProperName
-- | Parse a module name
moduleName :: TokenParser ModuleName
-- | Parse a qualified name, i.e. M.name or just name
parseQualified :: TokenParser a -> TokenParser (Qualified a)
-- | Parse an identifier or parenthesized operator
parseIdent :: TokenParser Ident
-- | 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 :: TokenParser (Qualified Ident)
-- | Mark the current indentation level
mark :: Parsec s ParseState a -> Parsec s ParseState a
-- | Check that the current identation level matches a predicate
checkIndentation :: (Column -> Column -> Bool) -> Parsec s ParseState ()
-- | Check that the current indentation level is past the current mark
indented :: Parsec s ParseState ()
-- | Check that the current indentation level is at the same indentation as
-- the current mark
same :: Parsec s ParseState ()
-- | Read the comments from the the next token, without consuming it
readComments :: Parsec [PositionedToken] u [Comment]
-- | Run a parser
runTokenParser :: FilePath -> TokenParser a -> [PositionedToken] -> Either ParseError a
-- | A parser for kinds
module Language.PureScript.Parser.Kinds
-- | Parse a kind
parseKind :: TokenParser Kind
-- | Parsers for types
module Language.PureScript.Parser.Types
-- | Parse a monotype
parseType :: TokenParser Type
-- | Parse a polytype
parsePolyType :: TokenParser Type
-- | Parse an atomic type with no wildcards
noWildcards :: TokenParser Type -> TokenParser Type
-- | Parse a type as it appears in e.g. a data constructor
parseTypeAtom :: TokenParser Type
-- | 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
-- | Prints an object key, escaping reserved names.
prettyPrintObjectKey :: String -> String
instance Show PrinterState
instance Eq PrinterState
instance Ord PrinterState
-- | Pretty printer for kinds
module Language.PureScript.Pretty.Kinds
-- | Generate a pretty-printed string representing a Kind
prettyPrintKind :: Kind -> 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 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
-- | The initial PureScript AST
module Language.PureScript.AST
-- | 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])]
-- | Parsers for module definitions and declarations
module Language.PureScript.Parser.Declarations
-- | Parse a single declaration
parseDeclaration :: TokenParser Declaration
-- | Parse a module header and a collection of declarations
parseModule :: TokenParser Module
-- | Parse a collection of modules
parseModules :: TokenParser [Module]
-- | Parse a collection of modules
parseModulesFromFiles :: (k -> String) -> [(k, String)] -> Either ParseError [(k, Module)]
-- | Parse a value
parseValue :: TokenParser Expr
-- | Parse a guard
parseGuard :: TokenParser Guard
-- | Parse a binder
parseBinder :: TokenParser Binder
-- | Parse a binder as it would appear in a top level declaration
parseBinderNoParens :: TokenParser 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
-- | Pretty printer for values
module Language.PureScript.Pretty.Values
-- | Generate a pretty-printed string representing an expression
prettyPrintValue :: Expr -> 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 Expr
ExprError :: Expr -> ErrorSource
-- | An error which originated at a Type
TypeError :: Type -> ErrorSource
-- | Compilation errors
data CompileError
CompileError :: String -> Maybe ErrorSource -> Maybe SourceSpan -> CompileError
-- | Error message
compileErrorMessage :: CompileError -> String
-- | The value where the error occurred
compileErrorValue :: CompileError -> Maybe ErrorSource
-- | Optional source position information
compileErrorPosition :: CompileError -> Maybe SourceSpan
-- | A stack trace for an error
data ErrorStack
ErrorStack :: [CompileError] -> ErrorStack
runErrorStack :: ErrorStack -> [CompileError]
MultipleErrors :: [ErrorStack] -> ErrorStack
prettyPrintErrorStack :: Bool -> ErrorStack -> String
stringifyErrorStack :: Bool -> Either ErrorStack a -> Either String a
isErrorNonEmpty :: CompileError -> Bool
showError :: CompileError -> String
mkErrorStack :: String -> Maybe ErrorSource -> ErrorStack
positionError :: SourceSpan -> 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 => SourceSpan -> m a -> m a
-- | Collect errors in in parallel
parU :: (MonadError ErrorStack m, Functor m) => [a] -> (a -> m b) -> m [b]
instance Show ErrorSource
instance Show CompileError
instance Show ErrorStack
instance Error ErrorStack
instance Monoid ErrorStack
-- | 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, NameVisibility) -> 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, NameVisibility)] -> 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
-- | Update the visibility of all names to Defined
makeBindingGroupVisible :: (Functor m, MonadState CheckState m) => 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 visibility of a value by name in the Environment
getVisibility :: (Error e, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m NameVisibility
-- | Assert that a name is visible
checkVisibility :: (Error e, Functor m, MonadState CheckState m, MonadError e m) => ModuleName -> Qualified Ident -> m ()
-- | 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 mode -> 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 mode -> 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 Alternative Check
instance MonadPlus Check
instance MonadState CheckState Check
instance MonadError ErrorStack Check
-- | 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
-- | "Desaturate" SaturatedTypeSynonyms
desaturateAllTypeSynonyms :: Type -> Type
replaceAllTypeSynonyms :: (Error e, Functor m, Monad m, MonadState CheckState m, MonadError e m) => Type -> m Type
expandAllTypeSynonyms :: (Error e, Functor m, Applicative m, Monad m, MonadState CheckState m, MonadError e m) => Type -> m Type
expandTypeSynonym :: (Error e, Functor m, Monad m, MonadState CheckState m, MonadError e m) => Qualified ProperName -> [Type] -> m Type
-- | Replace a type synonym and its arguments with the aliased type
expandTypeSynonym' :: Environment -> Qualified ProperName -> [Type] -> Either String Type
-- | 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
-- | 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, Maybe Kind)] -> [Type] -> Check Kind
-- | Simultaneously infer the kinds of several mutually recursive type
-- constructors
kindsOfAll :: ModuleName -> [(ProperName, [(String, Maybe Kind)], Type)] -> [(ProperName, [(String, Maybe Kind)], [Type])] -> Check ([Kind], [Kind])
instance Unifiable Check Kind
instance Partial Kind
-- | 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
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 replaces top-level
-- binders with case expressions.
module Language.PureScript.Sugar.CaseDeclarations
-- | Replace all top-level binders with case expressions.
desugarCases :: [Declaration] -> SupplyT (Either ErrorStack) [Declaration]
-- | Replace all top-level binders in a module with case expressions.
desugarCasesModule :: [Module] -> SupplyT (Either ErrorStack) [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] -> SupplyT (Either ErrorStack) [Module]
typeClassMemberName :: Declaration -> String
superClassDictionaryNames :: [Constraint] -> [String]
-- | The AST -> CoreFn desugaring step
module Language.PureScript.CoreFn.Desugar
-- | Desugars a module from AST to CoreFn representation.
moduleToCoreFn :: Environment -> Module -> Module Ann
-- | The core functional representation
module Language.PureScript.CoreFn
-- | Dead code elimination.
module Language.PureScript.DeadCodeElimination
-- | Eliminate all declarations which are not a transitive dependency of
-- the entry point module
eliminateDeadCode :: [ModuleName] -> [Module a] -> [Module a]
-- | Renaming pass that prevents shadowing of local identifiers.
module Language.PureScript.Renamer
-- | Renames within each declaration in a module.
renameInModules :: [Module Ann] -> [Module Ann]
-- | This module generates code in the simplified Javascript intermediate
-- representation from Purescript code
module Language.PureScript.CodeGen.JS
-- | Generate code in the simplified Javascript intermediate representation
-- for a declaration
bindToJs :: (Functor m, Applicative m, Monad m) => ModuleName -> Bind Ann -> SupplyT m [JS]
-- | Generate code in the simplified Javascript intermediate representation
-- for all declarations in a module.
moduleToJs :: (Functor m, Applicative m, Monad m) => Options mode -> Module Ann -> SupplyT m [JS]
-- | 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
-- | 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 -> SupplyT (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
module Language.PureScript.Sugar.ObjectWildcards
desugarObjectConstructors :: Module -> SupplyT (Either ErrorStack) Module
-- | 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
desugarOperatorSections :: Module -> SupplyT (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]
-- | Desugaring passes
module Language.PureScript.Sugar
-- | The desugaring pipeline proceeds as follows:
--
--
-- - Remove signed literals in favour of negate
-- applications
-- - Desugar object literals with wildcards into lambdas
-- - Desugar operator sections
-- - 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
-- - Qualify any unqualified names and types
-- - Rebracket user-defined binary operators
-- - Introduce type synonyms for type class dictionaries
-- - Group mutually recursive value and data declarations into binding
-- groups.
--
desugar :: [Module] -> SupplyT (Either ErrorStack) [Module]
-- | Functions relating to type checking for rows
module Language.PureScript.TypeChecker.Rows
-- | Ensure rows do not contain duplicate labels
checkDuplicateLabels :: Expr -> Check ()
-- | Functions relating to skolemization used during typechecking
module Language.PureScript.TypeChecker.Skolems
-- | Generate a new skolem constant
newSkolemConstant :: UnifyT Type Check Int
-- | Introduce skolem scope at every occurence of a ForAll
introduceSkolemScope :: Type -> UnifyT Type Check Type
-- | Generate a new skolem scope
newSkolemScope :: UnifyT Type Check SkolemScope
-- | Skolemize a type variable by replacing its instances with fresh skolem
-- constants
skolemize :: String -> Int -> SkolemScope -> Type -> Type
-- | This function has one purpose - to skolemize type variables appearing
-- in a SuperClassDictionary placeholder. These type variables are
-- somewhat unique since they are the only example of scoped type
-- variables.
skolemizeTypesInValue :: String -> Int -> SkolemScope -> Expr -> Expr
-- | Ensure skolem variables do not escape their scope
skolemEscapeCheck :: Expr -> Check ()
-- | Functions and instances relating to unification
module Language.PureScript.TypeChecker.Unify
-- | Unify two types, updating the current substitution
unifyTypes :: Type -> Type -> UnifyT Type Check ()
-- | Unify two rows, updating the current substitution
--
-- Common labels are first identified, and unified. Remaining labels and
-- types are unified with a trailing row unification variable, if
-- appropriate, otherwise leftover labels result in a unification error.
unifyRows :: Type -> Type -> UnifyT Type Check ()
-- | Check that two types unify
unifiesWith :: Environment -> Type -> Type -> Bool
-- | Replace a single type variable with a new unification variable
replaceVarWithUnknown :: String -> Type -> UnifyT Type Check Type
-- | Replace type wildcards with unknowns
replaceTypeWildcards :: Type -> UnifyT t Check Type
-- | Replace outermost unsolved unification variables with named type
-- variables
varIfUnknown :: Type -> Type
instance Unifiable Check Type
instance Partial Type
-- | Type class entailment
module Language.PureScript.TypeChecker.Entailment
-- | Check that the current set of type class dictionaries entail the
-- specified type class goal, and, if so, return a type class dictionary
-- reference.
entails :: Environment -> ModuleName -> [TypeClassDictionaryInScope] -> Constraint -> Bool -> Check Expr
instance Show DictionaryValue
instance Ord DictionaryValue
instance Eq DictionaryValue
-- | Subsumption checking
module Language.PureScript.TypeChecker.Subsumption
-- | Check whether one type subsumes another, rethrowing errors to provide
-- a better error message
subsumes :: Maybe Expr -> Type -> Type -> UnifyT Type Check (Maybe Expr)
-- | 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, Expr)] -> Check [(Ident, (Expr, Type))]
-- | The top-level type checker, which checks all declarations in a module.
module Language.PureScript.TypeChecker
-- | Type check an entire module and ensure all types and classes defined
-- within the module that are required by exported members are also
-- exported.
typeCheckModule :: Maybe ModuleName -> Module -> Check Module
-- | 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 Compile -> [Module] -> [String] -> Either String (String, String, Environment)
compile' :: Environment -> Options Compile -> [Module] -> [String] -> Either String (String, String, Environment)
-- | Determines when to rebuild a module
data RebuildPolicy
-- | Never rebuild this module
RebuildNever :: RebuildPolicy
-- | Always rebuild this module
RebuildAlways :: RebuildPolicy
-- | 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, Applicative m, Monad m, MonadMake m) => FilePath -> Options Make -> [(Either RebuildPolicy FilePath, Module)] -> [String] -> m Environment
prelude :: String
instance Show RebuildPolicy
instance Eq RebuildPolicy
instance Ord RebuildPolicy