HORIZON HASKELLDocslts/ghc-9.14.xb2f3bfd2026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · b2f3bfd · 2026-10-11

Moduleghc-lib-parser-9.14.1.20251220GHC2021

GHC.JS.Syntax

  • Domain and Purpose

    GHC.JS.Syntax defines the Syntax for the JS backend in GHC. It comports with the ECMA-262 although not every production rule of the standard is represented. Code in this module is a fork of JMacro (BSD 3 Clause) by Gershom Bazerman, heavily modified to accomodate GHC's constraints.

  • Strategy

    Nothing fancy in this module, this is a classic deeply embedded AST for JS. We define numerous ADTs and pattern synonyms to make pattern matching and constructing ASTs easier.

  • Consumers

    The entire JS backend consumes this module, e.g., the modules in GHC.StgToJS.*. Please see GHC.JS.Make for a module which provides helper functions that use the deeply embedded DSL defined in this module to provide some of the benefits of a shallow embedding.

  • 9 types
  • 3 values

Deeply embedded JS datatypes

8 declarations
datadata JStat
#

JavaScript statements, see the ECMA262 Reference for details

Constructors

Instances8Eq, Generic, Semigroup, Monoid, Binary, JsToDoc, …
datadata JExpr
#

JavaScript Expressions

Constructors

Instances7Eq, Generic, Outputable, Binary, JsToDoc, Rep, …
datadata JVal
#

JavaScript values

Constructors

Instances6Eq, Generic, Outputable, Binary, JsToDoc, Rep
datadata Op
#

JS Binary Operators. We do not deeply embed the comma operator and the assignment operators

Constructors

Instances9Enum, Eq, Data, Ord, Show, Generic, …
datadata UOp
#

JS Unary Operators

Constructors

Instances9Enum, Eq, Data, Ord, Show, Generic, …
datadata AOp
#

JS Unary Operators

Constructors

Instances9Enum, Eq, Data, Ord, Show, Generic, …
  • Enum AOpDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Syntax
  • Eq AOpDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Syntax
  • Data AOpDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Syntax
  • Ord AOpDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Syntax
  • Show AOpDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Syntax
  • Generic AOpDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Syntax
  • NFData AOpDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Syntax
  • Binary AOpDefined in ghc-lib-parser-9.14.1.20251220 · GHC.StgToJS.Object · orphan
  • type Rep AOp = D1 ('MetaData "AOp" "GHC.JS.Syntax" "ghc-lib-parser-9.14.1.20251220-2HxJziFvlvq9nNTVQhN5nL" 'False) (C1 ('MetaCons "AssignOp" 'PrefixI 'False) U1 :+: (C1 ('MetaCons "AddAssignOp" 'PrefixI 'False) U1 :+: C1 ('MetaCons "SubAssignOp" 'PrefixI 'False) U1))Defined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Syntax
newtypenewtype Ident
#

A newtype wrapper around FastString for JS identifiers.

Constructors

Instances8Eq, Show, Uniquable, Outputable, Binary, JVarMagic, …
  • Eq IdentDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Ident
  • Show IdentDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Ident
  • Uniquable IdentDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Ident
  • Outputable IdentDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Ident
  • Binary IdentDefined in ghc-lib-parser-9.14.1.20251220 · GHC.StgToJS.Object · orphan
  • JVarMagic IdentDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Make
  • ToJExpr IdentDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Make
  • JsToDoc IdentDefined in ghc-lib-parser-9.14.1.20251220 · GHC.JS.Ppr

pattern synonyms over JS operators

21 declarations
patternpattern New :: JExpr -> JExpr
#

pattern synonym for a unary operator new

patternpattern Not :: JExpr -> JExpr
#

pattern synonym for logical not !

patternpattern BNot :: JExpr -> JExpr
#

pattern synonym for Bitwise Not ~

patternpattern Int :: Integer -> JExpr
#

pattern synonym to create integer values

patternpattern Var :: Ident -> JExpr
#

pattern synonym to create a local variable reference

patternpattern PreInc :: JExpr -> JExpr
#

pattern synonym for prefix increment ++x

patternpattern PreDec :: JExpr -> JExpr
#

pattern synonym for prefix decrement --x

Utility

4 declarations
newtypenewtype SaneDouble
#

A newtype wrapper around Double to ensure we never generate a Double that becomes a NaN, see instances for details on sanity.

Instances6Eq, Fractional, Num, Ord, Show, Binary
  • Eq SaneDoubleDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.SaneDouble
  • Fractional SaneDoubleDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.SaneDouble
  • Num SaneDoubleDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.SaneDouble
  • Ord SaneDoubleDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.SaneDouble
  • Show SaneDoubleDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.SaneDouble
  • Binary SaneDoubleDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Types.SaneDouble