purescript-0.15.12: PureScript Programming Language Compiler

Safe Haskell | Safe-Inferred
Language | Haskell2010

Language.PureScript.Bundle

Description

Bundles compiled PureScript modules for the browser.

This module takes as input the individual generated modules from `Make` and performs dead code elimination, filters empty modules, and generates the final JavaScript bundle.

Synopsis

- data ModuleIdentifier = ModuleIdentifier String ModuleType
- data ModuleType
  - = Regular
  - | Foreign
- data ErrorMessage
  - = UnsupportedModulePath String
  - | InvalidTopLevel
  - | UnableToParseModule String
  - | UnsupportedImport
  - | UnsupportedExport
  - | ErrorInModule ModuleIdentifier ErrorMessage
  - | MissingEntryPoint String
  - | MissingMainModule String
- printErrorMessage :: ErrorMessage -> [String]
- data ForeignModuleExports = ForeignModuleExports {
  - cjsExports :: [String]
  - esExports :: [String]
  }
- getExportedIdentifiers :: forall m. MonadError ErrorMessage m => String -> JSAST -> m ForeignModuleExports
- data ForeignModuleImports = ForeignModuleImports {
  - cjsImports :: [String]
  - esImports :: [String]
  }
- getImportedModules :: forall m. MonadError ErrorMessage m => String -> JSAST -> m ForeignModuleImports
- data Module

# Documentation

data ModuleIdentifier #

A module is identified by its module name and its type.

Constructors

ModuleIdentifier String ModuleType |

#### Instances

Instances details

ToJSON ModuleIdentifier # |
Instance details Defined in Language.PureScript.Bundle Methods toJSON :: ModuleIdentifier -> Value # toEncoding :: ModuleIdentifier -> Encoding # toJSONList :: [ModuleIdentifier] -> Value # toEncodingList :: [ModuleIdentifier] -> Encoding # omitField :: ModuleIdentifier -> Bool #
Show ModuleIdentifier # |
Instance details Defined in Language.PureScript.Bundle Methods showsPrec :: Int -> ModuleIdentifier -> ShowS # show :: ModuleIdentifier -> String # showList :: [ModuleIdentifier] -> ShowS #
Eq ModuleIdentifier # |
Instance details Defined in Language.PureScript.Bundle Methods (==) :: ModuleIdentifier -> ModuleIdentifier -> Bool # (/=) :: ModuleIdentifier -> ModuleIdentifier -> Bool #
Ord ModuleIdentifier # |

Instance details

Defined in Language.PureScript.Bundle

Methods

compare :: ModuleIdentifier -> ModuleIdentifier -> Ordering #

(<) :: ModuleIdentifier -> ModuleIdentifier -> Bool #

(<=) :: ModuleIdentifier -> ModuleIdentifier -> Bool #

(>) :: ModuleIdentifier -> ModuleIdentifier -> Bool #

(>=) :: ModuleIdentifier -> ModuleIdentifier -> Bool #

max :: ModuleIdentifier -> ModuleIdentifier -> ModuleIdentifier #

min :: ModuleIdentifier -> ModuleIdentifier -> ModuleIdentifier #

data ModuleType #

Modules are either "regular modules" (i.e. those generated by the PureScript compiler) or foreign modules.

Constructors

Regular |
Foreign |

#### Instances

Instances details

Show ModuleType # |
Instance details Defined in Language.PureScript.Bundle Methods showsPrec :: Int -> ModuleType -> ShowS # show :: ModuleType -> String # showList :: [ModuleType] -> ShowS #
Eq ModuleType # |
Instance details Defined in Language.PureScript.Bundle Methods (==) :: ModuleType -> ModuleType -> Bool # (/=) :: ModuleType -> ModuleType -> Bool #
Ord ModuleType # |
Instance details Defined in Language.PureScript.Bundle Methods compare :: ModuleType -> ModuleType -> Ordering # (<) :: ModuleType -> ModuleType -> Bool # (<=) :: ModuleType -> ModuleType -> Bool # (>) :: ModuleType -> ModuleType -> Bool # (>=) :: ModuleType -> ModuleType -> Bool # max :: ModuleType -> ModuleType -> ModuleType # min :: ModuleType -> ModuleType -> ModuleType #

data ErrorMessage #

The type of error messages. We separate generation and rendering of errors using a data type, in case we need to match on error types later.

Constructors

UnsupportedModulePath String |
InvalidTopLevel |
UnableToParseModule String |
UnsupportedImport |
UnsupportedExport |
ErrorInModule ModuleIdentifier ErrorMessage |
MissingEntryPoint String |
MissingMainModule String |

#### Instances

Instances details

Show ErrorMessage # |
Instance details Defined in Language.PureScript.Bundle Methods showsPrec :: Int -> ErrorMessage -> ShowS # show :: ErrorMessage -> String # showList :: [ErrorMessage] -> ShowS #

printErrorMessage :: ErrorMessage -> [String] #

Prepare an error message for consumption by humans.

data ForeignModuleExports #

Constructors

ForeignModuleExports |

Fields

- cjsExports :: [String]
- esExports :: [String]

#### Instances

Instances details

Monoid ForeignModuleExports # |
Instance details Defined in Language.PureScript.Bundle Methods mempty :: ForeignModuleExports # mappend :: ForeignModuleExports -> ForeignModuleExports -> ForeignModuleExports # mconcat :: [ForeignModuleExports] -> ForeignModuleExports #
Semigroup ForeignModuleExports # |
Instance details Defined in Language.PureScript.Bundle Methods (<>) :: ForeignModuleExports -> ForeignModuleExports -> ForeignModuleExports # sconcat :: NonEmpty ForeignModuleExports -> ForeignModuleExports # stimes :: Integral b => b -> ForeignModuleExports -> ForeignModuleExports #
Show ForeignModuleExports # |
Instance details Defined in Language.PureScript.Bundle Methods showsPrec :: Int -> ForeignModuleExports -> ShowS # show :: ForeignModuleExports -> String # showList :: [ForeignModuleExports] -> ShowS #

getExportedIdentifiers :: forall m. MonadError ErrorMessage m => String -> JSAST -> m ForeignModuleExports #

data ForeignModuleImports #

Constructors

ForeignModuleImports |

Fields

- cjsImports :: [String]
- esImports :: [String]

#### Instances

Instances details

Monoid ForeignModuleImports # |
Instance details Defined in Language.PureScript.Bundle Methods mempty :: ForeignModuleImports # mappend :: ForeignModuleImports -> ForeignModuleImports -> ForeignModuleImports # mconcat :: [ForeignModuleImports] -> ForeignModuleImports #
Semigroup ForeignModuleImports # |
Instance details Defined in Language.PureScript.Bundle Methods (<>) :: ForeignModuleImports -> ForeignModuleImports -> ForeignModuleImports # sconcat :: NonEmpty ForeignModuleImports -> ForeignModuleImports # stimes :: Integral b => b -> ForeignModuleImports -> ForeignModuleImports #
Show ForeignModuleImports # |
Instance details Defined in Language.PureScript.Bundle Methods showsPrec :: Int -> ForeignModuleImports -> ShowS # show :: ForeignModuleImports -> String # showList :: [ForeignModuleImports] -> ShowS #

getImportedModules :: forall m. MonadError ErrorMessage m => String -> JSAST -> m ForeignModuleImports #

data Module #

A module is just a list of elements of the types listed above.

#### Instances

Instances details

ToJSON Module # |
Instance details Defined in Language.PureScript.Bundle Methods toJSON :: Module -> Value # toEncoding :: Module -> Encoding # toJSONList :: [Module] -> Value # toEncodingList :: [Module] -> Encoding # omitField :: Module -> Bool #
Show Module # |
Instance details Defined in Language.PureScript.Bundle Methods showsPrec :: Int -> Module -> ShowS # show :: Module -> String # showList :: [Module] -> ShowS #