From 7590436bf049c526c92bf4172ee6a2345c271dae Mon Sep 17 00:00:00 2001 From: Travis Whitaker Date: Fri, 20 Sep 2019 22:22:08 -0700 Subject: [PATCH] Add TVar, fix UArray typo, use Foreign.ForeignPtr.Safe when old. --- Control/DeepSeq.hs | 22 +++++++++++++++++++++- Control/DeepSeq/BackDoor.hs | 17 ++++++----------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/Control/DeepSeq.hs b/Control/DeepSeq.hs index 497bbb4..3a1d473 100644 --- a/Control/DeepSeq.hs +++ b/Control/DeepSeq.hs @@ -107,6 +107,12 @@ import Foreign.C.Types import System.Exit ( ExitCode(..) ) import System.Mem.StableName ( StableName ) +#if MIN_VERSION_base(4,8,0) +import Foreign.ForeignPtr +#else +import Foreign.ForeignPtr.Safe +#endif + #if MIN_VERSION_base(4,6,0) import Data.Ord ( Down(Down) ) #else @@ -125,6 +131,10 @@ import Data.Type.Equality ( (:~:) ) import Control.DeepSeq.BackDoor ( (:~:) ) #endif +#if MIN_VERSION_base(4,0,0) +import Control.DeepSeq.BackDoor ( TVar ) +#endif + #if MIN_VERSION_base(4,8,0) import Data.Functor.Identity ( Identity(..) ) import Data.Typeable ( rnfTypeRep, rnfTyCon ) @@ -627,7 +637,7 @@ instance (Ix i, NFData i, NFData e) => NFData (UArray i e) where instance (NFData i) => NFData1 (UArray i) where #else -- |@since 1.4.5.0 -instance (Ix i, NFData i) => NFData1 (UArray a) where +instance (Ix i, NFData i) => NFData1 (UArray i) where #endif liftRnf _ = rwhnf @@ -752,6 +762,16 @@ instance NFData (MVar a) where instance NFData1 MVar where liftRnf _ = rwhnf +#if MIN_VERSION_base(4,0,0) +-- | __NOTE__: Only strict in the reference and not the referenced value. +-- +-- @since 1.4.5.0 +instance NFData (TVar a) where + rnf = rwhnf +instance NFData1 TVar where + liftRnf _ = rwhnf +#endif + ---------------------------------------------------------------------------- -- GHC Specifics diff --git a/Control/DeepSeq/BackDoor.hs b/Control/DeepSeq/BackDoor.hs index 343ec56..d9347a7 100644 --- a/Control/DeepSeq/BackDoor.hs +++ b/Control/DeepSeq/BackDoor.hs @@ -5,14 +5,6 @@ -- This module only re-export reasonably safe entities from non-safe -- modules when there is no safe alternative -#if MIN_VERSION_base(4,9,0) || (MIN_VERSION_base(4,6,0) && !MIN_VERSION_base(4,7,0)) -{-# LANGUAGE Safe #-} - -module Control.DeepSeq.BackDoor - {-# WARNING "This module is empty! Do not import me!" #-} - () where - -#else {-# LANGUAGE Trustworthy #-} module Control.DeepSeq.BackDoor @@ -20,14 +12,17 @@ module Control.DeepSeq.BackDoor ) where #if !(MIN_VERSION_base(4,6,0)) --- not SAFE +-- not safe, but Down is in Data.Ord starting with base-4.6 import GHC.Exts as X ( Down(Down) ) #endif -#if MIN_VERSION_base(4,10,0) --- Data.Type.Equality SAFE starting with base-4.10 +#if MIN_VERSION_base(4,9,0) +-- Data.Type.Equality present from base-4.7, trustworthy starting with base-4.9 #elif MIN_VERSION_base(4,7,0) import Data.Type.Equality as X ( (:~:) ) #endif +#if MIN_VERSION_base(4,0,0) +-- present since at least base-4.0, maybe sooner? +import GHC.Conc as X ( TVar(TVar) ) #endif