on master help sign in
Fixes for GHC 8.4
bf278d3Hamish Mackenzie
jsaddle/src-ghc/Data/JSString/Internal/Type.hs+2−1
@@ -38,10 +38,11 @@ import Data.Aeson (ToJSON(..), FromJSON(..))
38import Data.Data (Data)
38import Data.Data (Data)
39-- import Data.Text.Internal.Unsafe.Char (ord)
39-- import Data.Text.Internal.Unsafe.Char (ord)
40import Data.Typeable (Typeable)
40import Data.Typeable (Typeable)
41+import Data.Semigroup (Semigroup)
41import GHC.Exts (Char(..), ord#, andI#, (/=#), isTrue#)
42import GHC.Exts (Char(..), ord#, andI#, (/=#), isTrue#)
42
43
43-- | A wrapper around a JavaScript string
44-- | A wrapper around a JavaScript string
44−newtype JSString = JSString Text deriving(Show, Read, IsString, Monoid, Ord, Eq, Data, ToJSON, FromJSON, Typeable)
45+newtype JSString = JSString Text deriving(Show, Read, IsString, Semigroup, Monoid, Ord, Eq, Data, ToJSON, FromJSON, Typeable)
45
46
46instance NFData JSString where rnf !_ = ()
47instance NFData JSString where rnf !_ = ()
47
48
jsaddle/src/Language/Javascript/JSaddle/Run.hs+15−2
@@ -73,10 +73,23 @@ import Language.Javascript.JSaddle.Types
73 Object(..), JSValueReceived(..), JSM(..), Batch(..), JSValueForSend(..), syncPoint, syncAfter, sendCommand)
73 Object(..), JSValueReceived(..), JSM(..), Batch(..), JSValueForSend(..), syncPoint, syncAfter, sendCommand)
74import Language.Javascript.JSaddle.Exception (JSException(..))
74import Language.Javascript.JSaddle.Exception (JSException(..))
75import Control.DeepSeq (force, deepseq)
75import Control.DeepSeq (force, deepseq)
76+#if MIN_VERSION_base(4,11,0)
77+import GHC.Stats (getRTSStatsEnabled, getRTSStats, RTSStats(..), gcdetails_live_bytes, gc)
78+#else
76import GHC.Stats (getGCStatsEnabled, getGCStats, GCStats(..))
79import GHC.Stats (getGCStatsEnabled, getGCStats, GCStats(..))
80+#endif
77import Data.Foldable (forM_)
81import Data.Foldable (forM_)
78#endif
82#endif
79
83
84+#ifndef ghcjs_HOST_OS
85+#if MIN_VERSION_base(4,11,0)
86+currentBytesUsed = gcdetails_live_bytes . gc
87+#else
88+getRTSStatsEnabled = getGCStatsEnabled
89+getRTSStats = getGCStats
90+#endif
91+#endif
92+
80-- | Enable (or disable) JSaddle logging
93-- | Enable (or disable) JSaddle logging
81enableLogging :: Bool -> JSM ()
94enableLogging :: Bool -> JSM ()
82#ifdef ghcjs_HOST_OS
95#ifdef ghcjs_HOST_OS
@@ -193,8 +206,8 @@ runJavaScript sendBatch entryPoint = do
193 logInfo s =
206 logInfo s =
194 readIORef loggingEnabled >>= \case
207 readIORef loggingEnabled >>= \case
195 True -> do
208 True -> do
196− currentBytesUsedStr <- getGCStatsEnabled >>= \case
209+ currentBytesUsedStr <- getRTSStatsEnabled >>= \case
197− True -> show . currentBytesUsed <$> getGCStats
210+ True -> show . currentBytesUsed <$> getRTSStats
198 False -> return "??"
211 False -> return "??"
199 cbCount <- M.size <$> readTVarIO callbacks
212 cbCount <- M.size <$> readTVarIO callbacks
200 putStrLn . s $ "M " <> currentBytesUsedStr <> " CB " <> show cbCount <> " "
213 putStrLn . s $ "M " <> currentBytesUsedStr <> " CB " <> show cbCount <> " "