[Git][ghc/ghc][wip/T22010] Remove unnecessary pragmas

Jaro Reinders (@Noughtmare) gitlab at gitlab.haskell.org
Fri Jul 28 15:15:53 UTC 2023



Jaro Reinders pushed to branch wip/T22010 at Glasgow Haskell Compiler / GHC


Commits:
f249403d by Jaro Reinders at 2023-07-28T17:15:37+02:00
Remove unnecessary pragmas

- - - - -


9 changed files:

- compiler/GHC/Data/Word64Map.hs
- compiler/GHC/Data/Word64Map/Internal.hs
- compiler/GHC/Data/Word64Map/Lazy.hs
- compiler/GHC/Data/Word64Map/Strict.hs
- compiler/GHC/Data/Word64Map/Strict/Internal.hs
- compiler/GHC/Data/Word64Set.hs
- compiler/GHC/Data/Word64Set/Internal.hs
- compiler/GHC/Utils/Containers/Internal/BitUtil.hs
- compiler/GHC/Utils/Containers/Internal/StrictPair.hs


Changes:

=====================================
compiler/GHC/Data/Word64Map.hs
=====================================
@@ -1,14 +1,8 @@
 {-# LANGUAGE CPP #-}
-#if !defined(TESTING) && defined(__GLASGOW_HASKELL__)
 {-# LANGUAGE Safe #-}
-#endif
-#ifdef __GLASGOW_HASKELL__
 {-# LANGUAGE DataKinds #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE MonoLocalBinds #-}
-#endif
-
-#include "containers.h"
 
 -----------------------------------------------------------------------------
 -- |


=====================================
compiler/GHC/Data/Word64Map/Internal.hs
=====================================
@@ -1,21 +1,15 @@
 {-# LANGUAGE CPP #-}
 {-# LANGUAGE BangPatterns #-}
 {-# LANGUAGE PatternGuards #-}
-#ifdef __GLASGOW_HASKELL__
 {-# LANGUAGE MagicHash #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 {-# LANGUAGE StandaloneDeriving #-}
 {-# LANGUAGE TypeFamilies #-}
-#endif
-#if !defined(TESTING) && defined(__GLASGOW_HASKELL__)
 {-# LANGUAGE Trustworthy #-}
-#endif
 
 {-# OPTIONS_HADDOCK not-home #-}
 {-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-}
 
-#include "containers.h"
-
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Data.Word64Map.Internal
@@ -313,14 +307,12 @@ import qualified GHC.Data.Word64Set.Internal as Word64Set
 import GHC.Utils.Containers.Internal.BitUtil
 import GHC.Utils.Containers.Internal.StrictPair
 
-#ifdef __GLASGOW_HASKELL__
 import Data.Coerce
 import Data.Data (Data(..), Constr, mkConstr, constrIndex, Fixity(Prefix),
                   DataType, mkDataType, gcast1)
 import GHC.Exts (build)
 import qualified GHC.Exts as GHCExts
 import Text.Read
-#endif
 import qualified Control.Category as Category
 import Data.Word
 
@@ -491,8 +483,6 @@ instance NFData a => NFData (Word64Map a) where
     rnf (Tip _ v) = rnf v
     rnf (Bin _ _ l r) = rnf l `seq` rnf r
 
-#if __GLASGOW_HASKELL__
-
 {--------------------------------------------------------------------
   A Data instance
 --------------------------------------------------------------------}
@@ -515,8 +505,6 @@ fromListConstr = mkConstr intMapDataType "fromList" [] Prefix
 intMapDataType :: DataType
 intMapDataType = mkDataType "Data.Word64Map.Internal.Word64Map" [fromListConstr]
 
-#endif
-
 {--------------------------------------------------------------------
   Query
 --------------------------------------------------------------------}
@@ -2404,13 +2392,11 @@ map f = go
     go (Tip k x)     = Tip k (f x)
     go Nil           = Nil
 
-#ifdef __GLASGOW_HASKELL__
 {-# NOINLINE [1] map #-}
 {-# RULES
 "map/map" forall f g xs . map f (map g xs) = map (f . g) xs
 "map/coerce" map coerce = coerce
  #-}
-#endif
 
 -- | \(O(n)\). Map a function over all values in the map.
 --
@@ -2424,7 +2410,6 @@ mapWithKey f t
       Tip k x     -> Tip k (f k x)
       Nil         -> Nil
 
-#ifdef __GLASGOW_HASKELL__
 {-# NOINLINE [1] mapWithKey #-}
 {-# RULES
 "mapWithKey/mapWithKey" forall f g xs . mapWithKey f (mapWithKey g xs) =
@@ -2434,7 +2419,6 @@ mapWithKey f t
 "map/mapWithKey" forall f g xs . map f (mapWithKey g xs) =
   mapWithKey (\k a -> f (g k a)) xs
  #-}
-#endif
 
 -- | \(O(n)\).
 -- @'traverseWithKey' f s == 'fromList' <$> 'traverse' (\(k, v) -> (,) k <$> f k v) ('toList' m)@
@@ -3103,13 +3087,11 @@ fromSet f (Word64Set.Tip kx bm) = buildTree f kx bm (Word64Set.suffixBitMask + 1
   Lists
 --------------------------------------------------------------------}
 
-#ifdef __GLASGOW_HASKELL__
 -- | @since 0.5.6.2
 instance GHCExts.IsList (Word64Map a) where
   type Item (Word64Map a) = (Key,a)
   fromList = fromList
   toList   = toList
-#endif
 
 -- | \(O(n)\). Convert the map to a list of key\/value pairs. Subject to list
 -- fusion.
@@ -3137,7 +3119,6 @@ toDescList :: Word64Map a -> [(Key,a)]
 toDescList = foldlWithKey (\xs k x -> (k,x):xs) []
 
 -- List fusion for the list generating functions.
-#if __GLASGOW_HASKELL__
 -- The foldrFB and foldlFB are fold{r,l}WithKey equivalents, used for list fusion.
 -- They are important to convert unfused methods back, see mapFB in prelude.
 foldrFB :: (Key -> a -> b -> b) -> b -> Word64Map a -> b
@@ -3169,7 +3150,6 @@ foldlFB = foldlWithKey
 {-# RULES "Word64Map.toAscListBack" [1] foldrFB (\k x xs -> (k, x) : xs) [] = toAscList #-}
 {-# RULES "Word64Map.toDescList" [~1] forall m . toDescList m = build (\c n -> foldlFB (\xs k x -> c (k,x) xs) n m) #-}
 {-# RULES "Word64Map.toDescListBack" [1] foldlFB (\xs k x -> (k, x) : xs) [] = toDescList #-}
-#endif
 
 
 -- | \(O(n \min(n,W))\). Create a map from a list of key\/value pairs.
@@ -3359,11 +3339,9 @@ instance Ord1 Word64Map where
 instance Functor Word64Map where
     fmap = map
 
-#ifdef __GLASGOW_HASKELL__
     a <$ Bin p m l r = Bin p m (a <$ l) (a <$ r)
     a <$ Tip k _     = Tip k a
     _ <$ Nil         = Nil
-#endif
 
 {--------------------------------------------------------------------
   Show
@@ -3385,19 +3363,12 @@ instance Show1 Word64Map where
   Read
 --------------------------------------------------------------------}
 instance (Read e) => Read (Word64Map e) where
-#ifdef __GLASGOW_HASKELL__
   readPrec = parens $ prec 10 $ do
     Ident "fromList" <- lexP
     xs <- readPrec
     return (fromList xs)
 
   readListPrec = readListPrecDefault
-#else
-  readsPrec p = readParen (p > 10) $ \ r -> do
-    ("fromList",s) <- lex r
-    (xs,t) <- reads s
-    return (fromList xs,t)
-#endif
 
 -- | @since 0.5.9
 instance Read1 Word64Map where


=====================================
compiler/GHC/Data/Word64Map/Lazy.hs
=====================================
@@ -1,9 +1,5 @@
 {-# LANGUAGE CPP #-}
-#if !defined(TESTING) && defined(__GLASGOW_HASKELL__)
 {-# LANGUAGE Safe #-}
-#endif
-
-#include "containers.h"
 
 -----------------------------------------------------------------------------
 -- |
@@ -67,11 +63,7 @@
 
 module GHC.Data.Word64Map.Lazy (
     -- * Map type
-#if !defined(TESTING)
     Word64Map, Key          -- instance Eq,Show
-#else
-    Word64Map(..), Key          -- instance Eq,Show
-#endif
 
     -- * Construction
     , empty


=====================================
compiler/GHC/Data/Word64Map/Strict.hs
=====================================
@@ -1,10 +1,6 @@
 {-# LANGUAGE CPP #-}
 {-# LANGUAGE BangPatterns #-}
-#if !defined(TESTING) && defined(__GLASGOW_HASKELL__)
 {-# LANGUAGE Trustworthy #-}
-#endif
-
-#include "containers.h"
 
 -----------------------------------------------------------------------------
 -- |
@@ -86,11 +82,7 @@
 
 module GHC.Data.Word64Map.Strict (
     -- * Map type
-#if !defined(TESTING)
     Word64Map, Key          -- instance Eq,Show
-#else
-    Word64Map(..), Key          -- instance Eq,Show
-#endif
 
     -- * Construction
     , empty


=====================================
compiler/GHC/Data/Word64Map/Strict/Internal.hs
=====================================
@@ -4,8 +4,6 @@
 
 {-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-}
 
-#include "containers.h"
-
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Data.Word64Map.Strict.Internal
@@ -86,11 +84,7 @@
 
 module GHC.Data.Word64Map.Strict.Internal (
     -- * Map type
-#if !defined(TESTING)
     Word64Map, Key          -- instance Eq,Show
-#else
-    Word64Map(..), Key          -- instance Eq,Show
-#endif
 
     -- * Construction
     , empty
@@ -827,13 +821,11 @@ map f = go
     go (Tip k x)     = Tip k $! f x
     go Nil           = Nil
 
-#ifdef __GLASGOW_HASKELL__
 {-# NOINLINE [1] map #-}
 {-# RULES
 "map/map" forall f g xs . map f (map g xs) = map (\x -> f $! g x) xs
 "map/mapL" forall f g xs . map f (L.map g xs) = map (\x -> f (g x)) xs
  #-}
-#endif
 
 -- | \(O(n)\). Map a function over all values in the map.
 --
@@ -847,7 +839,6 @@ mapWithKey f t
       Tip k x     -> Tip k $! f k x
       Nil         -> Nil
 
-#ifdef __GLASGOW_HASKELL__
 -- Pay close attention to strictness here. We need to force the
 -- intermediate result for map f . map g, and we need to refrain
 -- from forcing it for map f . L.map g, etc.
@@ -875,7 +866,6 @@ mapWithKey f t
 "map/mapWithKeyL" forall f g xs . map f (L.mapWithKey g xs) =
   mapWithKey (\k a -> f (g k a)) xs
  #-}
-#endif
 
 -- | \(O(n)\).
 -- @'traverseWithKey' f s == 'fromList' <$> 'traverse' (\(k, v) -> (,) k <$> f k v) ('toList' m)@


=====================================
compiler/GHC/Data/Word64Set.hs
=====================================
@@ -1,9 +1,5 @@
 {-# LANGUAGE CPP #-}
-#if !defined(TESTING) && defined(__GLASGOW_HASKELL__)
 {-# LANGUAGE Safe #-}
-#endif
-
-#include "containers.h"
 
 -----------------------------------------------------------------------------
 -- |
@@ -65,11 +61,7 @@ module GHC.Data.Word64Set (
             -- $strictness
 
             -- * Set type
-#if !defined(TESTING)
               Word64Set          -- instance Eq,Show
-#else
-              Word64Set(..)      -- instance Eq,Show
-#endif
             , Key
 
             -- * Construction
@@ -155,10 +147,6 @@ module GHC.Data.Word64Set (
             , showTree
             , showTreeWith
 
-#if defined(TESTING)
-            -- * Internals
-            , match
-#endif
             ) where
 
 import GHC.Data.Word64Set.Internal as WS


=====================================
compiler/GHC/Data/Word64Set/Internal.hs
=====================================
@@ -1,19 +1,13 @@
 {-# LANGUAGE CPP #-}
 {-# LANGUAGE BangPatterns #-}
 {-# LANGUAGE PatternGuards #-}
-#ifdef __GLASGOW_HASKELL__
 {-# LANGUAGE MagicHash #-}
 {-# LANGUAGE StandaloneDeriving #-}
 {-# LANGUAGE TypeFamilies #-}
-#endif
-#if !defined(TESTING) && defined(__GLASGOW_HASKELL__)
 {-# LANGUAGE Trustworthy #-}
-#endif
 
 {-# OPTIONS_HADDOCK not-home #-}
 
-#include "containers.h"
-
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Data.Word64Set.Internal
@@ -205,15 +199,11 @@ import Data.Word ( Word64 )
 import GHC.Utils.Containers.Internal.BitUtil
 import GHC.Utils.Containers.Internal.StrictPair
 
-#if __GLASGOW_HASKELL__
 import Data.Data (Data(..), Constr, mkConstr, constrIndex, DataType, mkDataType)
 import qualified Data.Data
 import Text.Read
-#endif
 
-#if __GLASGOW_HASKELL__
 import qualified GHC.Exts
-#endif
 
 import qualified Data.Foldable as Foldable
 import Data.Functor.Identity (Identity(..))
@@ -279,8 +269,6 @@ instance Semigroup Word64Set where
     (<>)    = union
     stimes  = stimesIdempotentMonoid
 
-#if __GLASGOW_HASKELL__
-
 {--------------------------------------------------------------------
   A Data instance
 --------------------------------------------------------------------}
@@ -302,8 +290,6 @@ fromListConstr = mkConstr intSetDataType "fromList" [] Data.Data.Prefix
 intSetDataType :: DataType
 intSetDataType = mkDataType "Data.Word64Set.Internal.Word64Set" [fromListConstr]
 
-#endif
-
 {--------------------------------------------------------------------
   Query
 --------------------------------------------------------------------}
@@ -513,15 +499,11 @@ alterF f k s = fmap choose (f member_)
 
     choose True  = inserted
     choose False = deleted
-#ifndef __GLASGOW_HASKELL__
-{-# INLINE alterF #-}
-#else
 {-# INLINABLE [2] alterF #-}
 
 {-# RULES
 "alterF/Const" forall k (f :: Bool -> Const a Bool) . alterF f k = \s -> Const . getConst . f $ member k s
  #-}
-#endif
 
 {-# SPECIALIZE alterF :: (Bool -> Identity Bool) -> Key -> Word64Set -> Identity Word64Set #-}
 
@@ -1139,13 +1121,11 @@ elems
   Lists
 --------------------------------------------------------------------}
 
-#ifdef __GLASGOW_HASKELL__
 -- | @since 0.5.6.2
 instance GHC.Exts.IsList Word64Set where
   type Item Word64Set = Key
   fromList = fromList
   toList   = toList
-#endif
 
 -- | \(O(n)\). Convert the set to a list of elements. Subject to list fusion.
 toList :: Word64Set -> [Key]
@@ -1163,7 +1143,6 @@ toDescList :: Word64Set -> [Key]
 toDescList = foldl (flip (:)) []
 
 -- List fusion for the list generating functions.
-#if __GLASGOW_HASKELL__
 -- The foldrFB and foldlFB are foldr and foldl equivalents, used for list fusion.
 -- They are important to convert unfused to{Asc,Desc}List back, see mapFB in prelude.
 foldrFB :: (Key -> b -> b) -> b -> Word64Set -> b
@@ -1189,7 +1168,6 @@ foldlFB = foldl
 {-# RULES "Word64Set.toAscListBack" [1] foldrFB (:) [] = toAscList #-}
 {-# RULES "Word64Set.toDescList" [~1] forall s . toDescList s = GHC.Exts.build (\c n -> foldlFB (\xs x -> c x xs) n s) #-}
 {-# RULES "Word64Set.toDescListBack" [1] foldlFB (\xs x -> x : xs) [] = toDescList #-}
-#endif
 
 
 -- | \(O(n \min(n,W))\). Create a set from a list of integers.
@@ -1313,19 +1291,12 @@ instance Show Word64Set where
   Read
 --------------------------------------------------------------------}
 instance Read Word64Set where
-#ifdef __GLASGOW_HASKELL__
   readPrec = parens $ prec 10 $ do
     Ident "fromList" <- lexP
     xs <- readPrec
     return (fromList xs)
 
   readListPrec = readListPrecDefault
-#else
-  readsPrec p = readParen (p > 10) $ \ r -> do
-    ("fromList",s) <- lex r
-    (xs,t) <- reads s
-    return (fromList xs,t)
-#endif
 
 {--------------------------------------------------------------------
   NFData
@@ -1547,7 +1518,6 @@ takeWhileAntitoneBits :: Word64 -> (Word64 -> Bool) -> Nat -> Nat
 {-# INLINE foldr'Bits #-}
 {-# INLINE takeWhileAntitoneBits #-}
 
-#if defined(__GLASGOW_HASKELL__)
 indexOfTheOnlyBit :: Nat -> Word64
 {-# INLINE indexOfTheOnlyBit #-}
 indexOfTheOnlyBit bitmask = fromIntegral $ countTrailingZeros bitmask
@@ -1614,64 +1584,6 @@ takeWhileAntitoneBits prefix predicate bitmap =
           else ((1 `shiftLL` b) - 1)
   in bitmap .&. m
 
-#else
-{----------------------------------------------------------------------
-  In general case we use logarithmic implementation of
-  lowestBitSet and highestBitSet, which works up to bit sizes of 64.
-
-  Folds are linear scans.
-----------------------------------------------------------------------}
-
-lowestBitSet n0 =
-    let (n1,b1) = if n0 .&. 0xFFFFFFFF /= 0 then (n0,0)  else (n0 `shiftRL` 32, 32)
-        (n2,b2) = if n1 .&. 0xFFFF /= 0     then (n1,b1) else (n1 `shiftRL` 16, 16+b1)
-        (n3,b3) = if n2 .&. 0xFF /= 0       then (n2,b2) else (n2 `shiftRL` 8,  8+b2)
-        (n4,b4) = if n3 .&. 0xF /= 0        then (n3,b3) else (n3 `shiftRL` 4,  4+b3)
-        (n5,b5) = if n4 .&. 0x3 /= 0        then (n4,b4) else (n4 `shiftRL` 2,  2+b4)
-        b6      = if n5 .&. 0x1 /= 0        then     b5  else                   1+b5
-    in b6
-
-highestBitSet n0 =
-    let (n1,b1) = if n0 .&. 0xFFFFFFFF00000000 /= 0 then (n0 `shiftRL` 32, 32)    else (n0,0)
-        (n2,b2) = if n1 .&. 0xFFFF0000 /= 0         then (n1 `shiftRL` 16, 16+b1) else (n1,b1)
-        (n3,b3) = if n2 .&. 0xFF00 /= 0             then (n2 `shiftRL` 8,  8+b2)  else (n2,b2)
-        (n4,b4) = if n3 .&. 0xF0 /= 0               then (n3 `shiftRL` 4,  4+b3)  else (n3,b3)
-        (n5,b5) = if n4 .&. 0xC /= 0                then (n4 `shiftRL` 2,  2+b4)  else (n4,b4)
-        b6      = if n5 .&. 0x2 /= 0                then                   1+b5   else     b5
-    in b6
-
-foldlBits prefix f z bm = let lb = lowestBitSet bm
-                          in  go (prefix+lb) z (bm `shiftRL` lb)
-  where go !_ acc 0 = acc
-        go bi acc n | n `testBit` 0 = go (bi + 1) (f acc bi) (n `shiftRL` 1)
-                    | otherwise     = go (bi + 1)    acc     (n `shiftRL` 1)
-
-foldl'Bits prefix f z bm = let lb = lowestBitSet bm
-                           in  go (prefix+lb) z (bm `shiftRL` lb)
-  where go !_ !acc 0 = acc
-        go bi acc n | n `testBit` 0 = go (bi + 1) (f acc bi) (n `shiftRL` 1)
-                    | otherwise     = go (bi + 1)    acc     (n `shiftRL` 1)
-
-foldrBits prefix f z bm = let lb = lowestBitSet bm
-                          in  go (prefix+lb) (bm `shiftRL` lb)
-  where go !_ 0 = z
-        go bi n | n `testBit` 0 = f bi (go (bi + 1) (n `shiftRL` 1))
-                | otherwise     =       go (bi + 1) (n `shiftRL` 1)
-
-foldr'Bits prefix f z bm = let lb = lowestBitSet bm
-                           in  go (prefix+lb) (bm `shiftRL` lb)
-  where
-        go !_ 0 = z
-        go bi n | n `testBit` 0 = f bi $! go (bi + 1) (n `shiftRL` 1)
-                | otherwise     =         go (bi + 1) (n `shiftRL` 1)
-
-takeWhileAntitoneBits prefix predicate = foldl'Bits prefix f 0 -- Does not use antitone property
-  where
-    f acc bi | predicate bi = acc .|. bitmapOf bi
-             | otherwise    = acc
-
-#endif
-
 
 {--------------------------------------------------------------------
   Utilities


=====================================
compiler/GHC/Utils/Containers/Internal/BitUtil.hs
=====================================
@@ -1,12 +1,6 @@
 {-# LANGUAGE CPP #-}
-#if __GLASGOW_HASKELL__
 {-# LANGUAGE MagicHash #-}
-#endif
-#if !defined(TESTING) && defined(__GLASGOW_HASKELL__)
 {-# LANGUAGE Safe #-}
-#endif
-
-#include "containers.h"
 
 -----------------------------------------------------------------------------
 -- |


=====================================
compiler/GHC/Utils/Containers/Internal/StrictPair.hs
=====================================
@@ -1,9 +1,5 @@
 {-# LANGUAGE CPP #-}
-#if !defined(TESTING) && defined(__GLASGOW_HASKELL__)
 {-# LANGUAGE Safe #-}
-#endif
-
-#include "containers.h"
 
 -- | A strict pair
 



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f249403d15c48533f25a9f9dce5b6af7b8fe6832
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/20230728/68a738aa/attachment-0001.html>


More information about the ghc-commits mailing list