Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7922f728 by Teo Camarasu at 2026-02-11T21:50:58-05:00 ghc-internal: avoid depending on GHC.Internal.Exts This module is mostly just re-exports. It made sense as a user-facing module, but there's no good reason ghc-internal modules should depend on it and doing so linearises the module graph - move considerAccessible to GHC.Internal.Magic Previously it lived in GHC.Internal.Exts, but it really deserves to live along with the other magic function, which are already re-exported from .Exts - move maxTupleSize to GHC.Internal.Tuple This previously lived in GHC.Internal.Exts but a comment already said it should be moved to .Tuple Resolves #26832 - - - - - 16 changed files: - compiler/GHC/Builtin/Names.hs - libraries/ghc-internal/src/GHC/Internal/Exts.hs - libraries/ghc-internal/src/GHC/Internal/Heap/Closures.hs - libraries/ghc-internal/src/GHC/Internal/JS/Foreign/Callback.hs - libraries/ghc-internal/src/GHC/Internal/JS/Prim.hs - libraries/ghc-internal/src/GHC/Internal/JS/Prim/Internal/Build.hs - libraries/ghc-internal/src/GHC/Internal/Magic.hs - libraries/ghc-internal/src/GHC/Internal/Stack/Decode.hs - libraries/ghc-internal/src/GHC/Internal/Tuple.hs - libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Exports.hs - libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Imports.hs - libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Types.hs - testsuite/tests/interface-stability/ghc-experimental-exports.stdout - testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32 - testsuite/tests/interface-stability/ghc-prim-exports.stdout - testsuite/tests/interface-stability/ghc-prim-exports.stdout-mingw32 Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -1063,7 +1063,7 @@ alternativeClassKey = mkPreludeMiscIdUnique 754 -- Functions for GHC extensions considerAccessibleName :: Name -considerAccessibleName = varQual gHC_INTERNAL_EXTS (fsLit "considerAccessible") considerAccessibleIdKey +considerAccessibleName = varQual gHC_MAGIC (fsLit "considerAccessible") considerAccessibleIdKey -- Random GHC.Internal.Base functions fromStringName, otherwiseIdName, foldrName, buildName, augmentName, ===================================== libraries/ghc-internal/src/GHC/Internal/Exts.hs ===================================== @@ -319,10 +319,7 @@ import GHC.Internal.Data.OldList import GHC.Internal.Data.Ord import qualified GHC.Internal.Debug.Trace import GHC.Internal.Unsafe.Coerce ( unsafeCoerce# ) -- just for re-export - --- XXX This should really be in Data.Tuple, where the definitions are -maxTupleSize :: Int -maxTupleSize = 64 +import GHC.Internal.Tuple (maxTupleSize) -- | 'the' ensures that all the elements of the list are identical -- and then returns that unique element @@ -441,27 +438,3 @@ resizeSmallMutableArray# arr0 szNew a s0 = (# s2, arr1 #) -> case copySmallMutableArray# arr0 0# arr1 0# szOld s2 of s3 -> (# s3, arr1 #) else (# s1, arr0 #) - --- | Semantically, @considerAccessible = True@. But it has special meaning --- to the pattern-match checker, which will never flag the clause in which --- 'considerAccessible' occurs as a guard as redundant or inaccessible. --- Example: --- --- > case (x, x) of --- > (True, True) -> 1 --- > (False, False) -> 2 --- > (True, False) -> 3 -- Warning: redundant --- --- The pattern-match checker will warn here that the third clause is redundant. --- It will stop doing so if the clause is adorned with 'considerAccessible': --- --- > case (x, x) of --- > (True, True) -> 1 --- > (False, False) -> 2 --- > (True, False) | considerAccessible -> 3 -- No warning --- --- Put 'considerAccessible' as the last statement of the guard to avoid get --- confusing results from the pattern-match checker, which takes \"consider --- accessible\" by word. -considerAccessible :: Bool -considerAccessible = True ===================================== libraries/ghc-internal/src/GHC/Internal/Heap/Closures.hs ===================================== @@ -75,9 +75,10 @@ import GHC.Internal.Int import GHC.Internal.Num import GHC.Internal.Real import GHC.Internal.Word -import GHC.Internal.Exts import GHC.Internal.Generics import GHC.Internal.Numeric +import GHC.Internal.Ptr +import GHC.Internal.Unsafe.Coerce import GHC.Internal.Stack (HasCallStack) ------------------------------------------------------------------------ ===================================== libraries/ghc-internal/src/GHC/Internal/JS/Foreign/Callback.hs ===================================== @@ -21,8 +21,6 @@ module GHC.Internal.JS.Foreign.Callback import GHC.Internal.JS.Prim -import qualified GHC.Internal.Exts as Exts - import GHC.Internal.Unsafe.Coerce import GHC.Internal.Base @@ -131,18 +129,18 @@ asyncCallback3 x = js_asyncCallbackApply 3 (unsafeCoerce x) -- ---------------------------------------------------------------------------- foreign import javascript unsafe "(($1, $2) => { return h$makeCallback(h$runSync, [$1], $2); })" - js_syncCallback :: Bool -> Exts.Any -> IO (Callback (IO b)) + js_syncCallback :: Bool -> Any -> IO (Callback (IO b)) foreign import javascript unsafe "(($1) => { return h$makeCallback(h$run, [], $1); })" - js_asyncCallback :: Exts.Any -> IO (Callback (IO b)) + js_asyncCallback :: Any -> IO (Callback (IO b)) foreign import javascript unsafe "(($1) => { return h$makeCallback(h$runSyncReturn, [false], $1); })" - js_syncCallbackReturn :: Exts.Any -> IO (Callback (IO JSVal)) + js_syncCallbackReturn :: Any -> IO (Callback (IO JSVal)) foreign import javascript unsafe "(($1, $2, $3) => { return h$makeCallbackApply($2, h$runSync, [$1], $3); })" - js_syncCallbackApply :: Bool -> Int -> Exts.Any -> IO (Callback b) + js_syncCallbackApply :: Bool -> Int -> Any -> IO (Callback b) foreign import javascript unsafe "(($1, $2) => { return h$makeCallbackApply($1, h$run, [], $2); })" - js_asyncCallbackApply :: Int -> Exts.Any -> IO (Callback b) + js_asyncCallbackApply :: Int -> Any -> IO (Callback b) foreign import javascript unsafe "(($1, $2) => { return h$makeCallbackApply($1, h$runSyncReturn, [false], $2); })" - js_syncCallbackApplyReturn :: Int -> Exts.Any -> IO (Callback b) + js_syncCallbackApplyReturn :: Int -> Any -> IO (Callback b) foreign import javascript unsafe "h$release" 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# import GHC.Internal.Unsafe.Coerce (unsafeCoerce) import GHC.Internal.Prim +import GHC.Internal.Types import qualified GHC.Internal.Exception as Ex -import qualified GHC.Internal.Exts as Exts import qualified GHC.Internal.CString as GHC import GHC.Internal.IO import GHC.Internal.Data.Bool @@ -78,15 +78,15 @@ instance Show JSException where #if defined(javascript_HOST_ARCH) {-# NOINLINE toIO #-} -toIO :: Exts.Any -> IO Exts.Any +toIO :: Any -> IO Any toIO x = pure x {-# NOINLINE resolve #-} -resolve :: JSVal# -> JSVal# -> Exts.Any -> IO () +resolve :: JSVal# -> JSVal# -> Any -> IO () resolve accept reject x = resolveIO accept reject (pure x) {-# NOINLINE resolveIO #-} -- used by the rts -resolveIO :: JSVal# -> JSVal# -> IO Exts.Any -> IO () +resolveIO :: JSVal# -> JSVal# -> IO Any -> IO () resolveIO accept reject x = (x >>= evaluate >>= js_callback_any accept) `catch` (\(e::Ex.SomeException) -> do @@ -260,16 +260,16 @@ seqList xs = go xs `seq` xs go [] = () foreign import javascript unsafe "h$toHsString" - js_fromJSString :: JSVal -> Exts.Any + js_fromJSString :: JSVal -> Any foreign import javascript unsafe "h$fromHsString" - js_toJSString :: Exts.Any -> JSVal + js_toJSString :: Any -> JSVal foreign import javascript unsafe "h$toHsListJSVal" - js_fromJSArray :: JSVal -> IO Exts.Any + js_fromJSArray :: JSVal -> IO Any foreign import javascript unsafe "h$fromHsListJSVal" - js_toJSArray :: Exts.Any -> IO JSVal + js_toJSArray :: Any -> IO JSVal foreign import javascript unsafe "(($1) => { return ($1 === null); })" js_isNull :: JSVal -> Bool @@ -287,10 +287,10 @@ foreign import javascript unsafe "(() => { return null; })" js_null :: JSVal foreign import javascript unsafe "(($1,$2) => { return $1[h$fromHsString($2)]; })" - js_getProp :: JSVal -> Exts.Any -> IO JSVal + js_getProp :: JSVal -> Any -> IO JSVal foreign import javascript unsafe "(($1,$2) => { return $1[h$fromHsString($2)]; })" - js_unsafeGetProp :: JSVal -> Exts.Any -> JSVal + js_unsafeGetProp :: JSVal -> Any -> JSVal foreign import javascript unsafe "(($1,$2) => { return $1[$2]; })" js_getProp' :: JSVal -> JSVal -> IO JSVal @@ -311,7 +311,7 @@ foreign import javascript unsafe "(($1_1, $1_2) => { return h$decodeUtf8z($1_1,$ js_unsafeUnpackJSStringUtf8## :: Addr# -> JSVal# foreign import javascript unsafe "(($1, $2) => { return $1($2); })" - js_callback_any :: JSVal# -> Exts.Any -> IO () + js_callback_any :: JSVal# -> Any -> IO () foreign import javascript unsafe "(($1, $2) => { return $1($2); })" 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 ) where import GHC.Internal.JS.Prim -import GHC.Internal.Exts import GHC.Internal.IO import GHC.Internal.Unsafe.Coerce import GHC.Internal.Base ===================================== libraries/ghc-internal/src/GHC/Internal/Magic.hs ===================================== @@ -24,7 +24,7 @@ -- ----------------------------------------------------------------------------- -module GHC.Internal.Magic ( inline, noinline, lazy, oneShot, runRW#, DataToTag(..) ) where +module GHC.Internal.Magic ( inline, noinline, lazy, oneShot, runRW#, DataToTag(..), considerAccessible ) where -------------------------------------------------- -- See Note [magicIds] in GHC.Types.Id.Make @@ -34,7 +34,7 @@ module GHC.Internal.Magic ( inline, noinline, lazy, oneShot, runRW#, DataToTag(. -- because TYPE is not exported by the source Haskell module generated by -- genprimops which Haddock will typecheck (#15935). import GHC.Internal.Prim (State#, realWorld#, RealWorld, Int#) -import GHC.Internal.Types (RuntimeRep(BoxedRep), TYPE, Levity, Constraint) +import GHC.Internal.Types (RuntimeRep(BoxedRep), TYPE, Levity, Constraint, Bool(True)) -- | The call @inline f@ arranges that @f@ is inlined, regardless of -- its size. More precisely, the call @inline f@ rewrites to the @@ -137,3 +137,27 @@ type DataToTag :: forall {lev :: Levity}. TYPE (BoxedRep lev) -> Constraint -- So it does not get its own Unsafe module, unlike WithDict. class DataToTag a where dataToTag# :: a -> Int# + +-- | Semantically, @considerAccessible = True@. But it has special meaning +-- to the pattern-match checker, which will never flag the clause in which +-- 'considerAccessible' occurs as a guard as redundant or inaccessible. +-- Example: +-- +-- > case (x, x) of +-- > (True, True) -> 1 +-- > (False, False) -> 2 +-- > (True, False) -> 3 -- Warning: redundant +-- +-- The pattern-match checker will warn here that the third clause is redundant. +-- It will stop doing so if the clause is adorned with 'considerAccessible': +-- +-- > case (x, x) of +-- > (True, True) -> 1 +-- > (False, False) -> 2 +-- > (True, False) | considerAccessible -> 3 -- No warning +-- +-- Put 'considerAccessible' as the last statement of the guard to avoid get +-- confusing results from the pattern-match checker, which takes \"consider +-- accessible\" by word. +considerAccessible :: Bool +considerAccessible = True ===================================== libraries/ghc-internal/src/GHC/Internal/Stack/Decode.hs ===================================== @@ -40,8 +40,8 @@ import GHC.Internal.Data.List import GHC.Internal.Data.Tuple import GHC.Internal.Foreign.Ptr import GHC.Internal.Foreign.Storable -import GHC.Internal.Exts import GHC.Internal.Unsafe.Coerce +import GHC.Internal.Ptr import GHC.Internal.ClosureTypes import GHC.Internal.Heap.Closures ===================================== libraries/ghc-internal/src/GHC/Internal/Tuple.hs ===================================== @@ -27,10 +27,11 @@ module GHC.Internal.Tuple ( Tuple40(..), Tuple41(..), Tuple42(..), Tuple43(..), Tuple44(..), Tuple45(..), Tuple46(..), Tuple47(..), Tuple48(..), Tuple49(..), Tuple50(..), Tuple51(..), Tuple52(..), Tuple53(..), Tuple54(..), Tuple55(..), Tuple56(..), Tuple57(..), Tuple58(..), Tuple59(..), Tuple60(..), Tuple61(..), Tuple62(..), Tuple63(..), Tuple64(..), + maxTupleSize, ) where -- See W1 of Note [Tracking dependencies on primitives] in GHC.Internal.Base -import GHC.Internal.Types () +import GHC.Internal.Types (Int) default () -- Double and Integer aren't available yet @@ -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 r1 s1 t1 u1 v1 w1 x1 y1 z1 a2 b2 c2 d2 e2 f2 g2 h2 i2 j2 k2 l2 = (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, r1,s1,t1,u1,v1,w1,x1,y1,z1,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2) + +maxTupleSize :: Int +maxTupleSize = 64 ===================================== libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Exports.hs ===================================== @@ -32,7 +32,6 @@ module GHC.Internal.Wasm.Prim.Exports ( import GHC.Internal.Base import GHC.Internal.Exception.Type -import GHC.Internal.Exts import GHC.Internal.IO import GHC.Internal.IORef import GHC.Internal.Int @@ -40,6 +39,8 @@ import GHC.Internal.Stable import GHC.Internal.TopHandler (flushStdHandles) import GHC.Internal.Wasm.Prim.Types import GHC.Internal.Word +import GHC.Internal.Unsafe.Coerce ( unsafeCoerce# ) +import GHC.Internal.Ptr mkJSCallback :: (StablePtr a -> IO JSVal) -> a -> IO JSVal mkJSCallback adjustor f = do ===================================== libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Imports.hs ===================================== @@ -30,10 +30,10 @@ module GHC.Internal.Wasm.Prim.Imports ( import GHC.Internal.Base import GHC.Internal.Exception -import GHC.Internal.Exts import GHC.Internal.IO.Unsafe import GHC.Internal.Stable import GHC.Internal.Wasm.Prim.Types +import GHC.Internal.Unsafe.Coerce ( unsafeCoerce# ) {-# OPAQUE raiseJSException #-} raiseJSException :: JSVal -> a ===================================== libraries/ghc-internal/src/GHC/Internal/Wasm/Prim/Types.hs ===================================== @@ -20,9 +20,9 @@ module GHC.Internal.Wasm.Prim.Types ( import GHC.Internal.Base import GHC.Internal.Exception.Type -import GHC.Internal.Exts import GHC.Internal.Foreign.C.String.Encoding import GHC.Internal.ForeignPtr +import GHC.Internal.Ptr import GHC.Internal.IO import GHC.Internal.IO.Encoding import GHC.Internal.Num ===================================== testsuite/tests/interface-stability/ghc-experimental-exports.stdout ===================================== @@ -4453,6 +4453,7 @@ module Data.Tuple.Experimental where type Unit# :: GHC.Internal.Types.ZeroBitType data Unit# = ... getSolo :: forall a. Solo a -> a + maxTupleSize :: GHC.Internal.Types.Int module GHC.Exception.Backtrace.Experimental where -- Safety: None @@ -11044,6 +11045,7 @@ module Prelude.Experimental where type Unit# :: GHC.Internal.Types.ZeroBitType data Unit# = ... getSolo :: forall a. Solo a -> a + maxTupleSize :: GHC.Internal.Types.Int module System.Mem.Experimental where -- Safety: None ===================================== testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32 ===================================== @@ -4453,6 +4453,7 @@ module Data.Tuple.Experimental where type Unit# :: GHC.Internal.Types.ZeroBitType data Unit# = ... getSolo :: forall a. Solo a -> a + maxTupleSize :: GHC.Internal.Types.Int module GHC.Exception.Backtrace.Experimental where -- Safety: None @@ -11047,6 +11048,7 @@ module Prelude.Experimental where type Unit# :: GHC.Internal.Types.ZeroBitType data Unit# = ... getSolo :: forall a. Solo a -> a + maxTupleSize :: GHC.Internal.Types.Int module System.Mem.Experimental where -- Safety: None ===================================== testsuite/tests/interface-stability/ghc-prim-exports.stdout ===================================== @@ -1232,6 +1232,7 @@ module GHC.Magic where class DataToTag a where dataToTag# :: a -> GHC.Internal.Prim.Int# {-# MINIMAL dataToTag# #-} + considerAccessible :: GHC.Internal.Types.Bool inline :: forall a. a -> a lazy :: forall a. a -> a noinline :: forall a. a -> a @@ -3891,6 +3892,7 @@ module GHC.Tuple where type Unit :: * data Unit = () getSolo :: forall a. Solo a -> a + maxTupleSize :: GHC.Internal.Types.Int module GHC.Types where -- Safety: None ===================================== testsuite/tests/interface-stability/ghc-prim-exports.stdout-mingw32 ===================================== @@ -1232,6 +1232,7 @@ module GHC.Magic where class DataToTag a where dataToTag# :: a -> GHC.Internal.Prim.Int# {-# MINIMAL dataToTag# #-} + considerAccessible :: GHC.Internal.Types.Bool inline :: forall a. a -> a lazy :: forall a. a -> a noinline :: forall a. a -> a @@ -3894,6 +3895,7 @@ module GHC.Tuple where type Unit :: * data Unit = () getSolo :: forall a. Solo a -> a + maxTupleSize :: GHC.Internal.Types.Int module GHC.Types where -- Safety: None View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7922f728e3c5c43fcb641523513ba4fb... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7922f728e3c5c43fcb641523513ba4fb... You're receiving this email because of your account on gitlab.haskell.org.