No import of Prelude
Question[edit]
Is it possible to not load the Prelude when compiling a Haskell module?
Answer[edit]
You can either do
import Prelude()
or add
{-# LANGUAGE NoImplicitPrelude #-}
to the top of the module, or equivalently compile with -XNoImplicitPrelude
(or older -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..]
Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \rightarrow}
enumFrom
,
[n..m]
Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \rightarrow}
enumFromTo
,
[n,o..]
Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \rightarrow}
enumFromThen
,
[n,o..m]
Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \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[edit]
- Haskell-Cafe: Not to load Prelude