packages feed

jmacro 0.6.5 → 0.6.6

raw patch · 3 files changed

+23/−9 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Language.Javascript.JMacro: JDouble :: Double -> JVal
+ Language.Javascript.JMacro: JDouble :: SaneDouble -> JVal

Files

Language/Javascript/JMacro/Base.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE FlexibleInstances, UndecidableInstances, OverlappingInstances, OverloadedStrings, TypeFamilies, RankNTypes, DeriveDataTypeable, StandaloneDeriving, FlexibleContexts, TypeSynonymInstances, ScopedTypeVariables, GADTs #-}+{-# LANGUAGE FlexibleInstances, UndecidableInstances, OverlappingInstances, OverloadedStrings, TypeFamilies, RankNTypes, DeriveDataTypeable, StandaloneDeriving, FlexibleContexts, TypeSynonymInstances, ScopedTypeVariables, GADTs, GeneralizedNewtypeDeriving #-}  ----------------------------------------------------------------------------- {- |@@ -160,7 +160,7 @@ -- | Values data JVal = JVar     Ident           | JList    [JExpr]-          | JDouble  Double+          | JDouble  SaneDouble           | JInt     Integer           | JStr     String           | JRegEx   String@@ -169,6 +169,19 @@           | UnsatVal (IdentSupply JVal)             deriving (Eq, Ord, Show, Data, Typeable) +newtype SaneDouble = SaneDouble Double deriving (Data, Typeable, Fractional, Num)++instance Eq SaneDouble where+    (SaneDouble x) == (SaneDouble y) = x == y || (isNaN x && isNaN y)++instance Ord SaneDouble where+    compare (SaneDouble x) (SaneDouble y) = compare (fromNaN x) (fromNaN y)+        where fromNaN z | isNaN z = Nothing+                        | otherwise = Just z++instance Show SaneDouble where+    show (SaneDouble x) = show x+ -- | Identifiers newtype Ident = StrI String deriving (Eq, Ord, Show, Data, Typeable) @@ -522,7 +535,7 @@ instance JsToDoc JVal where     jsToDoc (JVar i) = jsToDoc i     jsToDoc (JList xs) = brackets . fillSep . punctuate comma $ map jsToDoc xs-    jsToDoc (JDouble d) = double d+    jsToDoc (JDouble (SaneDouble d)) = double d     jsToDoc (JInt i) = integer i     jsToDoc (JStr s) = text . T.pack $ "\""++encodeJson s++"\""     jsToDoc (JRegEx s) = text . T.pack $ "/"++s++"/"@@ -615,7 +628,7 @@     toJExpr = ValExpr . JHash . M.map toJExpr  instance ToJExpr Double where-    toJExpr = ValExpr . JDouble+    toJExpr = ValExpr . JDouble . SaneDouble  instance ToJExpr Int where     toJExpr = ValExpr . JInt . fromIntegral
Language/Javascript/JMacro/QQ.hs view
@@ -437,7 +437,7 @@           return [ForeignStat i t]        returnStat =-        reserved "return" >> (:[]) . ReturnStat <$> option (ValExpr $ JVar $ StrI "null") expr+        reserved "return" >> (:[]) . ReturnStat <$> option (ValExpr $ JVar $ StrI "undefined") expr        ifStat = do         reserved "if"@@ -519,6 +519,7 @@           (e1,op) <- try $ liftM2 (,) dotExpr (fmap (take 1) $                                                    rop "="                                                <|> rop "+="+                                               <|> rop "-="                                                <|> rop "*="                                                <|> rop "/="                                                <|> rop "%="@@ -529,10 +530,10 @@                                                <|> rop "^="                                                <|> rop "|="                                               )-          let gofail = fail ("Invalid assignment.")+          let gofail  = fail ("Invalid assignment.")+              badList = ["this","true","false","undefined","null"]           case e1 of-            ValExpr (JVar (StrI "this")) -> gofail-            ValExpr (JVar _) -> return ()+            ValExpr (JVar (StrI s)) -> if s `elem` badList then gofail else return ()             ApplExpr _ _ -> gofail             ValExpr _ -> gofail             _ -> return ()
jmacro.cabal view
@@ -1,5 +1,5 @@ name:                jmacro-version:             0.6.5+version:             0.6.6 synopsis:            QuasiQuotation library for programmatic generation of Javascript code. description:         Javascript syntax, functional syntax, hygienic names, compile-time guarantees of syntactic correctness, limited typechecking. Additional documentation available at <http://www.haskell.org/haskellwiki/Jmacro> category:            Language