on develop help sign in
Add additional disambiguation for jsffi import names
1066430Ryan Trinkle
default.nix+2−1
@@ -2,7 +2,7 @@
2, mtl, ref-tf, reflex, safe, text, these
2, mtl, ref-tf, reflex, safe, text, these
3, transformers, data-default, semigroups, aeson
3, transformers, data-default, semigroups, aeson
4, ghc, webkitgtk3-javascriptcore, exception-transformers
4, ghc, webkitgtk3-javascriptcore, exception-transformers
5−, webkitgtk24x, dependent-sum-template, bifunctors
5+, webkitgtk24x, dependent-sum-template, bifunctors, zenc
6}:
6}:
7
7
8mkDerivation {
8mkDerivation {
@@ -26,6 +26,7 @@ mkDerivation {
26 exception-transformers
26 exception-transformers
27 dependent-sum-template
27 dependent-sum-template
28 bifunctors
28 bifunctors
29+ zenc
29 ] ++ (if (ghc.pname or null) == "ghcjs" then [ ] else [ webkitgtk3-javascriptcore ]);
30 ] ++ (if (ghc.pname or null) == "ghcjs" then [ ] else [ webkitgtk3-javascriptcore ]);
30 pkgconfigDepends = if (ghc.pname or null) == "ghcjs" then [ ] else [ webkitgtk24x ];
31 pkgconfigDepends = if (ghc.pname or null) == "ghcjs" then [ ] else [ webkitgtk24x ];
31 license = null;
32 license = null;
reflex-dom.cabal+2−1
@@ -41,7 +41,8 @@ library
41 exception-transformers == 0.4.*,
41 exception-transformers == 0.4.*,
42 directory == 1.2.*,
42 directory == 1.2.*,
43 dependent-sum-template >= 0.0.0.4 && < 0.1,
43 dependent-sum-template >= 0.0.0.4 && < 0.1,
44− bifunctors == 4.2.*
44+ bifunctors == 4.2.*,
45+ zenc == 0.1.*
45
46
46 if impl(ghcjs)
47 if impl(ghcjs)
47 hs-source-dirs: src-ghcjs
48 hs-source-dirs: src-ghcjs
src/Foreign/JavaScript/TH.hs+7−4
@@ -39,6 +39,8 @@ import Data.ByteString (ByteString)
39import qualified Data.ByteString as BS
39import qualified Data.ByteString as BS
40import Control.Concurrent
40import Control.Concurrent
41import Data.Coerce
41import Data.Coerce
42+import Text.Encoding.Z
43+import Data.Monoid
42
44
43import Reflex.Dom (WithWebView, askWebView, runWithWebView, unWebViewSingleton)
45import Reflex.Dom (WithWebView, askWebView, runWithWebView, unWebViewSingleton)
44
46
@@ -377,9 +379,10 @@ mkJSFFI :: Safety -> String -> Q ([Dec], Exp)
377#ifdef __GHCJS__
379#ifdef __GHCJS__
378mkJSFFI safety body = do
380mkJSFFI safety body = do
379 -- n <- newName "jsffi" --TODO: Should use newName, but that doesn't seem to work with ghcjs
381 -- n <- newName "jsffi" --TODO: Should use newName, but that doesn't seem to work with ghcjs
382+ l <- location
380− let n = mkName $ "jsffi_" ++ show (abs (hash (show safety, body)))
383+ n <- newName $ "jsffi_" <> zEncodeString (loc_package l <> ":" <> loc_module l) <> "_" <> show (abs (hash (show safety, body)))
381 t <- [t| JSFFI_Internal |]
384 t <- [t| JSFFI_Internal |]
382− let wrappedBody = "(function(){ return (" ++ body ++ "); }).apply($1)"
385+ let wrappedBody = "(function(){ return (" <> body <> "); }).apply($1)"
383 let decs = [ForeignD $ ImportF JavaScript safety wrappedBody n t]
386 let decs = [ForeignD $ ImportF JavaScript safety wrappedBody n t]
384 e <- [| JSFFI $(varE n) |]
387 e <- [| JSFFI $(varE n) |]
385 return (decs, e)
388 return (decs, e)
@@ -398,5 +401,5 @@ parseType (ForallT _ [AppT (AppT (ConT monadJs) (VarT _)) (VarT m)] funType)
398 in (arg : args, result)
401 in (arg : args, result)
399 AppT (VarT m') result
402 AppT (VarT m') result
400 | m' == m -> ([], result)
403 | m' == m -> ([], result)
401− _ -> error $ "parseType: can't parse type " ++ show t
404+ _ -> error $ "parseType: can't parse type " <> show t
402−parseType t = error $ "parseType: can't parse type " ++ show t
405+parseType t = error $ "parseType: can't parse type " <> show t