Teo Camarasu pushed to branch wip/T26832 at Glasgow Haskell Compiler / GHC

Commits:

4 changed files:

Changes:

  • compiler/GHC/Builtin/Names.hs
    ... ... @@ -1063,7 +1063,7 @@ alternativeClassKey = mkPreludeMiscIdUnique 754
    1063 1063
     
    
    1064 1064
     -- Functions for GHC extensions
    
    1065 1065
     considerAccessibleName :: Name
    
    1066
    -considerAccessibleName = varQual gHC_INTERNAL_EXTS (fsLit "considerAccessible") considerAccessibleIdKey
    
    1066
    +considerAccessibleName = varQual gHC_MAGIC (fsLit "considerAccessible") considerAccessibleIdKey
    
    1067 1067
     
    
    1068 1068
     -- Random GHC.Internal.Base functions
    
    1069 1069
     fromStringName, otherwiseIdName, foldrName, buildName, augmentName,
    

  • libraries/ghc-internal/src/GHC/Internal/Exts.hs
    ... ... @@ -321,10 +321,7 @@ import GHC.Internal.Data.Data
    321 321
     import GHC.Internal.Data.Ord
    
    322 322
     import qualified GHC.Internal.Debug.Trace
    
    323 323
     import GHC.Internal.Unsafe.Coerce ( unsafeCoerce# ) -- just for re-export
    
    324
    -
    
    325
    --- XXX This should really be in Data.Tuple, where the definitions are
    
    326
    -maxTupleSize :: Int
    
    327
    -maxTupleSize = 64
    
    324
    +import GHC.Internal.Tuple (maxTupleSize)
    
    328 325
     
    
    329 326
     -- | 'the' ensures that all the elements of the list are identical
    
    330 327
     -- and then returns that unique element
    
    ... ... @@ -444,27 +441,3 @@ resizeSmallMutableArray# arr0 szNew a s0 =
    444 441
               (# s2, arr1 #) -> case copySmallMutableArray# arr0 0# arr1 0# szOld s2 of
    
    445 442
                 s3 -> (# s3, arr1 #)
    
    446 443
             else (# s1, arr0 #)
    447
    -
    
    448
    --- | Semantically, @considerAccessible = True@. But it has special meaning
    
    449
    --- to the pattern-match checker, which will never flag the clause in which
    
    450
    --- 'considerAccessible' occurs as a guard as redundant or inaccessible.
    
    451
    --- Example:
    
    452
    ---
    
    453
    --- > case (x, x) of
    
    454
    --- >   (True,  True)  -> 1
    
    455
    --- >   (False, False) -> 2
    
    456
    --- >   (True,  False) -> 3 -- Warning: redundant
    
    457
    ---
    
    458
    --- The pattern-match checker will warn here that the third clause is redundant.
    
    459
    --- It will stop doing so if the clause is adorned with 'considerAccessible':
    
    460
    ---
    
    461
    --- > case (x, x) of
    
    462
    --- >   (True,  True)  -> 1
    
    463
    --- >   (False, False) -> 2
    
    464
    --- >   (True,  False) | considerAccessible -> 3 -- No warning
    
    465
    ---
    
    466
    --- Put 'considerAccessible' as the last statement of the guard to avoid get
    
    467
    --- confusing results from the pattern-match checker, which takes \"consider
    
    468
    --- accessible\" by word.
    
    469
    -considerAccessible :: Bool
    
    470
    -considerAccessible = True

  • libraries/ghc-internal/src/GHC/Internal/Magic.hs
    ... ... @@ -24,7 +24,7 @@
    24 24
     --
    
    25 25
     -----------------------------------------------------------------------------
    
    26 26
     
    
    27
    -module GHC.Internal.Magic ( inline, noinline, lazy, oneShot, runRW#, DataToTag(..) ) where
    
    27
    +module GHC.Internal.Magic ( inline, noinline, lazy, oneShot, runRW#, DataToTag(..), considerAccessible ) where
    
    28 28
     
    
    29 29
     --------------------------------------------------
    
    30 30
     --        See Note [magicIds] in GHC.Types.Id.Make
    
    ... ... @@ -34,7 +34,7 @@ module GHC.Internal.Magic ( inline, noinline, lazy, oneShot, runRW#, DataToTag(.
    34 34
     -- because TYPE is not exported by the source Haskell module generated by
    
    35 35
     -- genprimops which Haddock will typecheck (#15935).
    
    36 36
     import GHC.Internal.Prim (State#, realWorld#, RealWorld, Int#)
    
    37
    -import GHC.Internal.Types (RuntimeRep(BoxedRep), TYPE, Levity, Constraint)
    
    37
    +import GHC.Internal.Types (RuntimeRep(BoxedRep), TYPE, Levity, Constraint, Bool(True))
    
    38 38
     
    
    39 39
     -- | The call @inline f@ arranges that @f@ is inlined, regardless of
    
    40 40
     -- its size. More precisely, the call @inline f@ rewrites to the
    
    ... ... @@ -137,3 +137,27 @@ type DataToTag :: forall {lev :: Levity}. TYPE (BoxedRep lev) -> Constraint
    137 137
     -- So it does not get its own Unsafe module, unlike WithDict.
    
    138 138
     class DataToTag a where
    
    139 139
       dataToTag# :: a -> Int#
    
    140
    +
    
    141
    +-- | Semantically, @considerAccessible = True@. But it has special meaning
    
    142
    +-- to the pattern-match checker, which will never flag the clause in which
    
    143
    +-- 'considerAccessible' occurs as a guard as redundant or inaccessible.
    
    144
    +-- Example:
    
    145
    +--
    
    146
    +-- > case (x, x) of
    
    147
    +-- >   (True,  True)  -> 1
    
    148
    +-- >   (False, False) -> 2
    
    149
    +-- >   (True,  False) -> 3 -- Warning: redundant
    
    150
    +--
    
    151
    +-- The pattern-match checker will warn here that the third clause is redundant.
    
    152
    +-- It will stop doing so if the clause is adorned with 'considerAccessible':
    
    153
    +--
    
    154
    +-- > case (x, x) of
    
    155
    +-- >   (True,  True)  -> 1
    
    156
    +-- >   (False, False) -> 2
    
    157
    +-- >   (True,  False) | considerAccessible -> 3 -- No warning
    
    158
    +--
    
    159
    +-- Put 'considerAccessible' as the last statement of the guard to avoid get
    
    160
    +-- confusing results from the pattern-match checker, which takes \"consider
    
    161
    +-- accessible\" by word.
    
    162
    +considerAccessible :: Bool
    
    163
    +considerAccessible = True

  • libraries/ghc-internal/src/GHC/Internal/Tuple.hs
    ... ... @@ -27,10 +27,11 @@ module GHC.Internal.Tuple (
    27 27
       Tuple40(..), Tuple41(..), Tuple42(..), Tuple43(..), Tuple44(..), Tuple45(..), Tuple46(..), Tuple47(..), Tuple48(..), Tuple49(..),
    
    28 28
       Tuple50(..), Tuple51(..), Tuple52(..), Tuple53(..), Tuple54(..), Tuple55(..), Tuple56(..), Tuple57(..), Tuple58(..), Tuple59(..),
    
    29 29
       Tuple60(..), Tuple61(..), Tuple62(..), Tuple63(..), Tuple64(..),
    
    30
    +  maxTupleSize,
    
    30 31
     ) where
    
    31 32
     
    
    32 33
     -- See W1 of Note [Tracking dependencies on primitives] in GHC.Internal.Base
    
    33
    -import GHC.Internal.Types ()
    
    34
    +import GHC.Internal.Types (Int)
    
    34 35
     
    
    35 36
     default () -- Double and Integer aren't available yet
    
    36 37
     
    
    ... ... @@ -598,3 +599,6 @@ data Tuple64 a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1 c1 d1 e1
    598 599
           r1 s1 t1 u1 v1 w1 x1 y1 z1 a2 b2 c2 d2 e2 f2 g2 h2 i2 j2 k2 l2
    
    599 600
       = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1,n1,o1,p1,q1,
    
    600 601
          r1,s1,t1,u1,v1,w1,x1,y1,z1,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2)
    
    602
    +
    
    603
    +maxTupleSize :: Int
    
    604
    +maxTupleSize = 64