packages feed

ghc-experimental 9.1204.0 → 9.1402.0

raw patch · 11 files changed

Files

CHANGELOG.md view
@@ -1,5 +1,28 @@ # Revision history for ghc-experimental +## ghc-experimental-9.1402.0++- Add optional `SrcLoc` to `StackAnnotation` class in `GHC.Stack.Annotation.Experimental`+++## ghc-experimental-9.1401.0++- Expose access to RTS flags via `GHC.RTS.Flags.Experimental`+- Expose access to era profiling interface via `GHC.Profiling.Eras`+- Expose access to runtime stack annotations via `GHC.Stack.Annotation.Experimental`+- Expose custom allocation limit handler via `System.Mem.Experimental`+- Expose access to Stack Annotations via `GHC.Stack.Annotation.Experimental`+- Expose module Prelude.Experimental, which reexports some modules from ghc-experimental for convenience, like Prelude does for base.++## ghc-experimental-9.1201.0++- Expose `GHC.TypeLits.Experimental` and `GHC.TypeNats.Experimental`++## ghc-experimental-9.1002.0++- Expose primops via `GHC.PrimOps`++ ## 0.1.0.0 -- YYYY-mm-dd  * First version. Released on an unsuspecting world.
ghc-experimental.cabal view
@@ -6,14 +6,18 @@ name:               ghc-experimental -- The project is ghc's version plus ghc-experimental's version suffix. -- For example, for ghc=9.10.1, ghc-experimental's version will be 9.1001.0.-version:            9.1204.0-synopsis:           Experimental features of GHC's standard library+version:            9.1402.0+synopsis:           Experimental features of GHC's standard library and unstable GHC internals. description:     This package is where experimental GHC standard library interfaces start     life and mature. Eventually, stabilized interfaces will be     migrated into the @base@ library. +    This library also exposes some interfaces that are considered too unstable for+    the @base@ library like primitives built into GHC.+ homepage:           https://www.haskell.org/ghc/+bug-reports:        https://gitlab.haskell.org/ghc/ghc/-/issues/new license:            BSD-3-Clause license-file:       LICENSE author:             The GHC Team@@ -35,13 +39,17 @@       GHC.Profiling.Eras       GHC.TypeLits.Experimental       GHC.TypeNats.Experimental+      GHC.RTS.Flags.Experimental+      GHC.Stack.Annotation.Experimental+      GHC.Stack.Decode.Experimental+      GHC.Stats.Experimental       Prelude.Experimental+      System.Mem.Experimental       GHC.Exception.Backtrace.Experimental     if arch(wasm32)         exposed-modules:  GHC.Wasm.Prim     other-extensions:-    build-depends:    base >=4.20 && < 4.22,-                      ghc-internal == 9.1204.*,-                      ghc-prim >= 0.11 && < 0.14+    build-depends:    base >=4.20 && < 4.23,+                      ghc-internal == 9.1402.*     hs-source-dirs:   src     default-language: Haskell2010
src/Data/Sum/Experimental.hs view
@@ -80,6 +80,6 @@   Sum63#, ) where -import GHC.Types+import GHC.Internal.Types  default ()
src/Data/Tuple/Experimental.hs view
@@ -16,7 +16,7 @@ https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst -} module Data.Tuple.Experimental (-  module GHC.Tuple,+  module GHC.Internal.Tuple,   Solo (Solo, MkSolo),    -- * Unboxed tuples@@ -158,8 +158,8 @@   CTuple64, ) where -import GHC.Tuple-import GHC.Types-import GHC.Classes+import GHC.Internal.Tuple+import GHC.Internal.Types+import GHC.Internal.Classes  default ()
src/GHC/PrimOps.hs view
@@ -29,5 +29,5 @@         module GHC.Internal.Exts,        ) where -import GHC.Internal.Exts+import GHC.Internal.Exts hiding (UnusedType) 
+ src/GHC/RTS/Flags/Experimental.hs view
@@ -0,0 +1,54 @@+-- |+-- Module      :  GHC.RTS.Flags.Experimental+-- Copyright   :  (c) The University of Glasgow, 1994-2000+-- License     :  see libraries/ghc-experimental/LICENSE+--+-- Maintainer  :  ghc-devs@haskell.org+-- Stability   :  internal+-- Portability :  non-portable (GHC extensions)+--+-- /The API of this module is unstable and is coupled to GHC's internals./ As+-- such if you depend on it, you should expect to follow GHC's releases. This+-- API could change without warning.+--+-- Descriptions of flags can be seen in+-- <https://www.haskell.org/ghc/docs/latest/html/users_guide/runtime_control.html GHC User's Guide>,+-- or by running RTS help message using @+RTS --help@.+--+--++module GHC.RTS.Flags.Experimental+  ( RtsTime+  , RTSFlags (..)+  , GiveGCStats (..)+  , GCFlags (..)+  , ConcFlags (..)+  , MiscFlags (..)+  , IoManagerFlag (..)+  , DebugFlags (..)+  , DoCostCentres (..)+  , CCFlags (..)+  , DoHeapProfile (..)+  , ProfFlags (..)+  , DoTrace (..)+  , TraceFlags (..)+  , TickyFlags (..)+  , ParFlags (..)+  , HpcFlags (..)+  , {-# DEPRECATED "import GHC.IO.SubSystem (IoSubSystem (..))" #-}+    IoSubSystem (..)+  , getRTSFlags+  , getGCFlags+  , getConcFlags+  , getMiscFlags+  , getDebugFlags+  , getCCFlags+  , getProfFlags+  , getTraceFlags+  , getTickyFlags+  , getParFlags+  , getHpcFlags+  ) where++import GHC.Internal.RTS.Flags+import GHC.Internal.IO.SubSystem (IoSubSystem(..))
+ src/GHC/Stack/Annotation/Experimental.hs view
@@ -0,0 +1,252 @@+{-# LANGUAGE GADTs #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE MagicHash #-}+{-# LANGUAGE UnboxedTuples #-}+{-# LANGUAGE ImplicitParams #-}+-- |+-- Module      : GHC.Stack.Annotation.Experimental+-- Description : Push annotation stack frames onto the Haskell call stack+-- Copyright   : (c) The GHC Team+-- License     : see libraries/ghc-experimental/LICENSE+-- Maintainer  : ghc-devs@haskell.org+-- Stability   : experimental+-- Portability : non-portable (GHC Extensions)+--+-- Push user-defined annotation stack frames into the Haskell call stack.+-- Annotation stack frames may be decoded when unwinding the call stack, allowing+-- the user to gain more control over what an IPE stack trace looks like.+--+-- The main advantages of stack frame annotations over other 'Backtraces':+--+-- * Function signatures don't need to be modified to improve stack traces (e.g. via 'HasCallStack').+-- * Annotation are arbitrary user-defined datatypes, not just source locations.+-- * Stack frame annotations are always present and do not require recompilation (e.g. @-prof@ or @-g3@).+module GHC.Stack.Annotation.Experimental (+  -- * The root of Stack Annotation Types+  SomeStackAnnotation(..),+  -- * Displaying Stack Annotations+  StackAnnotation(..),+  -- * Annotation helpers+  ShowAnnotation(..),+  StringAnnotation(..),+  -- * 'CallStack' annotations+  CallStackAnnotation(..),+  -- * Push stack frame annotations in 'IO' code.+  --+  --+  annotateStackIO,+  annotateStackStringIO,+  annotateStackShowIO,+  annotateCallStackIO,+  -- * Push stack frame annotations in non-'IO' code.+  --+  -- | These variants all evaluate the code to be annotated to WHNF.+  -- Otherwise, the stack annotations will not be shown in stack traces,+  -- as the computation is immediately "evaluated" to a thunk, popping the+  -- annotation frames from the stack.+  -- If the pure computation throws an exception later, the annotation frame+  -- will not be present, thus missing in the stack trace.+  --+  -- Note, you will encounter similar issues if the exception is thrown+  -- during evaluation of a nested value, for example @Just (error "Oh, no!")@.+  annotateStack,+  annotateStackString,+  annotateStackShow,+  annotateCallStack,+  ) where++import Data.Typeable+import GHC.Exts+import GHC.IO+import GHC.Internal.Stack+import GHC.Internal.Stack.Annotation++-- Note [User-defined stack annotations for better stack traces]+-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+-- The primop 'annotateStack#' allows users to push arbitrary data onto+-- the Haskell-native call stack.+-- These annotations can later be discovered when unwinding and decoding the stack, for+-- example when an exception is thrown.+-- The annotations can add information to the call stack, such as source locations,+-- without needing 'HasCallStack' constraints in the calling function.+--+-- The feature is implemented via the stack frame 'AnnFrame', which consists of+-- nothing but an info table and a generic payload.+-- The 'AnnFrame' is semantically a no-op, and serves no further purpose than to+-- push user-defined annotations onto the Haskell-native call stack.+--+-- We provide a wrapper API for the primop 'annotateStack#' which allows users to annotate their+-- call stack in programs.+-- There are wrappers using 'IO', as well as wrappers that are pure.+-- Annotation stack frames are most reliable in the 'IO' monad, while+-- the pure variations can behave in ways that are hard to predict.+--+-- See Note [Stack annotations in pure code] for more details.++-- Note [Stack annotations in pure code]+-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+-- In lazy, non-IO code, the execution stack is quite confusing due to laziness+-- and doesn't follow any obvious intuition.+-- To make the pure API slightly more predictable, we evaluate the annotated value to WHNF.+-- This makes sure that stack annotations are present when we would intuitively expect them.+--+-- For example:+--+-- @+--  annotateStackShow (5 @Int) (fib 20 + error "Oh no!")+-- @+--+-- Without forcing the result of @(fib 20 + error "Oh no!")@, the computation+-- will simply return a thunk, and the stack annotation would be popped off the stack.+-- Once the thunk is evaluated, the exception is raised, but no stack annotation will be found!+-- If we force the result of @(fib 20 + error "Oh no!")@, then the stack+-- annotations remain on the stack, and are displayed in the stack trace.+--+-- Naturally, this only holds if no imprecise exceptions are thrown during evaluation of any+-- nested value, for example in 'annotateStackShow 5 (Just $ throw (ErrorCall "Oh no!"))', the+-- stack trace will not include the value @5@.+--++-- ----------------------------------------------------------------------------+-- Annotations+-- ----------------------------------------------------------------------------+++-- | A 'String' only annotation with an optional source location.+data StringAnnotation where+  StringAnnotation :: !(Maybe SrcLoc) -> String -> StringAnnotation++instance StackAnnotation StringAnnotation where+  displayStackAnnotationShort (StringAnnotation _srcLoc str) =+    str++  stackAnnotationSourceLocation (StringAnnotation srcLoc _str) =+    srcLoc++-- | Use the 'Show' instance of a type to display as the 'StackAnnotation'.+data ShowAnnotation where+  ShowAnnotation :: forall a . Show a => !(Maybe SrcLoc) -> a -> ShowAnnotation++instance StackAnnotation ShowAnnotation where+  displayStackAnnotationShort (ShowAnnotation _srcLoc showAnno) =+    show showAnno++  stackAnnotationSourceLocation (ShowAnnotation srcLoc _showAnno) =+    srcLoc++-- | A 'CallStack' stack annotation.+--+-- Captures the whole 'CallStack'.+newtype CallStackAnnotation = CallStackAnnotation CallStack++instance Show CallStackAnnotation where+  show (CallStackAnnotation cs) = prettyCallStack cs++-- | Displays the first entry of the 'CallStack'+instance StackAnnotation CallStackAnnotation where+  stackAnnotationSourceLocation (CallStackAnnotation cs) =+    callStackHeadSrcLoc cs++  displayStackAnnotationShort (CallStackAnnotation cs) =+    callStackHeadFunctionName cs++callStackHeadSrcLoc :: CallStack -> Maybe SrcLoc+callStackHeadSrcLoc cs =+  case getCallStack cs of+    [] -> Nothing+    (_, srcLoc):_ -> Just srcLoc++callStackHeadFunctionName :: CallStack -> String+callStackHeadFunctionName cs =+  case getCallStack cs of+    [] -> "<unknown source location>"+    (fnName, _):_ -> fnName++-- ----------------------------------------------------------------------------+-- Annotate the CallStack with custom data+-- ----------------------------------------------------------------------------++-- See Note [User-defined stack annotations for better stack traces]++-- | @'annotateStack' anno b@ annotates the evaluation stack of @b@+-- with the value of @anno@.+--+-- When decoding the call stack, the annotation frames can be used to add more+-- information to stack traces.+--+-- WARNING: forces the evaluation of @b@ to WHNF.+{-# NOINLINE annotateStack #-}+annotateStack :: forall a b. (HasCallStack, Typeable a, StackAnnotation a) => a -> b -> b+annotateStack ann b = unsafePerformIO $+  annotateStackIO ann (evaluate b)++-- | @'annotateCallStack' b@ annotates the evaluation stack of @b@+-- with the current 'callstack'.+--+-- When decoding the call stack, the annotation frames can be used to add more+-- information to stack traces.+--+-- WARNING: forces the evaluation of @b@ to WHNF.+{-# NOINLINE annotateCallStack #-}+annotateCallStack :: HasCallStack => b -> b+annotateCallStack b = unsafePerformIO $ withFrozenCallStack $+  annotateCallStackIO (evaluate b)+++-- | @'annotateStackString' msg b@ annotates the evaluation stack of @b@+-- with the value @msg@.+--+-- When decoding the call stack, the annotation frames can be used to add more+-- information to stack traces.+--+-- WARNING: forces the evaluation of @b@ to WHNF.+annotateStackString :: forall b . HasCallStack => String -> b -> b+annotateStackString ann =+  annotateStack (StringAnnotation (callStackHeadSrcLoc ?callStack) ann)++-- | @'annotateStackShow' showable b@ annotates the evaluation stack of @b@+-- with the value @showable@.+--+-- When decoding the call stack, the annotation frames can be used to add more+-- information to stack traces.+--+-- WARNING: forces the evaluation of @b@ to WHNF.+annotateStackShow :: forall a b . (HasCallStack, Typeable a, Show a) => a -> b -> b+annotateStackShow ann =+  annotateStack (ShowAnnotation (callStackHeadSrcLoc ?callStack) ann)++-- | @'annotateStackIO' showable b@ annotates the evaluation stack of @b@+-- with the value @showable@.+--+-- When decoding the call stack, the annotation frames can be used to add more+-- information to stack traces.+annotateStackIO :: forall a b . (HasCallStack, Typeable a, StackAnnotation a) => a -> IO b -> IO b+annotateStackIO ann (IO act) =+  IO $ \s -> annotateStack# (SomeStackAnnotation ann) act s++-- | @'annotateStackStringIO' msg b@ annotates the evaluation stack of @b@+-- with the value @msg@.+--+-- When decoding the call stack, the annotation frames can be used to add more+-- information to stack traces.+annotateStackStringIO :: forall b . HasCallStack => String -> IO b -> IO b+annotateStackStringIO ann =+  annotateStackIO (StringAnnotation (callStackHeadSrcLoc ?callStack) ann)++-- | @'annotateStackShowIO' msg b@ annotates the evaluation stack of @b@+-- with the value @msg@.+--+-- When decoding the call stack, the annotation frames can be used to add more+-- information to stack traces.+annotateStackShowIO :: forall a b . (HasCallStack, Show a) => a -> IO b -> IO b+annotateStackShowIO ann =+  annotateStackIO (ShowAnnotation (callStackHeadSrcLoc ?callStack) ann)++-- | @'annotateCallStackIO' b@ annotates the evaluation stack of @b@ with the+-- current 'callstack'.+--+-- When decoding the call stack, the annotation frames can be used to add more+-- information to stack traces.+annotateCallStackIO :: HasCallStack => IO a -> IO a+annotateCallStackIO =+  annotateStackIO (CallStackAnnotation ?callStack)
+ src/GHC/Stack/Decode/Experimental.hs view
@@ -0,0 +1,13 @@+module GHC.Stack.Decode.Experimental (+    -- * High-level stack decoders+    decodeStackWithIpe,+    -- * Stack decoder helpers+    decodeStackWithFrameUnpack,+    -- * StackEntry+    StackEntry(..),+    -- * Pretty printing+    prettyStackFrameWithIpe,+    prettyStackEntry,+  ) where++import GHC.Internal.Stack.Decode
+ src/GHC/Stats/Experimental.hs view
@@ -0,0 +1,27 @@+{-# LANGUAGE Safe #-}++-- |+-- Module      :  RTS.Stats.Experimental+-- Copyright   :  (c) The University of Glasgow, 1994-2000+-- License     :  see libraries/ghc-experimental/LICENSE+--+-- Maintainer  :  ghc-devs@haskell.org+-- Stability   :  internal+-- Portability :  non-portable (GHC extensions)+--+-- This module provides access to internal garbage collection and+-- memory usage statistics.  These statistics are not available unless+-- a program is run with the @-T@ RTS flag.+--+-- /The API of this module is unstable and is coupled to GHC's internals./ As+-- such if you depend on it, you should expect to follow GHC's releases. This+-- API could change without warning.++module GHC.Stats.Experimental+    ( -- * Runtime statistics+      RTSStats(..), GCDetails(..), RtsTime+    , getRTSStats+    , getRTSStatsEnabled+    ) where++import GHC.Internal.Stats
src/Prelude/Experimental.hs view
@@ -23,8 +23,8 @@   module Data.Sum.Experimental, ) where -import GHC.Types (List)-import GHC.Classes+import GHC.Internal.Types (List)+import GHC.Internal.Classes  import Data.Tuple.Experimental import Data.Sum.Experimental
+ src/System/Mem/Experimental.hs view
@@ -0,0 +1,10 @@+module System.Mem.Experimental+  ( setGlobalAllocationLimitHandler+  , AllocationLimitKillBehaviour(..)+  , getAllocationCounterFor+  , setAllocationCounterFor+  , enableAllocationLimitFor+  , disableAllocationLimitFor+  )+  where+import GHC.Internal.AllocationLimitHandler