diff options
author | Bodigrim <andrew.lelechenko@gmail.com> | 2023-02-11 14:15:30 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-02-16 10:18:24 -0500 |
commit | 5b0388880e10ce53565721a9569d009d4534cbc1 (patch) | |
tree | fe87bd887c1384392c82e27ca118c335118f8f3e | |
parent | 12965aba860676ec68cbced86eb18d6ec5cb83b3 (diff) | |
download | haskell-5b0388880e10ce53565721a9569d009d4534cbc1.tar.gz |
Documentation: add an example of SPEC usage
-rwxr-xr-x | libraries/base/GHC/Exts.hs | 7 | ||||
-rw-r--r-- | libraries/ghc-prim/GHC/Types.hs | 20 |
2 files changed, 24 insertions, 3 deletions
diff --git a/libraries/base/GHC/Exts.hs b/libraries/base/GHC/Exts.hs index da73955cba..5ebdc11a13 100755 --- a/libraries/base/GHC/Exts.hs +++ b/libraries/base/GHC/Exts.hs @@ -203,8 +203,11 @@ traceEvent = Debug.Trace.traceEventIO * * ********************************************************************** -} --- Annotating a type with NoSpecConstr will make SpecConstr --- not specialise for arguments of that type. +-- | Deprecated, use 'SPEC' directly instead. +-- +-- Annotating a type with 'NoSpecConstr' will make @SpecConstr@ +-- not specialise for arguments of that type, +-- e. g., @{-# ANN type SPEC ForceSpecConstr #-}@. -- This data type is defined here, rather than in the SpecConstr module -- itself, so that importing it doesn't force stupidly linking the diff --git a/libraries/ghc-prim/GHC/Types.hs b/libraries/ghc-prim/GHC/Types.hs index 8b9d23787b..448618b537 100644 --- a/libraries/ghc-prim/GHC/Types.hs +++ b/libraries/ghc-prim/GHC/Types.hs @@ -435,7 +435,25 @@ you're reading this in 2023 then things went wrong). See #8326. -- specializations. However, not all loops fall into this category. -- -- Libraries can specify this by using 'SPEC' data type to inform which --- loops should be aggressively specialized. +-- loops should be aggressively specialized. For example, +-- instead of +-- +-- > loop x where loop arg = ... +-- +-- write +-- +-- > loop SPEC x where loop !_ arg = ... +-- +-- There is no semantic difference between 'SPEC' and 'SPEC2', +-- we just need a type with two contructors lest it is optimised away +-- before @SpecConstr@. +-- +-- This type is reexported from "GHC.Exts" since GHC 9.0 and @base-4.15@. +-- For compatibility with earlier releases import it from "GHC.Types" +-- in @ghc-prim@ package. +-- +-- @since 0.3.1.0 +-- data SPEC = SPEC | SPEC2 |