@@ -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
43import Reflex.Dom (WithWebView, askWebView, runWithWebView, unWebViewSingleton)
45import Reflex.Dom (WithWebView, askWebView, runWithWebView, unWebViewSingleton)
@@ -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
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