summaryrefslogtreecommitdiff
path: root/compiler/GHC/HsToCore
diff options
context:
space:
mode:
authorM Farkas-Dyck <strake888@proton.me>2022-09-18 20:23:23 -0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-08 12:53:55 -0500
commit68f49874aa217c2222c80c596ef11ffd992b459a (patch)
tree215cafabd967e33b9d1c70182474d3690d1767fa /compiler/GHC/HsToCore
parent5fe11fe612e1881bd4d1b9d5950d0d801e08e159 (diff)
downloadhaskell-68f49874aa217c2222c80c596ef11ffd992b459a.tar.gz
Define `Infinite` list and use where appropriate.
Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists].
Diffstat (limited to 'compiler/GHC/HsToCore')
-rw-r--r--compiler/GHC/HsToCore/Pmc/Ppr.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/GHC/HsToCore/Pmc/Ppr.hs b/compiler/GHC/HsToCore/Pmc/Ppr.hs
index 9d57e99b07..d28f835327 100644
--- a/compiler/GHC/HsToCore/Pmc/Ppr.hs
+++ b/compiler/GHC/HsToCore/Pmc/Ppr.hs
@@ -1,6 +1,5 @@
-{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
-- | Provides facilities for pretty-printing 'Nabla's in a way appropriate for
-- user facing pattern match warnings.
@@ -10,6 +9,8 @@ module GHC.HsToCore.Pmc.Ppr (
import GHC.Prelude
+import GHC.Data.List.Infinite (Infinite (..))
+import qualified GHC.Data.List.Infinite as Inf
import GHC.Types.Basic
import GHC.Types.Id
import GHC.Types.Var.Env
@@ -101,12 +102,11 @@ prettifyRefuts nabla = listToUDFM_Directly . map attach_refuts . udfmToList
attach_refuts (u, (x, sdoc)) = (u, (sdoc, lookupRefuts nabla x))
-type PmPprM a = RWS Nabla () (DIdEnv (Id, SDoc), [SDoc]) a
+type PmPprM a = RWS Nabla () (DIdEnv (Id, SDoc), Infinite SDoc) a
-- Try nice names p,q,r,s,t before using the (ugly) t_i
-nameList :: [SDoc]
-nameList = map text ["p","q","r","s","t"] ++
- [ text ('t':show u) | u <- [(0 :: Int)..] ]
+nameList :: Infinite SDoc
+nameList = map text ["p","q","r","s","t"] Inf.++ flip Inf.unfoldr (0 :: Int) (\ u -> (text ('t':show u), u+1))
runPmPpr :: Nabla -> PmPprM a -> (a, DIdEnv (Id, SDoc))
runPmPpr nabla m = case runRWS m nabla (emptyDVarEnv, nameList) of
@@ -117,7 +117,7 @@ runPmPpr nabla m = case runRWS m nabla (emptyDVarEnv, nameList) of
getCleanName :: Id -> PmPprM SDoc
getCleanName x = do
(renamings, name_supply) <- get
- let (clean_name:name_supply') = name_supply
+ let Inf clean_name name_supply' = name_supply
case lookupDVarEnv renamings x of
Just (_, nm) -> pure nm
Nothing -> do