Rodrigo Mesquita pushed to branch wip/spj-reinstallable-base2 at Glasgow Haskell Compiler / GHC Commits: 496c99bb by Rodrigo Mesquita at 2026-05-26T13:52:33+01:00 Add composition library as test for 27013 - - - - - 48c0a754 by Rodrigo Mesquita at 2026-05-28T13:52:40+01:00 Add recompilation avoidance fails test for GHC.Essentials package changed - - - - - 10 changed files: - compiler/GHC/Driver/Pipeline/Execute.hs - + testsuite/tests/cabal/T27013a/Makefile - + testsuite/tests/cabal/T27013a/Setup.hs - + testsuite/tests/cabal/T27013a/all.T - + testsuite/tests/cabal/T27013a/composition.cabal - + testsuite/tests/cabal/T27013a/src/Data/Composition.hs - + testsuite/tests/driver/T27013b/Makefile - + testsuite/tests/driver/T27013b/T27013b.stdout - + testsuite/tests/driver/T27013b/X.hs - + testsuite/tests/driver/T27013b/all.T Changes: ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -670,7 +670,6 @@ runHscPhase pipe_env hsc_env0 input_fn src_flavour = do -- gather the imports and module name (hspp_buf,mod_name,imps,src_imps) <- do buf <- hGetStringBuffer input_fn - -- TODO: handle implicit knownkey names here? let rn_pkg_qual = renameRawPkgQual (hsc_unit_env hsc_env) rn_imps = fmap (\(s, rpk, lmn@(L _ mn)) -> (s, rn_pkg_qual mn rpk, lmn)) sec = initSourceErrorContext dflags ===================================== testsuite/tests/cabal/T27013a/Makefile ===================================== @@ -0,0 +1,22 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP=./Setup -v0 + +# Reproducer for #27013 (!15899#note_676801). +# +# The `composition` package depends on neither `base` nor `ghc-internal` +# (see composition.cabal: no build-depends). It uses NoImplicitPrelude +# and defines its own `(.)`. Building it should not require GHC to load +# known-key modules from `base` such as `GHC.Essentials`. + +T27013a: clean + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup + $(SETUP) clean + $(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --with-hc-pkg='$(GHC_PKG)' --ghc-options='$(TEST_HC_OPTS)' --package-db=tmp.d + $(SETUP) build + +clean : + $(RM) -r tmp.d dist Setup$(exeext) *.o *.hi ===================================== testsuite/tests/cabal/T27013a/Setup.hs ===================================== @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain ===================================== testsuite/tests/cabal/T27013a/all.T ===================================== @@ -0,0 +1,4 @@ +test('T27013a', + [extra_files(['src/', 'composition.cabal', 'Setup.hs'])], + makefile_test, + []) ===================================== testsuite/tests/cabal/T27013a/composition.cabal ===================================== @@ -0,0 +1,24 @@ +name: composition +version: 1.0.2.2 +synopsis: Combinators for unorthodox function composition + +license: BSD3 +license-file: LICENSE +author: Dan Burton +maintainer: danburton.email@gmail.com +bug-reports: + https://github.com/DanBurton/composition/issues + +category: Data +build-type: Simple +cabal-version: >=1.10 + +library + default-language: Haskell2010 + hs-source-dirs: src + exposed-modules: Data.Composition + default-extensions: NoImplicitPrelude + +source-repository head + type: git + location: git://github.com/DanBurton/composition.git ===================================== testsuite/tests/cabal/T27013a/src/Data/Composition.hs ===================================== @@ -0,0 +1,149 @@ +-- | 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/driver/T27013b/Makefile ===================================== @@ -0,0 +1,14 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +# Test that compiling X.hs without implicit Prelude does not recompile X the +# second time or third time. In !15899, X.hs was recompiled because of an +# incorrect "GHC.Essentials package changed" +clean: + rm -f *.o *.hi + +T27013b: clean + '$(TEST_HC)' $(TEST_HC_OPTS) --make X.hs + '$(TEST_HC)' $(TEST_HC_OPTS) --make X.hs + '$(TEST_HC)' $(TEST_HC_OPTS) --make X.hs ===================================== testsuite/tests/driver/T27013b/T27013b.stdout ===================================== @@ -0,0 +1 @@ +[1 of 1] Compiling X ( X.hs, X.o ) ===================================== testsuite/tests/driver/T27013b/X.hs ===================================== @@ -0,0 +1,3 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module X where +x = 3 ===================================== testsuite/tests/driver/T27013b/all.T ===================================== @@ -0,0 +1,2 @@ +test('T27013b', [extra_files(['X.hs'])], + makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/989b38cbe9dbf29b8673f3d4b27005d... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/989b38cbe9dbf29b8673f3d4b27005d... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Rodrigo Mesquita (@alt-romes)