packages feed

fay 0.19.1.2 → 0.19.2

raw patch · 5 files changed

+35/−8 lines, 5 files

Files

CHANGELOG.md view
@@ -2,6 +2,10 @@  See full history at: <https://github.com/faylang/fay/commits> +### 0.19.2 (2014-04-10)++* Fixes a bug where arrays types with an empty data decls would be deserialized into a Fay list.+ #### 0.19.1.2 (2014-04-07)  * Fix optimizations that were not applied and add codegen test cases.
fay.cabal view
@@ -1,5 +1,5 @@ name:                fay-version:             0.19.1.2+version:             0.19.2 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,
js/runtime.js view
@@ -394,17 +394,17 @@       type.push(["automatic"]);     return Fay$$jsToFay(["function", type], jsObj);   }+  else if(base == "automatic" && jsObj instanceof Array) {+    var list = null;+    for (var i = jsObj.length - 1; i >= 0; i--) {+      list = new Fay$$Cons(Fay$$jsToFay([base], jsObj[i]), list);+    }+    return list;+  }   else if(base == "automatic" || base == "user") {     if (jsObj && jsObj['instance']) {       var jsToFayFun = Fay$$jsToFayHash[jsObj["instance"]];       return jsToFayFun ? jsToFayFun(type,type[2],jsObj) : jsObj;-    }-    else if (jsObj instanceof Array) {-      var list = null;-      for (var i = jsObj.length - 1; i >= 0; i--) {-        list = new Fay$$Cons(Fay$$jsToFay([base], jsObj[i]), list);-      }-      return list;     }     else       return jsObj;
+ tests/EmptyDataDeclArray.hs view
@@ -0,0 +1,20 @@+import FFI++data Array a++empty :: Fay (Array a)+empty = ffi "[]"++push:: a -> Array a -> Fay ()+push = ffi "%2.push(%1)"++len :: Array a -> Fay Int+len = ffi "%1['length']"++main :: Fay ()+main = do+  arr <- empty+  print arr+  push (5::Int) arr+  print =<< len arr+  print arr
+ tests/EmptyDataDeclArray.res view
@@ -0,0 +1,3 @@+[]+1+[ 5 ]