[GHC] #15988: Remove Text.Printf and System.Console.GetOpt from base

#15988: Remove Text.Printf and System.Console.GetOpt from base -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: (none) Type: task | Status: new Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This was touched on in brief in a recent mailing list thread found at https://mail.haskell.org/pipermail/libraries/2018-October/029012.html. I propose removing `Text.Printf` and `System.Console.GetOpt` from `base` and moving them into their own packages named `printf` and `getopt` that would be managed by the haskell github organization. These two libraries, when built against newer versions of base, would provide the modules. When built against old versions of base, they would simply reexport the modules. There would be breakage from doing this, but libraries and applications that use these APIs would only need to add a single line to `build-depends` to continue being compatible with all versions of `base`. The benefits of doing this are small. As a matter of principle, it seems unfair that these two APIs are blessed by being a part of base when the would likely struggle to compete if they were in ordinary libraries. In particular, `printf` is less idiomatic and performs worse that the functions from `Numeric` (like `showFFloat`), but its prominent position in `base` encourages users to overlook the more type-safe options available for formatting numbers. More practically, the size of base does occassionally cause problems. In https://github.com/haskell/primitive/issues/218#issuecomment-443534850, Carter writes
base getting bigger actually hurts folk, eg, base recently got big enough that dwarf data gnerated by ghc at -g1 is now sooo much that you can't do a dwarf annotated build of base on mac OS X! anymore
Moving these APIs out of `base` makes a small step toward addressing this problem. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15988 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15988: Remove Text.Printf and System.Console.GetOpt from base -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: (none) Type: task | Status: new Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by svenpanne): Replying to [ticket:15988 andrewthad]:
[...] There would be breakage from doing this, but libraries and applications that use these APIs would only need to add a single line to `build-depends` to continue being compatible with all versions of `base`. [...]
Hmmm, I don't think it's that easy: If you add the proposed `getopt` package to `build-depends` and compile with current `base`, GHC will see *two* implementations of `System.Console.GetOpt`: One from `base` and one from `getopt`. I really hope that this will result in a compilation error, silently picking one of the two implementations would be really, really bad... I think you will at least have to guard your `build-depends` with a `if impl(ghc >= X.Y)`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15988#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15988: Remove Text.Printf and System.Console.GetOpt from base -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: (none) Type: task | Status: new Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by andrewthad): Sorry, I didn't explain that part clearly. I mean using cabal-the- library's module reexport feature (1) (not GHC's module reexport feature). In the cabal file for the `getopt` library, we would have something like this: {{{ library default-language: Haskell2010 if impl(ghc < 8.8) build-depends: base >= 4.5 (or whenever the module was originally introduced) reexported-modules: System.Console.GetOpt else hs-source-dirs: src exported-modules: System.Console.GetOpt }}} So now on old GHCs, the module really is exported by both libraries, but cabal (or maybe GHC) understands that these are the same module. (1) https://ghc.haskell.org/trac/ghc/wiki/ModuleReexports -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15988#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15988: Remove Text.Printf and System.Console.GetOpt from base -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: (none) Type: task | Status: new Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by svenpanne): Ooops, I must have missed that Cabal feature somehow. :-} Then the transition is of course easy for code using `System.Console.GetOpt`: Just unconditionally depend on the upcoming `getopt` package, which is totally OK. Sorry for the confusion... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15988#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15988: Remove Text.Printf and System.Console.GetOpt from base -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: (none) Type: task | Status: new Priority: normal | Milestone: 8.6.3 Component: Compiler | Version: 8.6.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by andrewthad): No worries. It's a pretty easy Cabal feature to miss since it's seldom used. Thinking about it more, I've realized that there actually is one small wrinkle to this plan though. Let's say that the original release of `getopt` is version `1.0.0.0`. It could be compatible with `base-4.x`, where `x` is the last time `System.Console.GetOpt` had any public-facing change to the API. If a minor release ever happened that adding anything, however small, to the API (`getopt-1.0.1.0`), this next release would need to drop the whole `module-reexport` clause and all compatibility with versions of `base` less than `4.13` (or whichever `base` the transition happened in). This isn't really a problem since it's no worse than the current situation, but it's worth noting. With the module being in `base`, if a change were made to `System.Console.GetOpt` and someone wrote a library that required the change, they would similarly have to blacklist old versions of `base`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15988#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC