diff options
author | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2021-04-06 15:51:38 +0300 |
---|---|---|
committer | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2021-05-22 22:17:04 +0300 |
commit | 385c8d8809b26b2d86883041d42fd1a33a80e990 (patch) | |
tree | db9c01ec2678aa78ce7c230668c5f83a7f49c34d /compiler/GHC/Tc | |
parent | 503388c53b0860e5a1fca11113ac7fc3e1e44492 (diff) | |
download | haskell-wip/strict-maybe.tar.gz |
Introduce Strict.Maybe, Strict.Pair (#19156)wip/strict-maybe
This patch fixes a space leak related to the use of
Maybe in RealSrcSpan by introducing a strict variant
of Maybe.
In addition to that, it also introduces a strict pair
and uses the newly introduced strict data types in a few
other places (e.g. the lexer/parser state) to reduce
allocations.
Includes a regression test.
Diffstat (limited to 'compiler/GHC/Tc')
-rw-r--r-- | compiler/GHC/Tc/Errors.hs | 5 | ||||
-rw-r--r-- | compiler/GHC/Tc/Utils/Monad.hs | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/compiler/GHC/Tc/Errors.hs b/compiler/GHC/Tc/Errors.hs index dcd9745758..3a77998c8f 100644 --- a/compiler/GHC/Tc/Errors.hs +++ b/compiler/GHC/Tc/Errors.hs @@ -66,6 +66,7 @@ import GHC.Data.List.SetOps ( equivClasses ) import GHC.Data.Maybe import qualified GHC.LanguageExtensions as LangExt import GHC.Utils.FV ( fvVarList, unionFV ) +import qualified GHC.Data.Strict as Strict import Control.Monad ( unless, when, foldM, forM_ ) import Data.Foldable ( toList ) @@ -1033,7 +1034,7 @@ mkErrorReport :: DiagnosticReason mkErrorReport rea ctxt tcl_env (Report important relevant_bindings valid_subs) = do { context <- mkErrInfo (cec_tidy ctxt) (tcl_ctxt tcl_env) ; mkTcRnMessage rea - (RealSrcSpan (tcl_loc tcl_env) Nothing) + (RealSrcSpan (tcl_loc tcl_env) Strict.Nothing) (vcat important) context (vcat $ relevant_bindings ++ valid_subs) @@ -1045,7 +1046,7 @@ mkErrorReportNC :: DiagnosticReason -> Report -> TcM (MsgEnvelope TcRnMessage) mkErrorReportNC rea tcl_env (Report important relevant_bindings valid_subs) - = mkTcRnMessage rea (RealSrcSpan (tcl_loc tcl_env) Nothing) + = mkTcRnMessage rea (RealSrcSpan (tcl_loc tcl_env) Strict.Nothing) (vcat important) O.empty (vcat $ relevant_bindings ++ valid_subs) diff --git a/compiler/GHC/Tc/Utils/Monad.hs b/compiler/GHC/Tc/Utils/Monad.hs index 2d9298e12b..e385322223 100644 --- a/compiler/GHC/Tc/Utils/Monad.hs +++ b/compiler/GHC/Tc/Utils/Monad.hs @@ -188,6 +188,7 @@ import GHC.Utils.Panic import GHC.Utils.Constants (debugIsOn) import GHC.Utils.Misc import GHC.Utils.Logger +import qualified GHC.Data.Strict as Strict import GHC.Types.Error import GHC.Types.Fixity.Env @@ -896,7 +897,7 @@ addDependentFiles fs = do getSrcSpanM :: TcRn SrcSpan -- Avoid clash with Name.getSrcLoc -getSrcSpanM = do { env <- getLclEnv; return (RealSrcSpan (tcl_loc env) Nothing) } +getSrcSpanM = do { env <- getLclEnv; return (RealSrcSpan (tcl_loc env) Strict.Nothing) } -- See Note [Error contexts in generated code] inGeneratedCode :: TcRn Bool |