-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | HJavaScript is an abstract syntax for a typed subset of JavaScript. -- -- HJavaScript defines an abstract syntax and pretty printer for a subset -- of JavaScript. as Language.HJavaScript. However, a significant -- difference from JavaScript is that HJavaScript is typed, even on the -- abstract syntax level using GADTs. The subset of JavaScript that is -- supported is those parts that lend themself to typing (i.e. no -- prototyping of classes). @package HJavaScript @version 0.4.5 module Language.HJavaScript.Syntax -- | JavaScript types class JType t data Exp t JInt :: Int -> Exp Int JFloat :: Float -> Exp Float JBool :: Bool -> Exp Bool JString :: String -> Exp String JRec :: Exp a -> Exp b -> Exp (Rec a b) JFst :: Exp (Rec a b) -> Exp a JSnd :: Exp (Rec a b) -> Exp b JConst :: String -> Exp t JAssign :: Var t -> Exp t -> Exp t JAssignWith :: Var t -> AssignOp t -> Exp t -> Exp t JNeg :: Exp t -> Exp t JNot :: Exp Bool -> Exp Bool JBinOp :: Exp t -> BinOp t r -> Exp t -> Exp r JIncrement :: PostPre -> Var t -> Exp t JDecrement :: PostPre -> Var t -> Exp t JIfOp :: Exp Bool -> Exp t -> Exp t -> Exp t JCall :: Exp (t -> r) -> e -> Exp r JNew :: c -> e -> Exp c JDeref :: d -> String -> Exp t JFunction :: Maybe String -> a -> Block r -> Exp (t -> r) JThis :: Exp c JBlock :: Block () -> Exp () JNull :: Exp t JCastObject :: Exp c1 -> Exp c2 JValueOf :: Var t -> Exp t JIsImpl :: Exp c -> f -> Exp Bool JShow :: Exp t -> Exp String data Rec a b data Var t JVar :: String -> Var a JParam :: String -> Var a JMember :: String -> Var a JDerefVar :: d -> String -> Var a JArrayIndex :: Exp (Array t) -> Exp Int -> Var t data Stmt t VarDecl :: String -> Stmt () VarDeclAssign :: String -> Exp t -> Stmt () VarAssign :: String -> Exp t -> Stmt () ExpStmt :: Exp t -> Stmt () While :: Exp Bool -> Block () -> Stmt () DoWhile :: Block () -> Exp Bool -> Stmt () For :: Stmt t1 -> Exp Bool -> Exp t2 -> Block () -> Stmt () Break :: Stmt () Continue :: Stmt () Return :: Exp t -> Stmt t If :: Exp Bool -> Block t -> Elses t -> Stmt () data Block t EmptyBlock :: Block () Sequence :: Block () -> Stmt t -> Block t class (Show c) => IsClass c -- | Class for binding objects with constructors. E.g. o = new Date(); class (IsClass c, Args e t) => HasConstructor c e t -- | Class for derefable data types, used to allow the creation of -- dereferencing objects. Examples: Math.random() or document.write() class (Show r) => IsDeref r -- | Assign Operator data AssignOp t PlusAssign :: AssignOp t MinusAssign :: AssignOp t TimesAssign :: AssignOp t DivAssign :: AssignOp Float ModAssign :: AssignOp Int AndAssign :: AssignOp Bool OrAssign :: AssignOp Bool -- | Binary Operator data BinOp t r Plus :: BinOp t t Minus :: BinOp t t Times :: BinOp t t Div :: BinOp t t Mod :: BinOp Int Int And :: BinOp Bool Bool Or :: BinOp Bool Bool Equals :: BinOp t Bool NotEquals :: BinOp t Bool GThan :: BinOp t Bool LThan :: BinOp t Bool GEThan :: BinOp t Bool LEThan :: BinOp t Bool -- | Class for expression that may be plussed. Examples: 1 + 2, -- ha + skell. class PlusOpType a -- | Post or Pre prefix , i.e. --x or x++ data PostPre Pst :: PostPre Pre :: PostPre data Elses t Elseif :: Exp Bool -> Block t -> Elses t -> Elses t Else :: Block t -> Elses t NoElse :: Elses () -- | Allows values to be compared to JNull. E.g. for checking that an -- object is instantiated or is accessible. class IsNullable a -- | Class for representing JavaScript features, e.g. names of -- objects or functions. Example: window hasFeature alert class (Show a) => IsFeature a -- | Class that represents showable types class JShow a jshow :: (JShow a) => a -> JString -- | Args represents types that can be passed as arguments to JavaScript -- functions. class (Show e) => Args e t | e -> t -- | Class for parameter types to JavaScript functions class ParamType t -- | JFormal params represents parameters passed to a function along with -- their corresponding types. class (Show a, ParamType t) => FormalParams a t | a -> t mkFParams :: (FormalParams a t) => (a -> b) -> Int -> a showsFParams :: (FormalParams a t) => a -> ShowS class VarsToExps v e | v -> e, e -> v v2e :: (VarsToExps v e) => v -> e -- | Array representation data Array t Array :: Array t type JInt = Exp Int type JString = Exp String type JBool = Exp Bool type JFloat = Exp Float type JVoid = Exp () type JObject c = Exp c type JArray t = Exp (Array t) -- | Class for representing expressions. First parameter is the expression, -- second a TBool for variable or constant. Third parameter represents -- the type. class IsExp e t | e -> t toExp :: (IsExp e t) => e -> Exp t -- | Class for JString expressions class (IsExp e String) => IsJString e toJString :: (IsJString e) => e -> Exp String -- | Class for JBool expressions class (IsExp e Bool) => IsJBool e toJBool :: (IsJBool e) => e -> Exp Bool -- | Class for JInt expressions class (IsExp e Int) => IsJInt e toJInt :: (IsJInt e) => e -> Exp Int -- | Class for JFloat expressions class (IsExp e Float) => IsJFloat e toJFloat :: (IsJFloat e) => e -> Exp Float -- | Get the value of a variable. val :: Var t -> Exp t -- | Generates a Block from a Stmt. toBlock :: Stmt t -> Block t deref :: (IsDeref d) => String -> d -> Exp t derefVar :: (IsDeref d) => String -> d -> Var a call :: (Args e t) => Exp (t -> r) -> e -> Exp r methodCall :: (Args e t1, IsDeref d) => String -> e -> d -> Exp t2 voidMethodCall :: (Args e t1, IsDeref a) => String -> e -> a -> Stmt () methodCallNoArgs :: (IsDeref d) => String -> d -> Exp t voidMethodCallNoArgs :: (IsDeref d) => String -> d -> Stmt () renderBlock :: Block r -> String instance [overlap ok] Show (Array t) instance [overlap ok] Eq PostPre instance [overlap ok] IsClass (Array t) instance [overlap ok] (IsExp e Bool) => IsJBool e instance [overlap ok] (IsExp e Float) => IsJFloat e instance [overlap ok] (IsExp e Int) => IsJInt e instance [overlap ok] (IsExp e String) => IsJString e instance [overlap ok] IsExp Bool Bool instance [overlap ok] IsExp Float Float instance [overlap ok] IsExp Int Int instance [overlap ok] IsExp String String instance [overlap ok] IsExp (Exp t) t instance [overlap ok] (IsClass c) => IsDeref (Exp c) instance [overlap ok] (IsClass c) => IsDeref c instance [overlap ok] VarsToExps (Var t1, Var t2, Var t3, Var t4, Var t5) (Exp t1, Exp t2, Exp t3, Exp t4, Exp t5) instance [overlap ok] VarsToExps (Var t1, Var t2, Var t3, Var t4) (Exp t1, Exp t2, Exp t3, Exp t4) instance [overlap ok] VarsToExps (Var t1, Var t2, Var t3) (Exp t1, Exp t2, Exp t3) instance [overlap ok] VarsToExps (Var t1, Var t2) (Exp t1, Exp t2) instance [overlap ok] VarsToExps (Var t) (Exp t) instance [overlap ok] VarsToExps () () instance [overlap ok] Args (Exp t1, Exp t2, Exp t3, Exp t4, Exp t5) (t1, t2, t3, t4, t5) instance [overlap ok] Args (Exp t1, Exp t2, Exp t3, Exp t4) (t1, t2, t3, t4) instance [overlap ok] Args (Exp t1, Exp t2, Exp t3) (t1, t2, t3) instance [overlap ok] Args (Exp t1, Exp t2) (t1, t2) instance [overlap ok] Args (Exp t) t instance [overlap ok] Args () () instance [overlap ok] (ParamType (t1, t2, t3, t4, t5)) => FormalParams (Var t1, Var t2, Var t3, Var t4, Var t5) (t1, t2, t3, t4, t5) instance [overlap ok] (ParamType (t1, t2, t3, t4)) => FormalParams (Var t1, Var t2, Var t3, Var t4) (t1, t2, t3, t4) instance [overlap ok] (ParamType (t1, t2, t3)) => FormalParams (Var t1, Var t2, Var t3) (t1, t2, t3) instance [overlap ok] (ParamType (t1, t2)) => FormalParams (Var t1, Var t2) (t1, t2) instance [overlap ok] (ParamType t) => FormalParams (Var t) t instance [overlap ok] FormalParams () () instance [overlap ok] (JType t1, JType t2, JType t3, JType t4, JType t5) => ParamType (t1, t2, t3, t4, t5) instance [overlap ok] (JType t1, JType t2, JType t3, JType t4) => ParamType (t1, t2, t3, t4) instance [overlap ok] (JType t1, JType t2, JType t3) => ParamType (t1, t2, t3) instance [overlap ok] (JType t1, JType t2) => ParamType (t1, t2) instance [overlap ok] (JType t) => ParamType t instance [overlap ok] ParamType () instance [overlap ok] Show (Block t) instance [overlap ok] Show (Elses t) instance [overlap ok] Show (Stmt t) instance [overlap ok] Show (BinOp t r) instance [overlap ok] PlusOpType Float instance [overlap ok] PlusOpType Int instance [overlap ok] PlusOpType String instance [overlap ok] Show (AssignOp t) instance [overlap ok] IsNullable (t -> r) instance [overlap ok] (IsClass c) => IsNullable c instance [overlap ok] IsNullable String instance [overlap ok] (JShow a) => JShow (Exp a) instance [overlap ok] JShow String instance [overlap ok] JShow Bool instance [overlap ok] JShow Float instance [overlap ok] JShow Int instance [overlap ok] IsFeature String instance [overlap ok] (IsClass c) => IsFeature c instance [overlap ok] Show (Exp t) instance [overlap ok] Show (Var t) instance [overlap ok] (Show t1, JType t1, Show t2, JType t2) => JType (t1 -> t2) instance [overlap ok] (IsClass c) => JType c instance [overlap ok] JType Float instance [overlap ok] JType () instance [overlap ok] JType Bool instance [overlap ok] JType Int instance [overlap ok] JType String