[Haskell-cafe] Feature Proposal: GHC Flag for implicit external Prelude

Simon Peyton Jones simonpj at microsoft.com
Tue Jul 15 07:26:05 UTC 2014

That sounds reasonable to me.  I’d use –prelude-is as the flag, by analogy with –main-is; see http://www.haskell.org/ghc/docs/latest/html/users_guide/options-phases.html#options-linker


From: Haskell-Cafe [mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Andrew Gibiansky
Sent: 15 July 2014 04:23
To: Haskell Cafe
Subject: [Haskell-cafe] Feature Proposal: GHC Flag for implicit external Prelude

Hey all,

I would like to propose a very minor flag to add to GHC. I would like GHC to have a --with-prelude flag, which would specify an alternate Prelude to use instead of the default Haskell prelude.

This would have an effect similar to -XNoImplicitPrelude and an additional

import MyNewPrelude

in the source file. It might be a little different semantically, as a qualified import would disable the original implicit import, just like it does with 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: --with-prelude=... 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.

In order to specify the actula module, I propose that you just pass the module name as the --with-prelude argument. You could thus invoke GHC like this:

ghc --with-prelude=MyNewPrelude Main.hs

Then, the same rules apply for figuring out which MyNewPrelude module you are referring to as if you had written a `import MyNewPrelude` statement in the file.

I am willing to implement this for GHC if people agree that this is a useful flag (or at least agree that isn't not a bad idea).

What are your thoughts on this proposal?

-- Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140715/7380ecc3/attachment.html>

More information about the Haskell-Cafe mailing list