packages feed

fay 0.23.1.6 → 0.23.1.7

raw patch · 7 files changed

+43/−7 lines, 7 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -2,6 +2,10 @@  See full history at: <https://github.com/faylang/fay/commits> +#### 0.23.1.7++* Fix panic when compiling irrefutable pattern matches on lists (thanks Christopher Parks)+ #### 0.23.1.6  * Allow `syb 0.5.*`
fay.cabal view
@@ -1,5 +1,5 @@ name:                fay-version:             0.23.1.6+version:             0.23.1.7 synopsis:            A compiler for Fay, a Haskell subset that compiles to JavaScript. description:         Fay is a proper subset of Haskell which is type-checked                      with GHC, and compiled to JavaScript. It is lazy, pure, has a Fay monad,
src/Fay/Compiler/Decl.hs view
@@ -99,12 +99,20 @@       exp <- compileExp rhs       name <- withScopedTmpJsName return       m <- compilePat (JsName name) pat []-      case m of-        [JsIf t b1 []] -> do-          let err = [throw ("Irrefutable pattern failed for pattern: " ++ prettyPrint pat) (JsList [])]-          return [JsVar name exp, JsIf t b1 err]-        [JsVar n _] -> return [JsVar n exp]-        x -> error $ "Fay bug! Can't compile pat bind for: " ++ show x+      m2 <- interleavePatternMatchFailures m pat m+      return (JsVar name exp : m2)++    interleavePatternMatchFailures :: [JsStmt] -> S.Pat -> [JsStmt] -> Compile [JsStmt]+    interleavePatternMatchFailures original pat = walk+      where+        walk m = case m of+          [JsIf t b1 []] -> do+            b2 <- walk b1+            return [JsIf t b2 err]+          [JsVar n exp2] -> return [JsVar n exp2]+          stmt:stmts -> (stmt:) <$> walk stmts+          [] -> error $ "Fay bug! Can't compile pat bind for pattern: " ++ show original+        err = [throw ("Irrefutable pattern failed for pattern: " ++ prettyPrint pat) (JsList [])]  -- | Compile a normal simple pattern binding. compileUnguardedRhs :: Bool -> S.X -> S.Name -> S.Exp -> Compile [JsStmt]
+ tests/VarPtr.hs view
@@ -0,0 +1,11 @@+module VarPtr where++import Data.Var++data Record = Record Int++main = do +  v <- newVar $ Record 5+  subscribeAndRead v $ \y -> case y of+    Record a -> putStrLn . show $ a+  set v $ Record 10
+ tests/VarPtr.res view
@@ -0,0 +1,2 @@+5+10
+ tests/patternMatchLet.hs view
@@ -0,0 +1,10 @@+module PatternMatchLet where++first3 :: String -> Fay ()+first3 cs = do+  let (a:b:c:_) = cs+  putStrLn [a, b, c]++main :: Fay ()+main = first3 "abcd"+
+ tests/patternMatchLet.res view
@@ -0,0 +1,1 @@+abc