on develop help sign in
Add additional disambiguation for jsffi import names
commit10664306f5648802be4f2bd296b4a5ddcdd7baf1 authorRyan Trinkle <ryan.trinkle@gmail.com> dateSat 1 Aug 2015, 03:54 (11 years ago) parentc5f7300
3 files changed+11−6
default.nix+2−1 reflex-dom.cabal+2−1 src/Foreign/JavaScript/TH.hs+7−4
default.nix+2−1
@@ -2,7 +2,7 @@
22, mtl, ref-tf, reflex, safe, text, these
33, transformers, data-default, semigroups, aeson
44, ghc, webkitgtk3-javascriptcore, exception-transformers
5−, webkitgtk24x, dependent-sum-template, bifunctors
5+, webkitgtk24x, dependent-sum-template, bifunctors, zenc
66}:
77
88mkDerivation {
@@ -26,6 +26,7 @@ mkDerivation {
2626 exception-transformers
2727 dependent-sum-template
2828 bifunctors
29+ zenc
2930 ] ++ (if (ghc.pname or null) == "ghcjs" then [ ] else [ webkitgtk3-javascriptcore ]);
3031 pkgconfigDepends = if (ghc.pname or null) == "ghcjs" then [ ] else [ webkitgtk24x ];
3132 license = null;
reflex-dom.cabal+2−1
@@ -41,7 +41,8 @@ library
4141 exception-transformers == 0.4.*,
4242 directory == 1.2.*,
4343 dependent-sum-template >= 0.0.0.4 && < 0.1,
44− bifunctors == 4.2.*
44+ bifunctors == 4.2.*,
45+ zenc == 0.1.*
4546
4647 if impl(ghcjs)
4748 hs-source-dirs: src-ghcjs
src/Foreign/JavaScript/TH.hs+7−4
@@ -39,6 +39,8 @@ import Data.ByteString (ByteString)
3939import qualified Data.ByteString as BS
4040import Control.Concurrent
4141import Data.Coerce
42+import Text.Encoding.Z
43+import Data.Monoid
4244
4345import Reflex.Dom (WithWebView, askWebView, runWithWebView, unWebViewSingleton)
4446
@@ -377,9 +379,10 @@ mkJSFFI :: Safety -> String -> Q ([Dec], Exp)
377379#ifdef __GHCJS__
378380mkJSFFI safety body = do
379381 -- n <- newName "jsffi" --TODO: Should use newName, but that doesn't seem to work with ghcjs
380− let n = mkName $ "jsffi_" ++ show (abs (hash (show safety, body)))
382+ l <- location
383+ n <- newName $ "jsffi_" <> zEncodeString (loc_package l <> ":" <> loc_module l) <> "_" <> show (abs (hash (show safety, body)))
381384 t <- [t| JSFFI_Internal |]
382− let wrappedBody = "(function(){ return (" ++ body ++ "); }).apply($1)"
385+ let wrappedBody = "(function(){ return (" <> body <> "); }).apply($1)"
383386 let decs = [ForeignD $ ImportF JavaScript safety wrappedBody n t]
384387 e <- [| JSFFI $(varE n) |]
385388 return (decs, e)
@@ -398,5 +401,5 @@ parseType (ForallT _ [AppT (AppT (ConT monadJs) (VarT _)) (VarT m)] funType)
398401 in (arg : args, result)
399402 AppT (VarT m') result
400403 | m' == m -> ([], result)
401− _ -> error $ "parseType: can't parse type " ++ show t
402−parseType t = error $ "parseType: can't parse type " ++ show t
404+ _ -> error $ "parseType: can't parse type " <> show t
405+parseType t = error $ "parseType: can't parse type " <> show t