-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | PureScript Programming Language Compiler -- -- A small strongly, statically typed programming language with -- expressive types, inspired by Haskell and compiling to Javascript. @package purescript @version 0.5.7.1 -- | 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 -- | 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 -- | 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 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 -- | Optimizer steps for simplifying Javascript blocks module Language.PureScript.Optimizer.Blocks -- | Collapse blocks which appear nested directly below another block collapseNestedBlocks :: JS -> JS collapseNestedIfs :: 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 (&) :: String bar :: 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 runSTArray :: String stRefValue :: String newSTRef :: String readSTRef :: String writeSTRef :: String modifySTRef :: String peekSTArray :: String pokeSTArray :: String mkFn :: String runFn :: 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 -- | Removes unused variables module Language.PureScript.Optimizer.Unused removeCodeAfterReturnStatements :: JS -> JS removeUnusedArg :: JS -> JS removeUndefinedApp :: JS -> JS -- | 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) -- | This module implements tail call elimination. module Language.PureScript.Optimizer.TCO -- | Eliminate tail calls tco :: Options mode -> 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 -- | Constants, and utility functions to be used when parsing module Language.PureScript.Parser.Common -- | A list of purescript reserved identifiers reservedPsNames :: [String] -- | The characters allowed for use in operators opChars :: [Char] -- | 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 -- | 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 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 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 -- | 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 -> 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 [(Qualified ProperName, [Type])] -- | 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 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)], [(Qualified ProperName, [Type])]) -> 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)], [(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 -- | 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) 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 -- | 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 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] -> (Maybe Guard) -> 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 -> [(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 set of identifiers to hide, optional qualified as -- name) ImportDeclaration :: ModuleName -> ImportDeclarationType -> (Maybe ModuleName) -> Declaration -- | A type class declaration (name, argument, implies, member -- declarations) TypeClassDeclaration :: ProperName -> [(String, Maybe Kind)] -> [(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 = 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 -- | An array literal ArrayLiteral :: [Expr] -> Expr -- | An object literal ObjectLiteral :: [(String, Expr)] -> Expr -- | An record property accessor expression Accessor :: String -> Expr -> Expr -- | Partial record update ObjectUpdate :: Expr -> [(String, 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 -> (Qualified ProperName, [Type]) -> [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 :: SourcePos -> Expr -> Expr -- | An alternative in a case statement data CaseAlternative CaseAlternative :: [Binder] -> Maybe Guard -> Expr -> 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 -> Expr -- | 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 :: 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 :: 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) -> (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) instance Typeable Associativity instance Typeable SourcePos instance Typeable Fixity instance Typeable DeclarationRef instance Typeable ImportDeclarationType instance Typeable Binder instance Typeable Declaration instance Typeable Expr 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 ImportDeclarationType instance Data ImportDeclarationType instance Show Binder instance Data Binder instance Show Declaration instance Data Declaration instance Show Expr instance Data Expr 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] -- | Common code generation utility functions module Language.PureScript.CodeGen.Common -- | Convert an Ident into a valid Javascript identifier: -- --