jmacro-0.6.17.1: QuasiQuotation library for programmatic generation of Javascript code.
Copyright(c) Gershom Bazerman 2010
LicenseBSD 3 Clause
Maintainergershomb@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Language.Javascript.JMacro

Description

Simple DSL for lightweight (untyped) programmatic generation of Javascript.

A number of examples are available in the source of Language.Javascript.JMacro.Prelude.

Functions to generate generic RPC wrappers (using json serialization) are available in Language.Javascript.JMacro.Rpc.

usage:

renderJs [jmacro|fun id x -> x|]

The above produces the id function at the top level.

renderJs [jmacro|var id = \x -> x;|]

So does the above here. However, as id is brought into scope by the keyword var, you do not get a variable named id in the generated javascript, but a variable with an arbitrary unique identifier.

renderJs [jmacro|var !id = \x -> x;|]

The above, by using the bang special form in a var declaration, produces a variable that really is named id.

renderJs [jmacro|function id(x) {return x;}|]

The above is also id.

renderJs [jmacro|function !id(x) {return x;}|]

As is the above (with the correct name).

renderJs [jmacro|fun id x {return x;}|]

As is the above.

renderJs [jmacroE|foo(x,y)|]

The above is an expression representing the application of foo to x and y.

renderJs [jmacroE|foo x y|]]

As is the above.

renderJs [jmacroE|foo (x,y)|]

While the above is an error. (i.e. standard javascript function application cannot seperate the leading parenthesis of the argument from the function being applied)

\x -> [jmacroE|foo `(x)`|]

The above is a haskell expression that provides a function that takes an x, and yields an expression representing the application of foo to the value of x as transformed to a Javascript expression.

[jmacroE|\x ->`(foo x)`|]

Meanwhile, the above lambda is in Javascript, and brings the variable into scope both in javascript and in the enclosed antiquotes. The expression is a Javascript function that takes an x, and yields an expression produced by the application of the Haskell function foo as applied to the identifier x (which is of type JExpr -- i.e. a Javascript expression).

Other than that, the language is essentially Javascript (1.5). Note however that one must use semicolons in a principled fashion -- i.e. to end statements consistently. Otherwise, the parser will mistake the whitespace for a whitespace application, and odd things will occur. A further gotcha exists in regex literals, whicch cannot begin with a space. x 5 4 parses as ((x 5) 4). However, x 5 4 will parse as x(5 , 4). Such are the perils of operators used as delimeters in the presence of whitespace application.

Additional features in jmacro (documented on the wiki) include an infix application operator, and an enhanced destructuring bind.

Additional datatypes can be marshalled to Javascript by proper instance declarations for the ToJExpr class.

An experimental typechecker is available in the Language.Javascript.JMacro.Typed module.

Synopsis

Documentation

jmacro :: QuasiQuoter Source #

QuasiQuoter for a block of JMacro statements.

jmacroE :: QuasiQuoter Source #

QuasiQuoter for a JMacro expression.

class ToStat a where Source #

Methods

toStat :: a -> JStat Source #

Instances

Instances details
ToStat JExpr Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toStat :: JExpr -> JStat Source #

ToStat JStat Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toStat :: JStat -> JStat Source #

ToStat [JExpr] Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toStat :: [JExpr] -> JStat Source #

ToStat [JStat] Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toStat :: [JStat] -> JStat Source #

class ToJExpr a where Source #

Things that can be marshalled into javascript values. Instantiate for any necessary data structures.

Minimal complete definition

toJExpr

Methods

toJExpr :: a -> JExpr Source #

toJExprFromList :: [a] -> JExpr Source #

Instances

Instances details
ToJExpr Bool Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

ToJExpr Char Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

ToJExpr Double Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

ToJExpr Int Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

ToJExpr Integer Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

ToJExpr () Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toJExpr :: () -> JExpr Source #

toJExprFromList :: [()] -> JExpr Source #

ToJExpr Text Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

ToJExpr Value Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

ToJExpr Text Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

ToJExpr JVal Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

ToJExpr JExpr Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

ToJExpr a => ToJExpr [a] Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toJExpr :: [a] -> JExpr Source #

toJExprFromList :: [[a]] -> JExpr Source #

(ToJExpr a, ToJExpr b) => ToJExpr (a, b) Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toJExpr :: (a, b) -> JExpr Source #

toJExprFromList :: [(a, b)] -> JExpr Source #

ToJExpr a => ToJExpr (Map String a) Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

(ToJExpr a, ToJExpr b, ToJExpr c) => ToJExpr (a, b, c) Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toJExpr :: (a, b, c) -> JExpr Source #

toJExprFromList :: [(a, b, c)] -> JExpr Source #

(ToJExpr a, ToJExpr b, ToJExpr c, ToJExpr d) => ToJExpr (a, b, c, d) Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toJExpr :: (a, b, c, d) -> JExpr Source #

toJExprFromList :: [(a, b, c, d)] -> JExpr Source #

(ToJExpr a, ToJExpr b, ToJExpr c, ToJExpr d, ToJExpr e) => ToJExpr (a, b, c, d, e) Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toJExpr :: (a, b, c, d, e) -> JExpr Source #

toJExprFromList :: [(a, b, c, d, e)] -> JExpr Source #

(ToJExpr a, ToJExpr b, ToJExpr c, ToJExpr d, ToJExpr e, ToJExpr f) => ToJExpr (a, b, c, d, e, f) Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toJExpr :: (a, b, c, d, e, f) -> JExpr Source #

toJExprFromList :: [(a, b, c, d, e, f)] -> JExpr Source #

class JsToDoc a where Source #

Methods

jsToDoc :: a -> Doc Source #

Instances

Instances details
JsToDoc JLocalType Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

JsToDoc JType Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: JType -> Doc Source #

JsToDoc Ident Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: Ident -> Doc Source #

JsToDoc JVal Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: JVal -> Doc Source #

JsToDoc JExpr Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: JExpr -> Doc Source #

JsToDoc JStat Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: JStat -> Doc Source #

JsToDoc [JExpr] Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: [JExpr] -> Doc Source #

JsToDoc [JStat] Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: [JStat] -> Doc 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 Language.Javascript.JMacro.Base

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 #

data JMGadt a where Source #

Union type to allow regular traversal by compos.

Instances

Instances details
Compos JMGadt Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

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 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 #

newtype Ident Source #

Identifiers

Constructors

StrI String 

Instances

Instances details
Eq Ident Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

(==) :: Ident -> Ident -> Bool #

(/=) :: Ident -> Ident -> Bool #

Data Ident Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Ident -> c Ident #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Ident #

toConstr :: Ident -> Constr #

dataTypeOf :: Ident -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Ident) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Ident) #

gmapT :: (forall b. Data b => b -> b) -> Ident -> Ident #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Ident -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Ident -> r #

gmapQ :: (forall d. Data d => d -> u) -> Ident -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Ident -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Ident -> m Ident #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Ident -> m Ident #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Ident -> m Ident #

Ord Ident Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

compare :: Ident -> Ident -> Ordering #

(<) :: Ident -> Ident -> Bool #

(<=) :: Ident -> Ident -> Bool #

(>) :: Ident -> Ident -> Bool #

(>=) :: Ident -> Ident -> Bool #

max :: Ident -> Ident -> Ident #

min :: Ident -> Ident -> Ident #

Show Ident Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

showsPrec :: Int -> Ident -> ShowS #

show :: Ident -> String #

showList :: [Ident] -> ShowS #

JsToDoc Ident Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: Ident -> Doc Source #

JMacro Ident Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

newtype SaneDouble Source #

Constructors

SaneDouble Double 

Instances

Instances details
Eq SaneDouble Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Fractional SaneDouble Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Data SaneDouble Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SaneDouble -> c SaneDouble #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SaneDouble #

toConstr :: SaneDouble -> Constr #

dataTypeOf :: SaneDouble -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SaneDouble) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SaneDouble) #

gmapT :: (forall b. Data b => b -> b) -> SaneDouble -> SaneDouble #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SaneDouble -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SaneDouble -> r #

gmapQ :: (forall d. Data d => d -> u) -> SaneDouble -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SaneDouble -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SaneDouble -> m SaneDouble #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SaneDouble -> m SaneDouble #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SaneDouble -> m SaneDouble #

Num SaneDouble Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Ord SaneDouble Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Show SaneDouble Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

data JVal Source #

Values

Instances

Instances details
Eq JVal Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

(==) :: JVal -> JVal -> Bool #

(/=) :: JVal -> JVal -> Bool #

Data JVal Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> JVal -> c JVal #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c JVal #

toConstr :: JVal -> Constr #

dataTypeOf :: JVal -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c JVal) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c JVal) #

gmapT :: (forall b. Data b => b -> b) -> JVal -> JVal #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> JVal -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> JVal -> r #

gmapQ :: (forall d. Data d => d -> u) -> JVal -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> JVal -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> JVal -> m JVal #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> JVal -> m JVal #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> JVal -> m JVal #

Ord JVal Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

compare :: JVal -> JVal -> Ordering #

(<) :: JVal -> JVal -> Bool #

(<=) :: JVal -> JVal -> Bool #

(>) :: JVal -> JVal -> Bool #

(>=) :: JVal -> JVal -> Bool #

max :: JVal -> JVal -> JVal #

min :: JVal -> JVal -> JVal #

Show JVal Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

showsPrec :: Int -> JVal -> ShowS #

show :: JVal -> String #

showList :: [JVal] -> ShowS #

ToJExpr JVal Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

JsToDoc JVal Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: JVal -> Doc Source #

JMacro JVal Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

JTypeCheck JVal Source # 
Instance details

Defined in Language.Javascript.JMacro.TypeCheck

data JExpr Source #

Expressions

Instances

Instances details
Eq JExpr Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

(==) :: JExpr -> JExpr -> Bool #

(/=) :: JExpr -> JExpr -> Bool #

Data JExpr Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> JExpr -> c JExpr #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c JExpr #

toConstr :: JExpr -> Constr #

dataTypeOf :: JExpr -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c JExpr) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c JExpr) #

gmapT :: (forall b. Data b => b -> b) -> JExpr -> JExpr #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> JExpr -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> JExpr -> r #

gmapQ :: (forall d. Data d => d -> u) -> JExpr -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> JExpr -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> JExpr -> m JExpr #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> JExpr -> m JExpr #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> JExpr -> m JExpr #

Num JExpr Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Ord JExpr Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

compare :: JExpr -> JExpr -> Ordering #

(<) :: JExpr -> JExpr -> Bool #

(<=) :: JExpr -> JExpr -> Bool #

(>) :: JExpr -> JExpr -> Bool #

(>=) :: JExpr -> JExpr -> Bool #

max :: JExpr -> JExpr -> JExpr #

min :: JExpr -> JExpr -> JExpr #

Show JExpr Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

showsPrec :: Int -> JExpr -> ShowS #

show :: JExpr -> String #

showList :: [JExpr] -> ShowS #

ToStat JExpr Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toStat :: JExpr -> JStat Source #

ToJExpr JExpr Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

JsToDoc JExpr Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: JExpr -> Doc Source #

JMacro JExpr Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

JTypeCheck JExpr Source # 
Instance details

Defined in Language.Javascript.JMacro.TypeCheck

ToStat [JExpr] Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toStat :: [JExpr] -> JStat Source #

JsToDoc [JExpr] Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: [JExpr] -> Doc Source #

data JStat Source #

Statements

Instances

Instances details
Eq JStat Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

(==) :: JStat -> JStat -> Bool #

(/=) :: JStat -> JStat -> Bool #

Data JStat Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> JStat -> c JStat #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c JStat #

toConstr :: JStat -> Constr #

dataTypeOf :: JStat -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c JStat) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c JStat) #

gmapT :: (forall b. Data b => b -> b) -> JStat -> JStat #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> JStat -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> JStat -> r #

gmapQ :: (forall d. Data d => d -> u) -> JStat -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> JStat -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> JStat -> m JStat #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> JStat -> m JStat #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> JStat -> m JStat #

Ord JStat Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

compare :: JStat -> JStat -> Ordering #

(<) :: JStat -> JStat -> Bool #

(<=) :: JStat -> JStat -> Bool #

(>) :: JStat -> JStat -> Bool #

(>=) :: JStat -> JStat -> Bool #

max :: JStat -> JStat -> JStat #

min :: JStat -> JStat -> JStat #

Show JStat Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

showsPrec :: Int -> JStat -> ShowS #

show :: JStat -> String #

showList :: [JStat] -> ShowS #

Semigroup JStat Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

(<>) :: JStat -> JStat -> JStat #

sconcat :: NonEmpty JStat -> JStat #

stimes :: Integral b => b -> JStat -> JStat #

Monoid JStat Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

mempty :: JStat #

mappend :: JStat -> JStat -> JStat #

mconcat :: [JStat] -> JStat #

ToStat JStat Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toStat :: JStat -> JStat Source #

JsToDoc JStat Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: JStat -> Doc Source #

JMacro JStat Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

JTypeCheck JStat Source # 
Instance details

Defined in Language.Javascript.JMacro.TypeCheck

ToStat [JStat] Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

toStat :: [JStat] -> JStat Source #

JsToDoc [JStat] Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: [JStat] -> Doc Source #

newtype IdentSupply a Source #

Constructors

IS 

Fields

Instances

Instances details
Functor IdentSupply Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

fmap :: (a -> b) -> IdentSupply a -> IdentSupply b #

(<$) :: a -> IdentSupply b -> IdentSupply a #

Eq a => Eq (IdentSupply a) Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Data a => Data (IdentSupply a) Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> IdentSupply a -> c (IdentSupply a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (IdentSupply a) #

toConstr :: IdentSupply a -> Constr #

dataTypeOf :: IdentSupply a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (IdentSupply a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (IdentSupply a)) #

gmapT :: (forall b. Data b => b -> b) -> IdentSupply a -> IdentSupply a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> IdentSupply a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> IdentSupply a -> r #

gmapQ :: (forall d. Data d => d -> u) -> IdentSupply a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> IdentSupply a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> IdentSupply a -> m (IdentSupply a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> IdentSupply a -> m (IdentSupply a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> IdentSupply a -> m (IdentSupply a) #

Ord a => Ord (IdentSupply a) Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Show a => Show (IdentSupply a) Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

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 #

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

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

withHygiene :: JMacro a => (a -> a) -> a -> a Source #

Apply a transformation to a fully saturated syntax tree, taking care to return any free variables back to their free state following the transformation. As the transformation preserves free variables, it is hygienic.

scopify :: JStat -> JStat Source #

Takes a fully saturated expression and transforms it to use unique variables that respect scope.

renderJs :: (JsToDoc a, JMacro a) => a -> Doc Source #

Render a syntax tree as a pretty-printable document (simply showing the resultant doc produces a nice, well formatted String).

renderPrefixJs :: (JsToDoc a, JMacro a) => String -> a -> Doc Source #

Render a syntax tree as a pretty-printable document, using a given prefix to all generated names. Use this with distinct prefixes to ensure distinct generated names between independent calls to render(Prefix)Js.

jLam :: ToSat a => a -> JExpr Source #

Create a new anonymous function. The result is an expression. Usage: jLam $ x y -> {JExpr involving x and y}

jVar :: ToSat a => a -> JStat Source #

Introduce a new variable into scope for the duration of the enclosed expression. The result is a block statement. Usage: jVar $ x y -> {JExpr involving x and y}

jVarTy :: ToSat a => a -> Maybe JLocalType -> JStat Source #

Introduce a new variable with optional type into scope for the duration of the enclosed expression. The result is a block statement. Usage: jVar $ x y -> {JExpr involving x and y}

jForIn :: ToSat a => JExpr -> (JExpr -> a) -> JStat Source #

Create a for in statement. Usage: jForIn {expression} $ x -> {block involving x}

jForEachIn :: ToSat a => JExpr -> (JExpr -> a) -> JStat Source #

As with "jForIn" but creating a "for each in" statement.

jTryCatchFinally :: ToSat a => JStat -> a -> JStat -> JStat Source #

jFor :: (ToJExpr a, ToStat b) => JStat -> a -> JStat -> b -> JStat Source #

data JType Source #

Instances

Instances details
Eq JType Source # 
Instance details

Defined in Language.Javascript.JMacro.Types

Methods

(==) :: JType -> JType -> Bool #

(/=) :: JType -> JType -> Bool #

Data JType Source # 
Instance details

Defined in Language.Javascript.JMacro.Types

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> JType -> c JType #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c JType #

toConstr :: JType -> Constr #

dataTypeOf :: JType -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c JType) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c JType) #

gmapT :: (forall b. Data b => b -> b) -> JType -> JType #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> JType -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> JType -> r #

gmapQ :: (forall d. Data d => d -> u) -> JType -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> JType -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> JType -> m JType #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> JType -> m JType #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> JType -> m JType #

Ord JType Source # 
Instance details

Defined in Language.Javascript.JMacro.Types

Methods

compare :: JType -> JType -> Ordering #

(<) :: JType -> JType -> Bool #

(<=) :: JType -> JType -> Bool #

(>) :: JType -> JType -> Bool #

(>=) :: JType -> JType -> Bool #

max :: JType -> JType -> JType #

min :: JType -> JType -> JType #

Read JType Source # 
Instance details

Defined in Language.Javascript.JMacro.Types

Show JType Source # 
Instance details

Defined in Language.Javascript.JMacro.Types

Methods

showsPrec :: Int -> JType -> ShowS #

show :: JType -> String #

showList :: [JType] -> ShowS #

JsToDoc JLocalType Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

JsToDoc JType Source # 
Instance details

Defined in Language.Javascript.JMacro.Base

Methods

jsToDoc :: JType -> Doc Source #

Compos1 JType Source # 
Instance details

Defined in Language.Javascript.JMacro.TypeCheck

Methods

compos1 :: (forall a. a -> m a) -> (forall a b. m (a -> b) -> m a -> m b) -> (JType -> m JType) -> JType -> m JType Source #