
Hi, Is it possible not to load Prelude module when compiling a Haskell module? Or instruct ghc to “unload” it? Thanks, Maurício

On Jan 10, 2008, at 14:22 , Maurí cio wrote:
Is it possible not to load Prelude module when compiling a Haskell module? Or instruct ghc to “unload” it?
-fno-implicit-prelude -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Sorry for the double message, Mauricio. It's the first time I ever
posted to haskell-cafe - figures I'd click on "reply" and not "reply
to all"...
On Jan 10, 2008 9:22 PM, Maurício
Hi,
Is it possible not to load Prelude module when compiling a Haskell module? Or instruct ghc to "unload" it?
Thanks, Maurício
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-XNoImplicitPrelude.does this in 6.8.x. In earlier versions (and apparently in 6.8 too), it's -fno-implicit-prelude.

Use:
import Prelude ()
On Jan 10, 2008 11:22 AM, Maurício
Hi,
Is it possible not to load Prelude module when compiling a Haskell module? Or instruct ghc to "unload" it?
Thanks, Maurício
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

At Thu, 10 Jan 2008 17:22:02 -0200, Maurício wrote:
Hi,
Is it possible not to load Prelude module when compiling a Haskell module? Or instruct ghc to “unload” it?
You can either do: import Prelude() or compile with the -fno-implicit-prelude flag, or add {-# LANGUAGE NoImplicitPrelude #-} to the top of the module. NoImplicitPrelude is more aggressive than 'import Prelude()'. You will have to look elsewhere for a better explanation of the difference. j.

Hi,
Is it possible not to load Prelude (...)
(...) NoImplicitPrelude is more aggressive than 'import Prelude()'. You will have to look elsewhere for a better explanation of the difference.
I tried google and ghc homepage, but could not find “elsewhere” :) Can you give me a link or somewhere to start from? Thanks, Maurício

On Jan 10, 2008, at 19:16 , Maurí cio wrote:
Hi,
Is it possible not to load Prelude (...)
(...) NoImplicitPrelude is more aggressive than 'import Prelude()'. You will have to look elsewhere for a better explanation of the difference.
I tried google and ghc homepage, but could not find “elsewhere” :) Can you give me a link or somewhere to start from?
You'll find it in a careful reading of the Haskell98 Report: certain syntactical constructs are rewritten into calls to Prelude functions. Most notably: a bare untyped integral number is rewritten as (fromIntegral num) (so its type will be (Num a => a)), and [n..m] list generation syntax is rewritten into calls to enumFrom ([n..]), enumFromTo ([n..m]), enumFromThen ([n,o..]), enumFromThenTo ([n,o..m]). (There are some such for which even -fno-implicit-prelude isn't enough; I think these are documented in the "bugs" section of the GHC manual.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Maurício wrote:
Is it possible not to load Prelude (...)
(...) NoImplicitPrelude is more aggressive than 'import Prelude()'. You will have to look elsewhere for a better explanation of the difference.
I tried google and ghc homepage, but could not find “elsewhere” :) Can you give me a link or somewhere to start from?
I often find it easier, rather than doing a full Google search, to start with a "Search haskell.org" on the front page here http://haskell.org/ This is a Google site search of *.haskell.org/* But ignore the type-in search box and button at the top of the front page - they don't work properly. Richard.

At Thu, 10 Jan 2008 22:16:27 -0200, Maurício wrote:
I tried google and ghc homepage, but could not find “elsewhere” :) Can you give me a link or somewhere to start from?
No. What I meant to say was, I'm not really sure myself, I just know there is a difference and -fno-implicit-prelude is more aggressive. If you do find a clear explaination, I would love to see it. j.

On Jan 11, 2008 8:13 PM, Jeremy Shaw
At Thu, 10 Jan 2008 22:16:27 -0200, Maurício wrote:
I tried google and ghc homepage, but could not find "elsewhere" :) Can you give me a link or somewhere to start from?
No. What I meant to say was, I'm not really sure myself, I just know there is a difference and -fno-implicit-prelude is more aggressive. I you do find a clear explaination, I would love to see it.
So, when you write the number 3 in Haskell, GHC converts this to essentially (Prelude.fromInteger (3::Integer)) in its internal format. So it doesn't matter if you import Prelude (), Prelude's version of fromInteger still gets called. If you give -fno-implicit-prelude, then this is converted to simply (fromInteger (3::Integer)), without the hard-coded prelude reference. That means you could write your own version of fromInteger that does something different. A common usage for -fno-implicit-prelude (insofar as it is used at all, which is seldom) is to replace the standard Num hierarchy with a saner one, with numeric literals resolving to that one instead. There are a few other hard-coded references to Prelude in the internal format, but I don't remember what they are offhand. -fno-implicit-prelude gets rid of those, too. Luke

On Fri, 11 Jan 2008, Luke Palmer wrote:
So, when you write the number 3 in Haskell, GHC converts this to essentially (Prelude.fromInteger (3::Integer)) in its internal format. So it doesn't matter if you import Prelude (), Prelude's version of fromInteger still gets called. If you give -fno-implicit-prelude, then this is converted to simply (fromInteger (3::Integer)), without the hard-coded prelude reference. That means you could write your own version of fromInteger that does something different. A common usage for -fno-implicit-prelude (insofar as it is used at all, which is seldom) is to replace the standard Num hierarchy with a saner one, with numeric literals resolving to that one instead.
There are a few other hard-coded references to Prelude in the internal format, but I don't remember what they are offhand. -fno-implicit-prelude gets rid of those, too.
For details, see: http://www.haskell.org/ghc/docs/latest/html/users_guide/ghc-language-feature... I have summarized the answers so far: http://www.haskell.org/haskellwiki/No_import_of_Prelude

On Thu, 10 Jan 2008, [windows-1252] Maurício wrote:
Hi,
Is it possible not to load Prelude module when compiling a Haskell module? Or instruct ghc to “unload” it?
You can either import Prelude () but some things like 'fromInteger' as used for number literals are still present. You can write the pragma {-# OPTIONS -fno-implicit-prelude #-} at the top of your module to get completely rid of the Prelude.
participants (8)
-
Ari Rahikkala
-
Brandon S. Allbery KF8NH
-
Clifford Beshers
-
Henning Thielemann
-
Jeremy Shaw
-
Luke Palmer
-
Maurício
-
Richard Kelsall