summaryrefslogtreecommitdiff
path: root/libraries/ghci
diff options
context:
space:
mode:
authorSimon Marlow <smarlow@fb.com>2016-07-21 04:32:55 -0700
committerSimon Marlow <marlowsd@gmail.com>2016-07-22 13:56:41 +0100
commitc4f3d91b6b32a27c2e00506de532e90c595de2d1 (patch)
tree75e294b134c3cc6e83c69a0171925718dfbd3270 /libraries/ghci
parentbfef2eb1898641f250a1b39fe67c18963a709534 (diff)
downloadhaskell-c4f3d91b6b32a27c2e00506de532e90c595de2d1.tar.gz
Add deepseq dependency and a few NFData instances
I needed to rnf a data structure (CompiledByteCode) but we don't have any good deepseq infrastructure in the compiler yet. There are bits and pieces, but nothing consistent, so this is a start. We already had a dependency on deepseq indirectly via other packages (e.g. containers). Includes an update to the haddock submodule, to remove orphan NFData instances in there. Test Plan: validate Reviewers: austin, bgamari, erikd, hvr Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2418
Diffstat (limited to 'libraries/ghci')
-rw-r--r--libraries/ghci/GHCi/RemoteTypes.hs5
-rw-r--r--libraries/ghci/SizedSeq.hs4
2 files changed, 9 insertions, 0 deletions
diff --git a/libraries/ghci/GHCi/RemoteTypes.hs b/libraries/ghci/GHCi/RemoteTypes.hs
index 5bc0136113..3b4dee75c5 100644
--- a/libraries/ghci/GHCi/RemoteTypes.hs
+++ b/libraries/ghci/GHCi/RemoteTypes.hs
@@ -17,6 +17,7 @@ module GHCi.RemoteTypes
, unsafeForeignRefToRemoteRef, finalizeForeignRef
) where
+import Control.DeepSeq
import Data.Word
import Foreign hiding (newForeignPtr)
import Foreign.Concurrent
@@ -49,6 +50,7 @@ castRemotePtr (RemotePtr a) = RemotePtr a
deriving instance Show (RemotePtr a)
deriving instance Binary (RemotePtr a)
+deriving instance NFData (RemotePtr a)
-- -----------------------------------------------------------------------------
-- HValueRef
@@ -91,6 +93,9 @@ freeRemoteRef (RemoteRef w) =
-- | An HValueRef with a finalizer
newtype ForeignRef a = ForeignRef (ForeignPtr ())
+instance NFData (ForeignRef a) where
+ rnf x = x `seq` ()
+
type ForeignHValue = ForeignRef HValue
-- | Create a 'ForeignRef' from a 'RemoteRef'. The finalizer
diff --git a/libraries/ghci/SizedSeq.hs b/libraries/ghci/SizedSeq.hs
index e5bb37c2f1..503544a9ed 100644
--- a/libraries/ghci/SizedSeq.hs
+++ b/libraries/ghci/SizedSeq.hs
@@ -8,6 +8,7 @@ module SizedSeq
, sizeSS
) where
+import Control.DeepSeq
import Data.Binary
import Data.List
import GHC.Generics
@@ -26,6 +27,9 @@ instance Traversable SizedSeq where
instance Binary a => Binary (SizedSeq a)
+instance NFData a => NFData (SizedSeq a) where
+ rnf (SizedSeq _ xs) = rnf xs
+
emptySS :: SizedSeq a
emptySS = SizedSeq 0 []