packages feed

ghc-heap-view 0.5.0.1 → 0.5.1

raw patch · 2 files changed

+30/−2 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ GHC.AssertNF: isNF :: a -> IO Bool

Files

ghc-heap-view.cabal view
@@ -1,5 +1,5 @@ Name:                ghc-heap-view-Version:             0.5.0.1+Version:             0.5.1 Synopsis:            Extract the heap representation of Haskell values and thunks Description:   This library provides functions to introspect the Haskell heap, for example@@ -65,7 +65,7 @@     containers,     transformers,     template-haskell,-    bytestring (>= 0.10),+    bytestring >= 0.10,     binary,     ghc   C-Sources: cbits/HeapView.c cbits/HeapViewPrim.cmm
src/GHC/AssertNF.hs view
@@ -20,6 +20,7 @@     assertNFNamed,     assertNFHere,     disableAssertNF,+    isNF,     ) where @@ -121,3 +122,30 @@ -- to 'assertNF' and its variants to noops. disableAssertNF :: IO () disableAssertNF = writeIORef enabledRef False++-- | A variant of 'assertNF' that does not print anything and just returns+-- 'True' if the value is in normal form, or 'False' otherwise. This function+-- is not affected by 'disableAssertNF'.+isNF :: a -> IO Bool+isNF x = isNFBoxed (asBox x)++isNFBoxed :: Box -> IO Bool+isNFBoxed b = do+    c <- getBoxedClosureData b+    nf <- isHNF c+    if nf+    then do+        c' <- getBoxedClosureData b+        allM isNFBoxed (allPtrs c')+    else do+        return False++-- From Control.Monad.Loops in monad-loops, but I'd like to avoid too many+-- trivial dependencies+allM :: (Monad m) => (a -> m Bool) -> [a] -> m Bool+allM _ []       = return True+allM p (x:xs)   = do+        q <- p x+        if q+                then allM p xs+                else return False