[Git][ghc/ghc][wip/romes/fixes-2] task: Substitute some datas for newtypes

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Fri Jun 23 14:59:09 UTC 2023



Rodrigo Mesquita pushed to branch wip/romes/fixes-2 at Glasgow Haskell Compiler / GHC


Commits:
362ac22c by Rodrigo Mesquita at 2023-06-23T15:58:54+01:00
task: Substitute some datas for newtypes

Some low-hanging fruit of data type definitions which could be defined
by a zero-cost newtype instead. None of these changes cause regressions
wrt laziness of newtypes (pattern matching on a newtype constructor
doesn't force it).

- - - - -


4 changed files:

- compiler/GHC/CmmToAsm/AArch64/RegInfo.hs
- compiler/GHC/CmmToAsm/PPC/RegInfo.hs
- compiler/GHC/Core/Map/Type.hs
- compiler/GHC/Driver/Pipeline/Phases.hs


Changes:

=====================================
compiler/GHC/CmmToAsm/AArch64/RegInfo.hs
=====================================
@@ -8,7 +8,7 @@ import GHC.Cmm
 
 import GHC.Utils.Outputable
 
-data JumpDest = DestBlockId BlockId
+newtype JumpDest = DestBlockId BlockId
 
 -- Debug Instance
 instance Outputable JumpDest where


=====================================
compiler/GHC/CmmToAsm/PPC/RegInfo.hs
=====================================
@@ -27,7 +27,7 @@ import GHC.Cmm.CLabel
 import GHC.Types.Unique
 import GHC.Utils.Outputable (ppr, text, Outputable, (<>))
 
-data JumpDest = DestBlockId BlockId
+newtype JumpDest = DestBlockId BlockId
 
 -- Debug Instance
 instance Outputable JumpDest where


=====================================
compiler/GHC/Core/Map/Type.hs
=====================================
@@ -542,7 +542,7 @@ instance Eq (DeBruijn a) => Eq (DeBruijn (Maybe a)) where
 -- We also need to do the same for multiplicity! Which, since multiplicities are
 -- encoded simply as a 'Type', amounts to have a Trie for a pair of types. Tries
 -- of pairs are composition.
-data BndrMap a = BndrMap (TypeMapG (MaybeMap TypeMapG a))
+newtype BndrMap a = BndrMap (TypeMapG (MaybeMap TypeMapG a))
 
 -- TODO(22292): derive
 instance Functor BndrMap where


=====================================
compiler/GHC/Driver/Pipeline/Phases.hs
=====================================
@@ -51,4 +51,4 @@ data TPhase res where
   T_MergeForeign :: PipeEnv -> HscEnv -> FilePath -> [FilePath] -> TPhase FilePath
 
 -- | A wrapper around the interpretation function for phases.
-data PhaseHook = PhaseHook (forall a . TPhase a -> IO a)
+newtype PhaseHook = PhaseHook (forall a . TPhase a -> IO a)



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/362ac22c305cfb22254ee8810a75b9973b051881

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/362ac22c305cfb22254ee8810a75b9973b051881
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230623/a4c015a5/attachment-0001.html>


More information about the ghc-commits mailing list