No import of Prelude

(Difference between revisions)
 Revision as of 17:53, 11 January 2008 (edit) (from Haskell-Cafe)← Previous diff Revision as of 18:01, 11 January 2008 (edit) (undo) (difference between the methods)Next diff → Line 17: Line 17: to the top of the module, or equivalently compile with -fno-implicit-prelude option. to the top of the module, or equivalently compile with -fno-implicit-prelude option. - import Prelude() is less aggressive than NoImplicitPrelude. + import Prelude() is less aggressive than NoImplicitPrelude. - E.g. with the first method fromInteger is still imported. It is silently inserted for number literals. + E.g. with the first method some functions are imported which are silently inserted for several syntactic constructs. + A bare untyped integral number is rewritten as fromIntegral num + (so its type will be Num a => a), + and list generation syntax is rewritten as follows: + [n..] $\rightarrow$ enumFrom, + [n..m] $\rightarrow$ enumFromTo, + [n,o..] $\rightarrow$ enumFromThen, + [n,o..m] $\rightarrow$ enumFromThenTo. + + 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. + == See also == == See also ==

1 Question

Is it possible not to load Prelude module when compiling a Haskell module?

You can either do

import Prelude()

{-# LANGUAGE NoImplicitPrelude #-}

to the top of the module, or equivalently compile with -fno-implicit-prelude option.

import Prelude()
is less aggressive than NoImplicitPrelude.

E.g. with the first method some functions are imported which are silently inserted for several syntactic constructs.

A bare untyped integral number is rewritten as
fromIntegral num
(so its type will be
Num a => a
),

and list generation syntax is rewritten as follows:

[n..]
$\rightarrow$
enumFrom
,
[n..m]
$\rightarrow$
enumFromTo
,
[n,o..]
$\rightarrow$
enumFromThen
,
[n,o..m]
$\rightarrow$
enumFromThenTo
.

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.