[Git][ghc/ghc][wip/spj-reinstallable-base2] 2 commits: T27013d tests recompilation checking of Composition.hs which uses -hide-all-packages
Rodrigo Mesquita pushed to branch wip/spj-reinstallable-base2 at Glasgow Haskell Compiler / GHC Commits: 23da209f by Rodrigo Mesquita at 2026-06-11T16:14:14+01:00 T27013d tests recompilation checking of Composition.hs which uses -hide-all-packages - - - - - a7b14581 by Rodrigo Mesquita at 2026-06-11T17:07:01+01:00 Revert "use lookupKnownKeyModule for defaulting check too" This reverts commit 5943ac8c8e7d9fc5dd5e25d118282f80ac1e0ab6. Oh no, doing this meant we would disable defaulting when rebindable known-keys was on; that's not what we want. - - - - - 5 changed files: - compiler/GHC/Tc/Utils/Env.hs - + testsuite/tests/cabal/T27013d/Composition.hs - + testsuite/tests/cabal/T27013d/Makefile - + testsuite/tests/cabal/T27013d/T27013d.stdout - + testsuite/tests/cabal/T27013d/all.T Changes: ===================================== compiler/GHC/Tc/Utils/Env.hs ===================================== @@ -83,6 +83,7 @@ import GHC.Driver.DynFlags import GHC.Builtin( isUnboundName ) import GHC.Builtin.KnownKeys import GHC.Builtin.WiredIn.Types +import GHC.Builtin.Modules ( eSSENTIALS_NAME ) import GHC.Runtime.Context @@ -115,6 +116,7 @@ import GHC.Unit.Home import GHC.Unit.Home.Graph import GHC.Unit.Home.ModInfo import GHC.Unit.External +import GHC.Unit.Finder import GHC.Utils.Outputable import GHC.Utils.Panic @@ -137,6 +139,7 @@ import GHC.Types.Id import GHC.Types.Id.Info ( RecSelParent(..) ) import GHC.Types.Name.Reader import GHC.Types.TyThing +import GHC.Types.PkgQual import GHC.Types.Unique.Set ( nonDetEltsUniqSet ) import qualified GHC.LanguageExtensions as LangExt @@ -1129,9 +1132,9 @@ tcGetDefaultTys ; user_defaults <- getDeclaredDefaultTys -- User-supplied defaults ; this_module <- tcg_mod <$> getGblEnv ; let this_unit = moduleUnit this_module - ; essentials_mod <- liftIO $ lookupKnownKeysModule hsc_env dflags - ; case essentials_mod of - Nothing -> + ; found_essentials <- liftIO $ findImportedModule hsc_env eSSENTIALS_NAME NoPkgQual + ; case found_essentials of + NotFound{} -> -- If GHC.Essentials isn't available at all (e.g. -hide-all-packages), -- don't add the built-in defaulting, bc e.g. Num is a known-entity. return (user_defaults, extended_defaults) ===================================== testsuite/tests/cabal/T27013d/Composition.hs ===================================== @@ -0,0 +1,150 @@ +-- | This module is for convenience and demonstrative purposes +-- more than it is for providing actual value. +-- I do not recommend that you rely on this module +-- for performance-sensitive code. +-- Because this module is not based on Prelude's (.), +-- some chances at optimization might be missed by your compiler. +module Data.Composition ( + -- * Math + (∘) + + -- * Colons and dots + , (.:) + , (.:.) + , (.::) + , (.::.) + , (.:::) + , (.:::.) + , (.::::) + , (.::::.) + + -- * Asterisks + , (.*) + , (.**) + , (.***) + , (.****) + , (.*****) + , (.******) + , (.*******) + , (.********) + + -- * composeN + , compose1 + , compose2 + , compose3 + , compose4 + , compose5 + , compose6 + , compose7 + , compose8 + , compose9 + + ) where + +-- Not exported. This is defined here to remove the dependency on base +(.) :: (b -> c) -> (a -> b) -> a -> c +(f . g) x = f (g x) + +infixr 9 . + +-- | The mathematical symbol for function composition. +(∘) :: (b -> c) -> (a -> b) -> a -> c +(∘) = (.) + +infixr 9 ∘ + +-- | Compose two functions. @f .: g@ is similar to @f . g@ +-- except that @g@ will be fed /two/ arguments instead of one +-- before handing its result to @f@. +-- +-- This function is defined as +-- +-- > (f .: g) x y = f (g x y) +-- +-- Example usage: +-- +-- > concatMap :: (a -> [b]) -> [a] -> [b] +-- > concatMap = concat .: map +-- +-- Notice how /two/ arguments +-- (the function /and/ the list) +-- will be given to @map@ before the result +-- is passed to @concat@. This is equivalent to: +-- +-- > concatMap f xs = concat (map f xs) +(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d +(f .: g) x y = f (g x y) + +infixr 8 .: + +-- | Equivalent to '.:' +-- +-- The pattern of appending asterisks is +-- straightforward to extend to similar functions: +-- (compose2 = .*, compose3 = .**, etc). +-- However, @.:@ has been commonly adopted amongst Haskellers, +-- and the need for compose3 and beyond is rare in practice. +(.*) :: (c -> d) -> (a -> b -> c) -> a -> b -> d +(.*) = (.) . (.) + +infixr 8 .* + +(.**) :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e +(.**) = (.) . (.*) + +(.***) = (.) . (.**) +(.****) = (.) . (.***) +(.*****) = (.) . (.****) +(.******) = (.) . (.*****) +(.*******) = (.) . (.******) +(.********) = (.) . (.*******) + +infixr 8 .** +infixr 8 .*** +infixr 8 .**** +infixr 8 .***** +infixr 8 .****** +infixr 8 .******* +infixr 8 .******** + + +-- | @composeN f g@ means give @g@ @N@ inputs +-- and then pass its result to @f@. +compose1 :: (b -> c) -> (a -> b) -> a -> c +compose1 = (.) + +compose2 :: (c -> d) -> (a -> b -> c) -> a -> b -> d +compose2 = (.*) + +compose3 :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e +compose3 = (.**) + +compose4 = (.***) +compose5 = (.****) +compose6 = (.*****) +compose7 = (.******) +compose8 = (.*******) +compose9 = (.********) + +-- | One compact pattern for composition operators is to +-- "count the dots after the first one", +-- which begins with the common '.:', and proceeds by first +-- appending another @.@ and then replacing it with @:@ +(.:.) :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e +(.:.) = (.**) + +(.::) = (.***) +(.::.) = (.****) +(.:::) = (.*****) +(.:::.) = (.******) +(.::::) = (.*******) +(.::::.) = (.********) + +infixr 8 .:. +infixr 8 .:: +infixr 8 .::. +infixr 8 .::: +infixr 8 .:::. +infixr 8 .:::: +infixr 8 .::::. + ===================================== testsuite/tests/cabal/T27013d/Makefile ===================================== @@ -0,0 +1,16 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +# Test that compiling Data.Composition without implicit Prelude does not +# recompile the second or third time. The `composition` package's +# Data.Composition uses NoImplicitPrelude and depends on neither base nor +# ghc-internal. In !15899, it was recompiled because of an incorrect +# "GHC.Essentials package changed". +clean: + rm -f *.o *.hi + +T27013d: clean + '$(TEST_HC)' $(TEST_HC_OPTS) Composition.hs -XNoImplicitPrelude -hide-all-packages + '$(TEST_HC)' $(TEST_HC_OPTS) Composition.hs -XNoImplicitPrelude -hide-all-packages + '$(TEST_HC)' $(TEST_HC_OPTS) Composition.hs -XNoImplicitPrelude -hide-all-packages ===================================== testsuite/tests/cabal/T27013d/T27013d.stdout ===================================== @@ -0,0 +1 @@ +[1 of 1] Compiling Data.Composition ( Composition.hs, Composition.o ) ===================================== testsuite/tests/cabal/T27013d/all.T ===================================== @@ -0,0 +1,2 @@ +test('T27013d', [extra_files(['Composition.hs'])], + makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5943ac8c8e7d9fc5dd5e25d118282f8... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5943ac8c8e7d9fc5dd5e25d118282f8... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Rodrigo Mesquita (@alt-romes)