GHC.JS.Ident

ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Copyright | (c) The University of Glasgow 2001
License | BSD-style (see the file LICENSE)
Maintainer | Jeffrey Young <jeffrey.young@iohk.io> Luite Stegeman <luite.stegeman@iohk.io> Sylvain Henry <sylvain.henry@iohk.io> Josh Meredith <josh.meredith@iohk.io>
Stability | experimental
Safe Haskell | Ignore
Language | GHC2021

GHC.JS.Ident

Description

- Domain and Purpose

  GHC.JS.Ident defines identifiers for the JS backend. We keep this module separate to prevent coupling between GHC and the backend and between unrelated modules is the JS backend.

- Consumers

  The entire JavaScript Backend consumes this module including modules in GHC.JS.* and modules in GHC.StgToJS.*

- Additional Notes

  This module should be kept as small as possible. Anything added to it will be coupled to the JS backend EDSL and the JS Backend including the linker and rts. You have been warned.

Synopsis

- newtype Ident = TxtI {
  - identFS :: FastString
  }
- name :: FastString -> Ident

# Documentation

newtype Ident #

A newtype wrapper around `FastString` for JS identifiers.

Constructors

TxtI |
Fields identFS :: FastString

#### Instances

Instances details

Show Ident # |
Instance details Defined in GHC.JS.Ident Methods showsPrec :: Int -> Ident -> ShowS # show :: Ident -> String # showList :: [Ident] -> ShowS #
JVarMagic Ident # |
Instance details Defined in GHC.JS.Make Methods fresh :: JSM Ident #
ToJExpr Ident # |
Instance details Defined in GHC.JS.Make Methods toJExpr :: Ident -> JStgExpr # toJExprFromList :: [Ident] -> JStgExpr #
JsToDoc Ident # |
Instance details Defined in GHC.JS.Ppr Methods jsToDocR :: JsRender doc => RenderJs doc -> Ident -> doc #
Uniquable Ident # |
Instance details Defined in GHC.JS.Ident Methods getUnique :: Ident -> Unique #
Binary Ident # |
Instance details Defined in GHC.StgToJS.Object Methods put_ :: WriteBinHandle -> Ident -> IO () # put :: WriteBinHandle -> Ident -> IO (Bin Ident) # get :: ReadBinHandle -> IO Ident #
Outputable Ident # |
Instance details Defined in GHC.JS.Ident Methods ppr :: Ident -> SDoc #
Eq Ident # |
Instance details Defined in GHC.JS.Ident Methods (==) :: Ident -> Ident -> Bool # (/=) :: Ident -> Ident -> Bool #

name :: FastString -> Ident #

To give a thing a name is to have power over it. This smart constructor serves two purposes: first, it isolates the JS backend from the rest of GHC. The backend should not explicitly use types provided by GHC but instead should wrap them such as we do here. Second it creates a symbol in the JS backend, but it does not yet give that symbols meaning. Giving the symbol meaning only occurs once it is used with a combinator from `GHC.JS.Make`.