From c4f3d91b6b32a27c2e00506de532e90c595de2d1 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Thu, 21 Jul 2016 04:32:55 -0700 Subject: 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 --- libraries/ghci/GHCi/RemoteTypes.hs | 5 +++++ libraries/ghci/SizedSeq.hs | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'libraries/ghci') 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 [] -- cgit v1.2.1