jmacro 0.6.4 → 0.6.5
raw patch · 4 files changed
+31/−16 lines, 4 filesdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base
API changes (from Hackage documentation)
- Language.Javascript.JMacro.TypeCheck: isLeft :: Either a b -> Bool
+ Language.Javascript.JMacro: type JsLabel = String
+ Language.Javascript.JMacro.TypeCheck: eitherIsLeft :: Either a b -> Bool
Files
- Language/Javascript/JMacro/Base.hs +7/−7
- Language/Javascript/JMacro/QQ.hs +16/−1
- Language/Javascript/JMacro/TypeCheck.hs +6/−6
- jmacro.cabal +2/−2
Language/Javascript/JMacro/Base.hs view
@@ -14,7 +14,7 @@ module Language.Javascript.JMacro.Base ( -- * ADT- JStat(..), JExpr(..), JVal(..), Ident(..), IdentSupply(..),+ JStat(..), JExpr(..), JVal(..), Ident(..), IdentSupply(..), JsLabel, -- * Generic traversal (via compos) JMacro(..), JMGadt(..), Compos(..), composOp, composOpM, composOpM_, composOpFold,@@ -208,14 +208,14 @@ jtoGADT = JMGStat jfromGADT (JMGStat x) = x jfromGADT _ = error "impossible"- + instance JMacro JExpr where jtoGADT = JMGExpr jfromGADT (JMGExpr x) = x jfromGADT _ = error "impossible" instance JMacro JVal where- jtoGADT = JMGVal + jtoGADT = JMGVal jfromGADT (JMGVal x) = x jfromGADT _ = error "impossible" @@ -245,7 +245,7 @@ compos = jmcompos jmcompos :: forall m c. (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)-jmcompos ret app f' v = +jmcompos ret app f' v = case v of JMGId _ -> ret v JMGStat v' -> ret JMGStat `app` case v' of@@ -340,7 +340,7 @@ jsSaturate_ :: (JMacro a) => a -> IdentSupply a jsSaturate_ e = IS $ jfromGADT <$> go (jtoGADT e)- where + where go :: forall a. JMGadt a -> State [Ident] (JMGadt a) go v = case v of JMGStat (UnsatBlock us) -> go =<< (JMGStat <$> runIdentSupply us)@@ -355,8 +355,8 @@ --doesn't apply to unsaturated bits jsReplace_ :: JMacro a => [(Ident, Ident)] -> a -> a jsReplace_ xs e = jfromGADT $ go (jtoGADT e)- where - go :: forall a. JMGadt a -> JMGadt a + where+ go :: forall a. JMGadt a -> JMGadt a go v = case v of JMGId i -> maybe v JMGId (M.lookup i mp) _ -> composOp go v
Language/Javascript/JMacro/QQ.hs view
@@ -235,6 +235,8 @@ P.reservedOpNames = ["|>","<|","+=","-=","*=","/=","%=","<<=", ">>=", ">>>=", "&=", "^=", "|=", "--","*","/","+","-",".","%","?","=","==","!=","<",">","&&","||","&", "^", "|", "++","===","!==", ">=","<=","!", "~", "<<", ">>", ">>>", "->","::","::!",":|","@"], P.identLetter = alphaNum <|> oneOf "_$", P.identStart = letter <|> oneOf "_$",+ P.opStart = oneOf "|+-/*%<>&^.?=!~:@",+ P.opLetter = oneOf "|+-/*%<>&^.?=!~:@", P.commentLine = "//", P.commentStart = "/*", P.commentEnd = "*/"}@@ -398,6 +400,7 @@ <|> breakStat <|> continueStat <|> antiStat+ <|> antiStatSimple <?> "statement" where declStat = do@@ -576,6 +579,12 @@ (const (return x)) (parseHSExp x) + antiStatSimple = return . AntiStat <$> do+ x <- (symbol "`" >> anyChar `manyTill` symbol "`")+ either (fail . ("Bad AntiQuotation: \n" ++))+ (const (return x))+ (parseHSExp x)+ --args :: JMParser [JExpr] --args = parens $ commaSep expr @@ -642,7 +651,7 @@ _ -> error "exprApp" dotExprOne :: JMParser JExpr-dotExprOne = addNxt =<< valExpr <|> antiExpr <|> parens' expr <|> notExpr <|> newExpr+dotExprOne = addNxt =<< valExpr <|> antiExpr <|> antiExprSimple <|> parens' expr <|> notExpr <|> newExpr where addNxt e = do nxt <- (Just <$> lookAhead anyChar <|> return Nothing)@@ -663,6 +672,12 @@ antiExpr = AntiExpr <$> do x <- (try (symbol "`(") >> anyChar `manyTill` try (string ")`"))+ either (fail . ("Bad AntiQuotation: \n" ++))+ (const (return x))+ (parseHSExp x)++ antiExprSimple = AntiExpr <$> do+ x <- (symbol "`" >> anyChar `manyTill` string "`") either (fail . ("Bad AntiQuotation: \n" ++)) (const (return x)) (parseHSExp x)
Language/Javascript/JMacro/TypeCheck.hs view
@@ -28,9 +28,9 @@ -- Utility -isLeft :: Either a b -> Bool-isLeft (Left _) = True-isLeft _ = False+eitherIsLeft :: Either a b -> Bool+eitherIsLeft (Left _) = True+eitherIsLeft _ = False partitionOut :: (a -> Maybe b) -> [a] -> ([b],[a]) partitionOut f xs' = foldr go ([],[]) xs'@@ -581,13 +581,13 @@ findLoop i cs@(c:_) = go [] cs where- cTyp = isLeft c+ cTyp = eitherIsLeft c go accum (r:rs)- | either id id r == i && isLeft r == cTyp = Just $ Just (either id id r : accum)+ | either id id r == i && eitherIsLeft r == cTyp = Just $ Just (either id id r : accum) -- i.e. there's a cycle to close | either id id r == i = Just Nothing -- i.e. there's a "dull" cycle- | isLeft r /= cTyp = Nothing -- we stop looking for a cycle because the chain is broken+ | eitherIsLeft r /= cTyp = Nothing -- we stop looking for a cycle because the chain is broken | otherwise = go (either id id r : accum) rs go _ [] = Nothing
jmacro.cabal view
@@ -1,5 +1,5 @@ name: jmacro-version: 0.6.4+version: 0.6.5 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@@ -7,7 +7,7 @@ license-file: LICENSE author: Gershom Bazerman maintainer: gershomb@gmail.com-Tested-With: GHC == 7.0.2+Tested-With: GHC == 7.6.2 Build-Type: Simple Cabal-Version: >= 1.6