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

Commits:

14 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/Heap/Closures.hs
    ... ... @@ -75,9 +75,10 @@ import GHC.Internal.Int
    75 75
     import GHC.Internal.Num
    
    76 76
     import GHC.Internal.Real
    
    77 77
     import GHC.Internal.Word
    
    78
    -import GHC.Internal.Exts
    
    79 78
     import GHC.Internal.Generics
    
    80 79
     import GHC.Internal.Numeric
    
    80
    +import GHC.Internal.Ptr
    
    81
    +import GHC.Internal.Unsafe.Coerce
    
    81 82
     import GHC.Internal.Stack (HasCallStack)
    
    82 83
     
    
    83 84
     ------------------------------------------------------------------------
    

  • libraries/ghc-internal/src/GHC/Internal/JS/Foreign/Callback.hs
    ... ... @@ -21,8 +21,6 @@ module GHC.Internal.JS.Foreign.Callback
    21 21
     
    
    22 22
     import           GHC.Internal.JS.Prim
    
    23 23
     
    
    24
    -import qualified GHC.Internal.Exts as Exts
    
    25
    -
    
    26 24
     import           GHC.Internal.Unsafe.Coerce
    
    27 25
     import           GHC.Internal.Base
    
    28 26
     
    
    ... ... @@ -131,18 +129,18 @@ asyncCallback3 x = js_asyncCallbackApply 3 (unsafeCoerce x)
    131 129
     -- ----------------------------------------------------------------------------
    
    132 130
     
    
    133 131
     foreign import javascript unsafe "(($1, $2) => { return h$makeCallback(h$runSync, [$1], $2); })"
    
    134
    -  js_syncCallback :: Bool -> Exts.Any -> IO (Callback (IO b))
    
    132
    +  js_syncCallback :: Bool -> Any -> IO (Callback (IO b))
    
    135 133
     foreign import javascript unsafe "(($1) => { return h$makeCallback(h$run, [], $1); })"
    
    136
    -  js_asyncCallback :: Exts.Any -> IO (Callback (IO b))
    
    134
    +  js_asyncCallback :: Any -> IO (Callback (IO b))
    
    137 135
     foreign import javascript unsafe "(($1) => { return h$makeCallback(h$runSyncReturn, [false], $1); })"
    
    138
    -  js_syncCallbackReturn :: Exts.Any -> IO (Callback (IO JSVal))
    
    136
    +  js_syncCallbackReturn :: Any -> IO (Callback (IO JSVal))
    
    139 137
     
    
    140 138
     foreign import javascript unsafe "(($1, $2, $3) => { return h$makeCallbackApply($2, h$runSync, [$1], $3); })"
    
    141
    -  js_syncCallbackApply :: Bool -> Int -> Exts.Any -> IO (Callback b)
    
    139
    +  js_syncCallbackApply :: Bool -> Int -> Any -> IO (Callback b)
    
    142 140
     foreign import javascript unsafe "(($1, $2) => { return h$makeCallbackApply($1, h$run, [], $2); })"
    
    143
    -  js_asyncCallbackApply :: Int -> Exts.Any -> IO (Callback b)
    
    141
    +  js_asyncCallbackApply :: Int -> Any -> IO (Callback b)
    
    144 142
     foreign import javascript unsafe "(($1, $2) => { return h$makeCallbackApply($1, h$runSyncReturn, [false], $2); })"
    
    145
    -  js_syncCallbackApplyReturn :: Int -> Exts.Any -> IO (Callback b)
    
    143
    +  js_syncCallbackApplyReturn :: Int -> Any -> IO (Callback b)
    
    146 144
     
    
    147 145
     foreign import javascript unsafe "h$release"
    
    148 146
       js_release :: Callback a -> IO ()

  • libraries/ghc-internal/src/GHC/Internal/JS/Prim.hs
    ... ... @@ -42,8 +42,8 @@ module GHC.Internal.JS.Prim ( JSVal(..), JSVal#
    42 42
     import           GHC.Internal.Unsafe.Coerce (unsafeCoerce)
    
    43 43
     
    
    44 44
     import           GHC.Internal.Prim
    
    45
    +import           GHC.Internal.Types
    
    45 46
     import qualified GHC.Internal.Exception as Ex
    
    46
    -import qualified GHC.Internal.Exts as Exts
    
    47 47
     import qualified GHC.Internal.CString as GHC
    
    48 48
     import           GHC.Internal.IO
    
    49 49
     import           GHC.Internal.Data.Bool
    
    ... ... @@ -78,15 +78,15 @@ instance Show JSException where
    78 78
     #if defined(javascript_HOST_ARCH)
    
    79 79
     
    
    80 80
     {-# NOINLINE toIO #-}
    
    81
    -toIO :: Exts.Any -> IO Exts.Any
    
    81
    +toIO :: Any -> IO Any
    
    82 82
     toIO x = pure x
    
    83 83
     
    
    84 84
     {-# NOINLINE resolve #-}
    
    85
    -resolve :: JSVal# -> JSVal# -> Exts.Any -> IO ()
    
    85
    +resolve :: JSVal# -> JSVal# -> Any -> IO ()
    
    86 86
     resolve accept reject x = resolveIO accept reject (pure x)
    
    87 87
     
    
    88 88
     {-# NOINLINE resolveIO #-} -- used by the rts
    
    89
    -resolveIO :: JSVal# -> JSVal# -> IO Exts.Any -> IO ()
    
    89
    +resolveIO :: JSVal# -> JSVal# -> IO Any -> IO ()
    
    90 90
     resolveIO accept reject x =
    
    91 91
       (x >>= evaluate >>= js_callback_any accept) `catch`
    
    92 92
       (\(e::Ex.SomeException) -> do
    
    ... ... @@ -260,16 +260,16 @@ seqList xs = go xs `seq` xs
    260 260
             go []     = ()
    
    261 261
     
    
    262 262
     foreign import javascript unsafe "h$toHsString"
    
    263
    -  js_fromJSString :: JSVal -> Exts.Any
    
    263
    +  js_fromJSString :: JSVal -> Any
    
    264 264
     
    
    265 265
     foreign import javascript unsafe "h$fromHsString"
    
    266
    -  js_toJSString :: Exts.Any -> JSVal
    
    266
    +  js_toJSString :: Any -> JSVal
    
    267 267
     
    
    268 268
     foreign import javascript unsafe "h$toHsListJSVal"
    
    269
    -  js_fromJSArray :: JSVal -> IO Exts.Any
    
    269
    +  js_fromJSArray :: JSVal -> IO Any
    
    270 270
     
    
    271 271
     foreign import javascript unsafe "h$fromHsListJSVal"
    
    272
    -  js_toJSArray :: Exts.Any -> IO JSVal
    
    272
    +  js_toJSArray :: Any -> IO JSVal
    
    273 273
     
    
    274 274
     foreign import javascript unsafe "(($1) => { return ($1 === null); })"
    
    275 275
       js_isNull :: JSVal -> Bool
    
    ... ... @@ -287,10 +287,10 @@ foreign import javascript unsafe "(() => { return null; })"
    287 287
       js_null :: JSVal
    
    288 288
     
    
    289 289
     foreign import javascript unsafe "(($1,$2) => { return $1[h$fromHsString($2)]; })"
    
    290
    -  js_getProp :: JSVal -> Exts.Any -> IO JSVal
    
    290
    +  js_getProp :: JSVal -> Any -> IO JSVal
    
    291 291
     
    
    292 292
     foreign import javascript unsafe "(($1,$2) => { return $1[h$fromHsString($2)]; })"
    
    293
    -  js_unsafeGetProp :: JSVal -> Exts.Any -> JSVal
    
    293
    +  js_unsafeGetProp :: JSVal -> Any -> JSVal
    
    294 294
     
    
    295 295
     foreign import javascript unsafe "(($1,$2) => { return $1[$2]; })"
    
    296 296
       js_getProp' :: JSVal -> JSVal -> IO JSVal
    
    ... ... @@ -311,7 +311,7 @@ foreign import javascript unsafe "(($1_1, $1_2) => { return h$decodeUtf8z($1_1,$
    311 311
       js_unsafeUnpackJSStringUtf8## :: Addr# -> JSVal#
    
    312 312
     
    
    313 313
     foreign import javascript unsafe "(($1, $2) => { return $1($2); })"
    
    314
    -  js_callback_any :: JSVal# -> Exts.Any -> IO ()
    
    314
    +  js_callback_any :: JSVal# -> Any -> IO ()
    
    315 315
     
    
    316 316
     foreign import javascript unsafe "(($1, $2) => { return $1($2); })"
    
    317 317
       js_callback_jsval :: JSVal# -> JSVal -> IO ()
    

  • libraries/ghc-internal/src/GHC/Internal/JS/Prim/Internal/Build.hs
    ... ... @@ -145,7 +145,6 @@ module GHC.Internal.JS.Prim.Internal.Build
    145 145
       ) where
    
    146 146
     
    
    147 147
     import GHC.Internal.JS.Prim
    
    148
    -import GHC.Internal.Exts
    
    149 148
     import GHC.Internal.IO
    
    150 149
     import GHC.Internal.Unsafe.Coerce
    
    151 150
     import GHC.Internal.Base
    

  • 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/Stack/Decode.hs
    ... ... @@ -40,8 +40,8 @@ import GHC.Internal.Data.List
    40 40
     import GHC.Internal.Data.Tuple
    
    41 41
     import GHC.Internal.Foreign.Ptr
    
    42 42
     import GHC.Internal.Foreign.Storable
    
    43
    -import GHC.Internal.Exts
    
    44 43
     import GHC.Internal.Unsafe.Coerce
    
    44
    +import GHC.Internal.Ptr
    
    45 45
     
    
    46 46
     import GHC.Internal.ClosureTypes
    
    47 47
     import GHC.Internal.Heap.Closures
    

  • 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

  • libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Exports.hs
    ... ... @@ -32,7 +32,6 @@ module GHC.Internal.Wasm.Prim.Exports (
    32 32
     
    
    33 33
     import GHC.Internal.Base
    
    34 34
     import GHC.Internal.Exception.Type
    
    35
    -import GHC.Internal.Exts
    
    36 35
     import GHC.Internal.IO
    
    37 36
     import GHC.Internal.IORef
    
    38 37
     import GHC.Internal.Int
    

  • libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Imports.hs
    ... ... @@ -30,7 +30,6 @@ module GHC.Internal.Wasm.Prim.Imports (
    30 30
     
    
    31 31
     import GHC.Internal.Base
    
    32 32
     import GHC.Internal.Exception
    
    33
    -import GHC.Internal.Exts
    
    34 33
     import GHC.Internal.IO.Unsafe
    
    35 34
     import GHC.Internal.Stable
    
    36 35
     import GHC.Internal.Wasm.Prim.Types
    

  • libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Types.hs
    ... ... @@ -20,9 +20,9 @@ module GHC.Internal.Wasm.Prim.Types (
    20 20
     
    
    21 21
     import GHC.Internal.Base
    
    22 22
     import GHC.Internal.Exception.Type
    
    23
    -import GHC.Internal.Exts
    
    24 23
     import GHC.Internal.Foreign.C.String.Encoding
    
    25 24
     import GHC.Internal.ForeignPtr
    
    25
    +import GHC.Internal.Ptr
    
    26 26
     import GHC.Internal.IO
    
    27 27
     import GHC.Internal.IO.Encoding
    
    28 28
     import GHC.Internal.Num
    

  • testsuite/tests/interface-stability/ghc-experimental-exports.stdout
    ... ... @@ -4453,6 +4453,7 @@ module Data.Tuple.Experimental where
    4453 4453
       type Unit# :: GHC.Internal.Types.ZeroBitType
    
    4454 4454
       data Unit# = ...
    
    4455 4455
       getSolo :: forall a. Solo a -> a
    
    4456
    +  maxTupleSize :: GHC.Internal.Types.Int
    
    4456 4457
     
    
    4457 4458
     module GHC.Exception.Backtrace.Experimental where
    
    4458 4459
       -- Safety: None
    
    ... ... @@ -11044,6 +11045,7 @@ module Prelude.Experimental where
    11044 11045
       type Unit# :: GHC.Internal.Types.ZeroBitType
    
    11045 11046
       data Unit# = ...
    
    11046 11047
       getSolo :: forall a. Solo a -> a
    
    11048
    +  maxTupleSize :: GHC.Internal.Types.Int
    
    11047 11049
     
    
    11048 11050
     module System.Mem.Experimental where
    
    11049 11051
       -- Safety: None
    

  • testsuite/tests/interface-stability/ghc-prim-exports.stdout
    ... ... @@ -1232,6 +1232,7 @@ module GHC.Magic where
    1232 1232
       class DataToTag a where
    
    1233 1233
         dataToTag# :: a -> GHC.Internal.Prim.Int#
    
    1234 1234
         {-# MINIMAL dataToTag# #-}
    
    1235
    +  considerAccessible :: GHC.Internal.Types.Bool
    
    1235 1236
       inline :: forall a. a -> a
    
    1236 1237
       lazy :: forall a. a -> a
    
    1237 1238
       noinline :: forall a. a -> a
    
    ... ... @@ -3891,6 +3892,7 @@ module GHC.Tuple where
    3891 3892
       type Unit :: *
    
    3892 3893
       data Unit = ()
    
    3893 3894
       getSolo :: forall a. Solo a -> a
    
    3895
    +  maxTupleSize :: GHC.Internal.Types.Int
    
    3894 3896
     
    
    3895 3897
     module GHC.Types where
    
    3896 3898
       -- Safety: None