purescript-0.15.15: PureScript Programming Language Compiler

Safe Haskell | None
Language | Haskell2010

Language.PureScript.Sugar.Operators

Description

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.

Synopsis

- desugarSignedLiterals :: Module -> Module
- data RebracketCaller
  - = CalledByCompile
  - | CalledByDocs
- rebracket :: (MonadError MultipleErrors m, MonadSupply m) => [ExternsFile] -> Module -> m Module
- rebracketFiltered :: (MonadError MultipleErrors m, MonadSupply m) => RebracketCaller -> (Declaration -> Bool) -> [ExternsFile] -> Module -> m Module
- checkFixityExports :: MonadError MultipleErrors m => Module -> m Module

# Documentation

desugarSignedLiterals :: Module -> Module #

Removes unary negation operators and replaces them with calls to `negate`.

data RebracketCaller #

Indicates whether the `rebracketModule` is being called with the full desugar pass run via `purs compile` or whether only the partial desugar pass is run via `purs docs`. This indication is needed to prevent a `purs docs` error when using `case _ of` syntax in a type class instance.

Constructors

CalledByCompile |
CalledByDocs |

#### Instances

Instances details

Show RebracketCaller # |
Instance details Defined in Language.PureScript.Sugar.Operators Methods showsPrec :: Int -> RebracketCaller -> ShowS # show :: RebracketCaller -> String # showList :: [RebracketCaller] -> ShowS #
Eq RebracketCaller # |
Instance details Defined in Language.PureScript.Sugar.Operators Methods (==) :: RebracketCaller -> RebracketCaller -> Bool # (/=) :: RebracketCaller -> RebracketCaller -> Bool #

rebracket :: (MonadError MultipleErrors m, MonadSupply m) => [ExternsFile] -> Module -> m Module #

Remove explicit parentheses and reorder binary operator applications.

This pass requires name desugaring and export elaboration to have run first.

rebracketFiltered :: (MonadError MultipleErrors m, MonadSupply m) => RebracketCaller -> (Declaration -> Bool) -> [ExternsFile] -> Module -> m Module #

A version of `rebracket` which allows you to choose which declarations should be affected. This is used in docs generation, where we want to desugar type operators in instance declarations to ensure that instances are paired up with their types correctly, but we don't want to desugar type operators in value declarations.

checkFixityExports :: MonadError MultipleErrors m => Module -> m Module #

Checks all the fixity exports within a module to ensure that members aliased by the operators are also exported from the module.

This pass requires name desugaring and export elaboration to have run first.