Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more instances. #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Control/DeepSeq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ import Foreign.C.Types
import Foreign.Ptr
import GHC.Arr (Array)
import qualified GHC.Arr
import GHC.Conc (TVar)
import GHC.Fingerprint.Type (Fingerprint (..))
import GHC.Generics
import GHC.Stack.Types (CallStack (..), SrcLoc (..))
Expand All @@ -137,6 +138,12 @@ import GHC.Tuple (Solo (..))
import Data.Array.Byte (ByteArray(..), MutableByteArray(..))
#endif

#if MIN_VERSION_base(4,8,0)
import Foreign.ForeignPtr
#else
import Foreign.ForeignPtr.Safe
#endif

-- | Hidden internal type-class
class GNFData arity f where
grnf :: RnfArgs arity a -> f a -> ()
Expand Down Expand Up @@ -758,6 +765,14 @@ instance NFData (MVar a) where
instance NFData1 MVar where
liftRnf _ = rwhnf

-- | @since 1.5.X
instance NFData (TVar a) where
rnf = rwhnf

-- | @since 1.5.X
instance NFData1 TVar where
liftRnf _ = rwhnf

----------------------------------------------------------------------------
-- GHC Specifics

Expand All @@ -784,6 +799,20 @@ instance NFData (FunPtr a) where
instance NFData1 FunPtr where
liftRnf _ = rwhnf

----------------------------------------------------------------------------
-- Foreign.Ptr

-- | __NOTE__: Only strict in the reference and not the referenced value. Not
-- strict in the finalizers.

-- | @since 1.5.X
instance NFData (ForeignPtr a) where
rnf = rwhnf

-- | @since 1.5.X
instance NFData1 ForeignPtr where
liftRnf _ = rwhnf

----------------------------------------------------------------------------
-- Foreign.C.Types

Expand Down
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Upcoming


* Add `NFData` instance for `ForeignPtr` ([#50](https://github.com/haskell/deepseq/pull/50))
* Add `NFData` instance for `TVar` ([#50](https://github.com/haskell/deepseq/pull/50))

## 1.5.1.0

Expand Down