ghc-9.6.3: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

GHC.JS.Transform

Contents

- Saturation
- Generic traversal (via compos)

Synopsis

- mapIdent :: (Ident -> JExpr) -> (JExpr -> JExpr, JStat -> JStat)
- mapStatIdent :: (Ident -> JExpr) -> JStat -> JStat
- mapExprIdent :: (Ident -> JExpr) -> JExpr -> JExpr
- identsS :: JStat -> [Ident]
- identsV :: JVal -> [Ident]
- identsE :: JExpr -> [Ident]
- jsSaturate :: JMacro a => Maybe FastString -> a -> a
- class JMacro a where
  - jtoGADT :: a -> JMGadt a
  - jfromGADT :: JMGadt a -> a
- data JMGadt a where
  - JMGId :: Ident -> JMGadt Ident
  - JMGStat :: JStat -> JMGadt JStat
  - JMGExpr :: JExpr -> JMGadt JExpr
  - JMGVal :: JVal -> JMGadt JVal
- class Compos t where
  - compos :: (forall a. a -> m a) -> (forall a b. m (a -> b) -> m a -> m b) -> (forall a. t a -> m (t a)) -> t c -> m (t c)
- composOp :: Compos t => (forall a. t a -> t a) -> t b -> t b
- composOpM :: (Compos t, Monad m) => (forall a. t a -> m (t a)) -> t b -> m (t b)
- composOpM_ :: (Compos t, Monad m) => (forall a. t a -> m ()) -> t b -> m ()
- composOpFold :: Compos t => b -> (b -> b -> b) -> (forall a. t a -> b) -> t c -> b

# Documentation

mapIdent :: (Ident -> JExpr) -> (JExpr -> JExpr, JStat -> JStat) Source #

Map on every variable ident

mapStatIdent :: (Ident -> JExpr) -> JStat -> JStat Source #

mapExprIdent :: (Ident -> JExpr) -> JExpr -> JExpr Source #

identsS :: JStat -> [Ident] Source #

identsV :: JVal -> [Ident] Source #

identsE :: JExpr -> [Ident] Source #

# Saturation

jsSaturate :: JMacro a => Maybe FastString -> a -> a Source #

Given an optional prefix, fills in all free variable names with a supply of names generated by the prefix.

# Generic traversal (via compos)

class JMacro a where Source #

Compos and ops for generic traversal as defined over the JMacro ADT.

Utility class to coerce the ADT into a regular structure.

Methods

jtoGADT :: a -> JMGadt a Source #

jfromGADT :: JMGadt a -> a Source #

#### Instances

Instances details

JMacro Ident Source # |
Instance details Defined in GHC.JS.Transform Methods jtoGADT :: Ident -> JMGadt Ident Source # jfromGADT :: JMGadt Ident -> Ident Source #
JMacro JExpr Source # |
Instance details Defined in GHC.JS.Transform Methods jtoGADT :: JExpr -> JMGadt JExpr Source # jfromGADT :: JMGadt JExpr -> JExpr Source #
JMacro JStat Source # |
Instance details Defined in GHC.JS.Transform Methods jtoGADT :: JStat -> JMGadt JStat Source # jfromGADT :: JMGadt JStat -> JStat Source #
JMacro JVal Source # |
Instance details Defined in GHC.JS.Transform Methods jtoGADT :: JVal -> JMGadt JVal Source # jfromGADT :: JMGadt JVal -> JVal Source #

data JMGadt a where Source #

Union type to allow regular traversal by compos.

Constructors

JMGId :: Ident -> JMGadt Ident |
JMGStat :: JStat -> JMGadt JStat |
JMGExpr :: JExpr -> JMGadt JExpr |
JMGVal :: JVal -> JMGadt JVal |

#### Instances

Instances details

Compos JMGadt Source # |
Instance details Defined in GHC.JS.Transform Methods compos :: (forall a. a -> m a) -> (forall a b. m (a -> b) -> m a -> m b) -> (forall a. JMGadt a -> m (JMGadt a)) -> JMGadt c -> m (JMGadt c) Source #

class Compos t where Source #

Methods

compos :: (forall a. a -> m a) -> (forall a b. m (a -> b) -> m a -> m b) -> (forall a. t a -> m (t a)) -> t c -> m (t c) Source #

#### Instances

Instances details

Compos JMGadt Source # |
Instance details Defined in GHC.JS.Transform Methods compos :: (forall a. a -> m a) -> (forall a b. m (a -> b) -> m a -> m b) -> (forall a. JMGadt a -> m (JMGadt a)) -> JMGadt c -> m (JMGadt c) Source #

composOp :: Compos t => (forall a. t a -> t a) -> t b -> t b Source #

composOpM :: (Compos t, Monad m) => (forall a. t a -> m (t a)) -> t b -> m (t b) Source #

composOpM_ :: (Compos t, Monad m) => (forall a. t a -> m ()) -> t b -> m () Source #

composOpFold :: Compos t => b -> (b -> b -> b) -> (forall a. t a -> b) -> t c -> b Source #