Skip to content

Commit

Permalink
Add TVar, fix UArray typo, use Foreign.ForeignPtr.Safe when old.
Browse files Browse the repository at this point in the history
  • Loading branch information
TravisWhitaker committed Sep 21, 2019
1 parent 468fc06 commit b7889db
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
23 changes: 21 additions & 2 deletions Control/DeepSeq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,16 @@ import Data.Monoid as Mon
import Data.Typeable ( TypeRep, TyCon )
import Data.Unique ( Unique )
import Foreign.Ptr
import Foreign.ForeignPtr
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
Expand All @@ -125,6 +130,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 )
Expand Down Expand Up @@ -627,7 +636,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

Expand Down Expand Up @@ -752,6 +761,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

Expand Down
17 changes: 6 additions & 11 deletions Control/DeepSeq/BackDoor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,24 @@
-- 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
( module X
) 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

0 comments on commit b7889db

Please sign in to comment.