Language.PureScript.Bundle

purescript-0.15.15: PureScript Programming Language Compiler

Safe Haskell | None
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 :: MonadError ErrorMessage m => String -> JSAST -> m ForeignModuleExports
- data ForeignModuleImports = ForeignModuleImports {
  - cjsImports :: [String]
  - esImports :: [String]
  }
- getImportedModules :: 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 #
NFData ModuleIdentifier # |
Instance details Defined in Language.PureScript.Bundle Methods rnf :: ModuleIdentifier -> () #
Generic ModuleIdentifier # |
Instance details Defined in Language.PureScript.Bundle Associated Types
type Rep ModuleIdentifier |
Instance details Defined in Language.PureScript.Bundle type Rep ModuleIdentifier = D1 ('MetaData "ModuleIdentifier" "Language.PureScript.Bundle" "purescript-0.15.15-8K0LbmS63k4ILju2RsIrDp" 'False) (C1 ('MetaCons "ModuleIdentifier" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModuleType)))
Methods from :: ModuleIdentifier -> Rep ModuleIdentifier x # to :: Rep ModuleIdentifier x -> ModuleIdentifier #
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 #
type Rep ModuleIdentifier # |
Instance details Defined in Language.PureScript.Bundle type Rep ModuleIdentifier = D1 ('MetaData "ModuleIdentifier" "Language.PureScript.Bundle" "purescript-0.15.15-8K0LbmS63k4ILju2RsIrDp" 'False) (C1 ('MetaCons "ModuleIdentifier" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModuleType)))

data ModuleType #

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

Constructors

Regular |
Foreign |

#### Instances

Instances details

NFData ModuleType # |
Instance details Defined in Language.PureScript.Bundle Methods rnf :: ModuleType -> () #
Generic ModuleType # |
Instance details Defined in Language.PureScript.Bundle Associated Types
type Rep ModuleType |
Instance details Defined in Language.PureScript.Bundle type Rep ModuleType = D1 ('MetaData "ModuleType" "Language.PureScript.Bundle" "purescript-0.15.15-8K0LbmS63k4ILju2RsIrDp" 'False) (C1 ('MetaCons "Regular" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Foreign" 'PrefixI 'False) (U1 :: Type -> Type))
Methods from :: ModuleType -> Rep ModuleType x # to :: Rep ModuleType x -> ModuleType #
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 #
type Rep ModuleType # |
Instance details Defined in Language.PureScript.Bundle type Rep ModuleType = D1 ('MetaData "ModuleType" "Language.PureScript.Bundle" "purescript-0.15.15-8K0LbmS63k4ILju2RsIrDp" 'False) (C1 ('MetaCons "Regular" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Foreign" 'PrefixI 'False) (U1 :: Type -> Type))

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

NFData ErrorMessage # |
Instance details Defined in Language.PureScript.Bundle Methods rnf :: ErrorMessage -> () #
Generic ErrorMessage # |
Instance details Defined in Language.PureScript.Bundle Associated Types
type Rep ErrorMessage |
Instance details Defined in Language.PureScript.Bundle type Rep ErrorMessage = D1 ('MetaData "ErrorMessage" "Language.PureScript.Bundle" "purescript-0.15.15-8K0LbmS63k4ILju2RsIrDp" 'False) (((C1 ('MetaCons "UnsupportedModulePath" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "InvalidTopLevel" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "UnableToParseModule" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "UnsupportedImport" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "UnsupportedExport" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ErrorInModule" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModuleIdentifier) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ErrorMessage))) :+: (C1 ('MetaCons "MissingEntryPoint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "MissingMainModule" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))))
Methods from :: ErrorMessage -> Rep ErrorMessage x # to :: Rep ErrorMessage x -> ErrorMessage #
Show ErrorMessage # |
Instance details Defined in Language.PureScript.Bundle Methods showsPrec :: Int -> ErrorMessage -> ShowS # show :: ErrorMessage -> String # showList :: [ErrorMessage] -> ShowS #
type Rep ErrorMessage # |
Instance details Defined in Language.PureScript.Bundle type Rep ErrorMessage = D1 ('MetaData "ErrorMessage" "Language.PureScript.Bundle" "purescript-0.15.15-8K0LbmS63k4ILju2RsIrDp" 'False) (((C1 ('MetaCons "UnsupportedModulePath" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "InvalidTopLevel" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "UnableToParseModule" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "UnsupportedImport" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "UnsupportedExport" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ErrorInModule" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ModuleIdentifier) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ErrorMessage))) :+: (C1 ('MetaCons "MissingEntryPoint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "MissingMainModule" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))))

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 :: 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 :: 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 #