ghc-9.12: The GHC API
Copyright(c) The University of Glasgow 2001
LicenseBSD-style (see the file LICENSE)
MaintainerJeffrey Young <jeffrey.young@iohk.io> Luite Stegeman <luite.stegeman@iohk.io> Sylvain Henry <sylvain.henry@iohk.io> Josh Meredith <josh.meredith@iohk.io>
Stabilityexperimental
Safe HaskellNone
LanguageGHC2021

GHC.JS.JStg.Monad

Description

  • Domain and Purpose

    GHC.JS.JStg.Monad defines the computational environment for the eDSL that we use to write the JS Backend's RTS. Its purpose is to ensure unique identifiers are generated throughout the backend and that we can use the host language to ensure references are not mixed.

  • Strategy

    The monad is a straightforward state monad which holds an environment holds a pointer to a prefix to tag identifiers with and an infinite stream of identifiers.

  • Usage

    One should almost never need to directly use the functions in this module. Instead one should opt to use the combinators in Make, the sole exception to this is the withTag function which is used to change the prefix of identifiers for a given computation. For example, the rts uses this function to tag all identifiers generated by the RTS code as RTS_N, where N is some unique.

Synopsis

Documentation

runJSM :: JEnv -> JSM a -> a Source #

type JSM a = State JEnv a Source #

withTag Source #

Arguments

:: FastString

new name to tag with

-> JSM a

action to run with new tags

-> JSM a

result

tag the name generater with a prefix for the monadic action.

newIdent :: JSM Ident Source #

generate a fresh Ident

initJSM :: IO JEnv Source #