[GHC] #9499: Add -prelude-is flag

#9499: Add -prelude-is flag -------------------------------------+------------------------------------- Reporter: agibiansky | Owner: agibiansky Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Keywords: flag | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Easy (less than 1 | Type of failure: hour) | None/Unknown Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- I would like GHC to have a `-prelude-is` flag, which would specify an alternate Prelude to use instead of the default Haskell prelude. The benefit this would have is that this would give alternate preludes a more first-class status. Instead of having to import an alternative prelude everywhere, you could just have a ghc-options: -prelude-is=... flag in your *.cabal file, and have a different prelude be used. This is important for my own work, as I highly prefer other preludes for my non- library development; I think this is a feature which will be very useful as Haskell develops and we try to figure out how to get rid of the warts in the current Prelude. Additional discussion here: https://groups.google.com/forum/#!topic /haskell-cafe/NCVzXZcxNmQ -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9499 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9499: Add -prelude-is flag -------------------------------------+------------------------------------- Reporter: agibiansky | Owner: agibiansky Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.9 Component: Compiler | Keywords: flag Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 Unknown/Multiple | hour) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): I'm not against this. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9499#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9499: Add -prelude-is flag -------------------------------------+------------------------------------- Reporter: agibiansky | Owner: agibiansky Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.9 Component: Compiler | Keywords: flag Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 Unknown/Multiple | hour) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: Phab:D171 | -------------------------------------+------------------------------------- Changes (by rwbarton): * differential: => Phab:D171 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9499#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9499: Add -prelude-is flag -------------------------------------+------------------------------------- Reporter: agibiansky | Owner: agibiansky Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.9 Component: Compiler | Keywords: flag Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 Unknown/Multiple | hour) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by ezyang): * differential: Phab:D171 => Comment: I'm sorry I'm late to the conversation, but I wanted to remark that with GHC HEAD, there is an alternative implementation path to this feature, which is reusing the new module renaming support. Essentially, instead of saying `-prelude-is`, you can say `-package "base hiding (Prelude)" -package "my-prelude (MyPrelude as Prelude)"`. (Well, actually, the `hiding` modifier is not supported yet, but it wouldn't be hard to add.) Obviously this set of flags is longer, so `-prelude-is` might still be a handy shortcut, but an FYI! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9499#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9499: Add -prelude-is flag -------------------------------------+------------------------------------- Reporter: agibiansky | Owner: agibiansky Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.9 Component: Compiler | Keywords: flag Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 Unknown/Multiple | hour) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: Phab:D171 | -------------------------------------+------------------------------------- Changes (by ezyang): * differential: => Phab:D171 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9499#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9499: Add -prelude-is flag -------------------------------------+------------------------------------- Reporter: agibiansky | Owner: agibiansky Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.9 Component: Compiler | Keywords: flag Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 Unknown/Multiple | hour) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: Phab:D171 | -------------------------------------+------------------------------------- Comment (by agibiansky): ezyang, if I implement this using the module renaming support, will that work if the new prelude `MyPrelude` isn't in a package? For example, if I just have two files named `A.hs` and `B.hs`, the current implementation allows you to write `ghc -prelude-is A B.hs` to use the module `A` as a prelude, even though you have no package structure at all. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9499#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9499: Add -prelude-is flag -------------------------------------+------------------------------------- Reporter: agibiansky | Owner: agibiansky Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.9 Component: Compiler | Keywords: flag Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 Unknown/Multiple | hour) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: Phab:D171 | -------------------------------------+------------------------------------- Comment (by ezyang): Not out of the box, but there is a related feature we're planning on adding which is `-alias MyPrelude Prelude`, which gives a module from any package another name. Of course, you could also just name your local file `Prelude`... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9499#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9499: Add -prelude-is flag -------------------------------------+------------------------------------- Reporter: agibiansky | Owner: agibiansky Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: flag Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: #9590 | Blocking: | Differential Revisions: Phab:D171 -------------------------------------+------------------------------------- Changes (by hvr): * related: => #9590 Comment: Tbh, I wouldn't like seeing the `ghc-options: -is-prelude foobar` approach spread, as it would be a rather adhoc GHC-specific hack IMO, and also require `if impl(ghc >= ...)` guards if older GHCs are to be supported Moreover, I don't understand why the current implicit `Prelude` approach requires "having to import an alternative prelude everywhere", and how `-is-prelude` would help here. (I'd also like to point to comment:ticket:9590:20) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9499#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9499: Add -prelude-is flag -------------------------------------+------------------------------------- Reporter: agibiansky | Owner: agibiansky Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: flag Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: #9590 | Blocking: | Differential Revisions: Phab:D171 -------------------------------------+------------------------------------- Comment (by hvr): Fwiw, here's a different way how to replace the default `Prelude` with the current tooling that would IMO reduce the need for an `-is-prelude` option: https://github.com/hvr/base-noprelude The basic idea is to have `base` sans the `Prelude` module, and then you just need to provide the `Prelude` module either locally in the Package, or by importing some other package that provides the `Prelude` module. For instance, there's the `extended-prelude` package example: https://github.com/hvr/base-noprelude/tree/master/examples/extended- prelude which can be then used simply by setting `build-depends: base-noprelude, extended-prelude` -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9499#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9499: Add -prelude-is flag -------------------------------------+------------------------------------- Reporter: agibiansky | Owner: agibiansky Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: flag Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: #9590 | Blocking: | Differential Revisions: Phab:D171 -------------------------------------+------------------------------------- Comment (by rwbarton): Agree with hvr's comments. An quick-and-dirty hack that also works (I don't entirely understand why it works, but it does) is just to add a file `Prelude.hs` to your project consisting of {{{ module Prelude (module My.Fancy.Prelude) where import My.Fancy.Prelude }}} Apparently this overrides the Prelude module from base for the scope of your project, even for the implicit Prelude import in modules that don't have an explicit one. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9499#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9499: Add -prelude-is flag -------------------------------------+------------------------------------- Reporter: agibiansky | Owner: agibiansky Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: wontfix | Keywords: flag Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9590 | Differential Rev(s): Phab:D171 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * status: new => closed * resolution: => wontfix Comment: Closing, since the Diff is abandoned, and an alternative prelude can already be specified without compiler modifications (see comment:8 and comment:9). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9499#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC