HJScript-0.7.0: HJScript is a Haskell EDSL for writing JavaScript programs.

Stabilityexperimental
MaintainerJoel Bjornson joel.bjornson@gmail.com, Niklas Broberg nibro@cs.chalmers.se
Safe HaskellNone

HJScript.Lang

Description

 

Synopsis

Documentation

preinc :: Num t => Var t -> HJScript ()Source

Incrementing or decrementing numbers.

postinc :: Num t => Var t -> HJScript ()Source

predec :: Num t => Var t -> HJScript ()Source

postdec :: Num t => Var t -> HJScript ()Source

(.+.) :: PlusOpType a => HJSJBinOperator a aSource

(.-.) :: Num a => HJSJBinOperator a aSource

(.*.) :: Num a => HJSJBinOperator a aSource

(./.) :: Num a => HJSJBinOperator a aSource

(.&&.) :: HJSJBinOperator Bool BoolSource

(.||.) :: HJSJBinOperator Bool BoolSource

(.==.) :: HJSJBinOperator a BoolSource

(.!=.) :: HJSJBinOperator a BoolSource

(.>.) :: Num a => HJSJBinOperator a BoolSource

(.<.) :: Num a => HJSJBinOperator a BoolSource

(.>=.) :: Num a => HJSJBinOperator a BoolSource

(.<=.) :: Num a => HJSJBinOperator a BoolSource

(.=.) :: Var t -> Exp t -> HJScript ()Source

Assignment

(.+=.) :: Num t => Var t -> Exp t -> HJScript ()Source

Plus with

(?) :: JBool -> (HJScript t1, HJScript t2) -> HJScript ()Source

Alternative if-else syntax: isTrue ? (doA,doB)

(<|>) :: a -> a -> (a, a)Source

Providing a way of writing if-else expression as in: isTrue ? doA | doB

callMethod :: (IsDeref d, Args e t1) => String -> e -> d -> Exp t2Source

callVoidMethod :: (Args e t1, IsDeref a) => String -> e -> a -> HJScript ()Source

callProc :: Args e t => Exp (t -> t1) -> e -> HJScript ()Source

function :: (FormalParams a t, VarsToExps a e) => (e -> HJScript (Exp r)) -> HJScript (Exp (t -> r))Source

Anonymous function, returning an expression

procedure :: (FormalParams a t, VarsToExps a e) => (e -> HJScript ()) -> HJScript (Exp (t -> ()))Source

Anonymous void function.

functionDecl :: (FormalParams a t, VarsToExps a e) => String -> (e -> HJScript (Exp r)) -> HJScript ()Source

Function declaration

procedureDecl :: (FormalParams a t, VarsToExps a e) => String -> (e -> HJScript ()) -> HJScript ()Source

Procedure declaration.

for :: JInt -> JInt -> (JInt -> HJScript t) -> HJScript ()Source

for

forIn :: IsDeref d => d -> (JString -> HJScript ()) -> HJScript ()Source

for (var in object) { .. }

forInVar :: IsDeref d => d -> (Var a -> HJScript ()) -> HJScript ()Source

for (var in object) { .. }

while :: JBool -> HJScript t -> HJScript ()Source

while

doWhile :: HJScript t -> JBool -> HJScript ()Source

doWhile

doIf :: JBool -> HJScript t -> HJScript (Elses ()) -> HJScript ()Source

doIf

doElse :: HJScript () -> HJScript (Elses ())Source

doElse

doIfElse :: JBool -> (HJScript t1, HJScript t2) -> HJScript ()Source

doIfElse

doIfNoElse :: Exp Bool -> HJScript () -> HJScript ()Source

Only an if branch

noElse :: HJScript (Elses ())Source

No else branch.

new :: (HasConstructor o e t, Args e t) => o -> e -> HJScript (Exp o)Source

delete :: Var a -> Exp BoolSource

delete a property

Can only delete properties/variables that are created implicitly, not those declared with the var statement.

returns true if property was deleted. false if operation was not possible.

(#) :: a -> (a -> b) -> bSource

Dereferencing operator, similar to the dot operator in JavaScript. E.g. document.forms => document # forms, same as forms document

(#.) :: (a -> b) -> (b -> c) -> a -> cSource

rec :: Exp a -> Exp b -> Exp (Rec a b)Source

first :: Exp (Rec a b) -> Exp aSource

second :: Exp (Rec a b) -> Exp bSource

x :: Exp (Rec a b) -> Exp aSource

y :: Exp (Rec a b) -> Exp bSource

(#!) :: JArray t -> JInt -> Var tSource

Accessing arrays.

jnull :: IsNullable t => Exp tSource

Null value

jShow :: JShow t => Exp t -> JStringSource

Converts to JString expression.

castObject :: (IsClass c1, IsClass c2) => JObject c1 -> JObject c2Source

Casting an JObject

hasFeature :: (IsFeature f, IsClass c) => JObject c -> f -> JBoolSource

Checks if an object is supported by browser

ifOp :: JBool -> Exp t -> Exp t -> Exp tSource

class IsHJScript a whereSource

IsHJscript class with function toHJScript for converting instances to HJScript ()

Methods

toHJScript :: a -> HJScript ()Source

outputBlock :: Block () -> HJScript ()Source

Adds a block

outputStmt :: Stmt () -> HJScript ()Source

Adds a statement

evalHJScript :: HJScript t -> (t, Block ())Source

Evaluate a script returning a tuple of the produced value and a block of code.