HJavaScript 0.4.5 → 0.4.6
raw patch · 2 files changed
+15/−2 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Language.HJavaScript.Syntax: ForIn :: Var String -> d -> Block () -> Stmt ()
+ Language.HJavaScript.Syntax: JDelete :: Var a -> Exp Bool
+ Language.HJavaScript.Syntax: JPropertyVar :: d -> Exp p -> Var a
+ Language.HJavaScript.Syntax: propertyVar :: (IsDeref d, JShow p) => Exp p -> d -> Var a
Files
- HJavaScript.cabal +1/−1
- src/Language/HJavaScript/Syntax.hs +14/−1
HJavaScript.cabal view
@@ -1,5 +1,5 @@ Name: HJavaScript-Version: 0.4.5+Version: 0.4.6 License: BSD3 Author: Joel Bjornson, Niklas Broberg Maintainer: joel.bjornson@gmail.com, nibro@cs.chalmers.se
src/Language/HJavaScript/Syntax.hs view
@@ -59,7 +59,7 @@ IsJFloat(..), -- * Helper functions- val, toBlock, deref, derefVar, + val, toBlock, deref, derefVar, propertyVar, call, methodCall, voidMethodCall, methodCallNoArgs, voidMethodCallNoArgs, @@ -93,6 +93,7 @@ JMember :: String -> Var a JDerefVar :: IsDeref d => d -> String -> Var a JArrayIndex :: Exp (Array t) -> Exp Int -> Var t+ JPropertyVar :: (IsDeref d, JShow p) => d -> Exp p -> Var a instance Show (Var t) where showsPrec p var = case var of@@ -102,6 +103,7 @@ JDerefVar o v -> shows o . sDot . showString v JArrayIndex a ix -> shows a . showString "[" . shows ix . showString "]"+ JPropertyVar c p -> shows c . showString "[" . shows p . showString "]" -- We model records simply as tuples, for lack of a better record mechanism@@ -127,6 +129,7 @@ JIfOp :: Exp Bool -> Exp t -> Exp t -> Exp t JCall :: (Args e t) => Exp (t -> r) -> e -> Exp r JNew :: (Args e t, HasConstructor c e t) => c -> e -> Exp c+ JDelete :: Var a -> Exp Bool JDeref :: IsDeref d => d -> String -> Exp t JFunction :: FormalParams a t => Maybe String -> a -> Block r -> Exp (t -> r) JThis :: IsClass c => Exp c@@ -172,6 +175,7 @@ showString ":" . shows e3 JCall x a2 -> shows x . showsArgs a2 JNew c a -> showString "new" . sSpace . shows c . showsArgs a+ JDelete v -> showString "delete" . sSpace . shows v JDeref o e -> shows o . sDot . showString e JFunction n fp b -> showString "function" . sSpace .@@ -324,6 +328,7 @@ While :: Exp Bool -> Block () -> Stmt () DoWhile :: Block () -> Exp Bool -> Stmt () For :: Stmt t1 -> Exp Bool -> Exp t2 -> Block () -> Stmt () + ForIn :: IsDeref d => Var String -> d -> Block () -> Stmt () Break :: Stmt () Continue :: Stmt () Return :: Exp t -> Stmt t@@ -348,6 +353,9 @@ For e1 e2 e3 b -> showString "for" . showParen True (shows e1 . sc . shows e2 . sc . shows e3) . sBrack b+ ForIn v o b -> showString "for" . + showParen True (shows v . showString " in " . shows o) .+ sBrack b Break -> showString "break" Continue -> showString "continue" Return e -> showString "return" . showString " " . shows e@@ -565,9 +573,14 @@ ------------------------------------------------------------------- -- Dereferencing+deref :: (IsDeref d) => String -> d -> Exp t deref str obj = JDeref obj str +derefVar :: (IsDeref d) => String -> d -> Var a derefVar str obj = JDerefVar obj str++propertyVar :: (IsDeref d, JShow p) => Exp p -> d -> Var a+propertyVar str obj = JPropertyVar obj str -- Calling a function call :: (Args e t) => Exp (t -> r) -> e -> Exp r