haste-compiler 0.4.1 → 0.4.2
raw patch · 4 files changed
+50/−36 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- haste-compiler.cabal +7/−16
- libraries/haste-lib/src/Haste/Foreign.hs +33/−14
- src/Haste/Version.hs +1/−1
- src/haste-pkg.hs +9/−5
haste-compiler.cabal view
@@ -1,5 +1,5 @@ Name: haste-compiler-Version: 0.4.1+Version: 0.4.2 License: BSD3 License-File: LICENSE Synopsis: Haskell To ECMAScript compiler@@ -54,10 +54,6 @@ Hs-Source-Dirs: src if flag(portable) CPP-Options: -DPORTABLE- if os(windows)- GHC-Options: -static -optl-static- else- GHC-Options: -static -optl-static -optl-pthread Build-Depends: ghc, base < 5,@@ -81,7 +77,8 @@ if os(windows) GHC-Options: -static -optl-static else- GHC-Options: -static -optl-static -optl-pthread+ if os(linux)+ GHC-Options: -static -optl-static -optl-pthread Build-Depends: base < 5, ghc-prim,@@ -135,7 +132,8 @@ if os(windows) GHC-Options: -static -optl-static else- GHC-Options: -static -optl-static -optl-pthread+ if os(linux)+ GHC-Options: -static -optl-static -optl-pthread Build-Depends: base < 5, shellmate,@@ -152,7 +150,8 @@ if os(windows) GHC-Options: -static -optl-static else- GHC-Options: -static -optl-static -optl-pthread+ if os(linux)+ GHC-Options: -static -optl-static -optl-pthread Build-Depends: base < 5, shellmate,@@ -167,10 +166,6 @@ Hs-Source-Dirs: src if flag(portable) CPP-Options: -DPORTABLE- if os(windows)- GHC-Options: -static -optl-static- else- GHC-Options: -static -optl-static -optl-pthread Build-Depends: base < 5, shellmate,@@ -186,10 +181,6 @@ Hs-Source-Dirs: src if flag(portable) CPP-Options: -DPORTABLE- if os(windows)- GHC-Options: -static -optl-static- else- GHC-Options: -static -optl-static -optl-pthread Build-Depends: base < 5, shellmate >= 0.1.5,
libraries/haste-lib/src/Haste/Foreign.hs view
@@ -15,6 +15,8 @@ import System.IO.Unsafe import Unsafe.Coerce +import Debug.Trace+ #ifdef __HASTE__ foreign import ccall eval :: JSString -> IO (Ptr a) foreign import ccall "String" jsString :: Double -> JSString@@ -262,28 +264,45 @@ instance Unpack a => IOFun (IO a) where type X (IO a) = Unpacked- packify = unsafePerformIO . unpack' . toOpaque . fmap unpack- where- {-# NOINLINE unpack' #-}- unpack' :: Opaque (IO a) -> IO Unpacked- unpack' =- ffi (toJSStr $ "(function(f) {" ++- " return (function() {" ++- " var args=Array.prototype.slice.call(arguments,0);"++- " args.push(0);" ++- " return E(B(A(f, args)));" ++- " });" ++- "})")+ packify m = unsafePerformIO $ do+ x <- m+ return $! unpack x instance (Pack a, IOFun b) => IOFun (a -> b) where type X (a -> b) = Unpacked -> X b packify f = \x -> packify (f $! pack x) instance Unpack a => Unpack (IO a) where- unpack = packify+ unpack = unsafePerformIO . unpackAct . toOpaque . fmap unpack+ where+ {-# NOINLINE unpackAct #-}+ unpackAct :: Opaque (IO Unpacked) -> IO Unpacked+ unpackAct =+ ffi (toJSStr $ "(function(m){" +++ " return (function() {" +++ " return (function(){return E(B(A(m,[0])));});" +++ " });" +++ "})") instance (IOFun (a -> b)) => Unpack (a -> b) where- unpack = unsafeCoerce . packify+ unpack = unpackFun++unpackFun :: IOFun a => a -> Unpacked+unpackFun =+ unsafePerformIO . go . toOpaque . packify+ where+ {-# NOINLINE go #-}+ go :: Opaque a -> IO Unpacked+ go = ffi (toJSStr $ "(function(f) {" +++ " return (function() {" +++ " return (function(){" +++ " var args=Array.prototype.slice.call(arguments,0);"+++ " args.push(0);" +++ " return E(B(A(f, args)));" +++ " });" +++ " });" +++ "})")+ -- | Creates a function based on the given string of Javascript code. If this -- code is not well typed or is otherwise incorrect, your program may crash
src/Haste/Version.hs view
@@ -9,7 +9,7 @@ import Haste.Environment (hasteSysDir, ghcBinary) hasteVersion :: Version-hasteVersion = Version [0, 4, 1] []+hasteVersion = Version [0, 4, 2] [] ghcVersion :: String ghcVersion = unsafePerformIO $ do
src/haste-pkg.hs view
@@ -53,9 +53,13 @@ prefix s pfx path = pfx ++ ": " ++ path </> stripPrefix s - stripPrefix s =- case take 2 $ reverse $ splitPath s of- [second, first] -> first </> second+ stripPrefix s+ | os == "darwin" =+ case take 3 $ reverse $ splitPath s of+ [third, second, first] -> first </> second </> third+ | otherwise =+ case take 2 $ reverse $ splitPath s of+ [second, first] -> first </> second isKey _ "" = False@@ -63,6 +67,6 @@ and $ zipWith (==) key str importDir- | os == "mingw32" = "${pkgroot}" </> "libraries"- | otherwise = "${pkgroot}" </> "libraries" </> "lib"+ | os == "linux" = "${pkgroot}" </> "libraries" </> "lib"+ | otherwise = "${pkgroot}" </> "libraries" includeDir = "${pkgroot}" </> "include"