This question arose on #haskell irc chat:
How can I start ghci without importing prelude?
The possible answer seemed obvious:
ghci -XNoImplicitPrelude
, or load a file withimport Prelude ()
The latter seems to work, while the former strangely does not. However, import Prelude ()
imports the declared instances from Prelude, right? Is there a better way of creating a ghci session without loading Prelude at all?
Prelude is a module that contains a small set of standard definitions and is included automatically into all Haskell modules.
GHCi is the interactive interface to GHC. From the command line, enter "ghci" (or "ghci -W") followed by an optional filename to load. Note: We recommend using "ghci -W", which tells GHC to output useful warning messages in more situations. These warnings help to avoid common programming errors.
Quits GHCi. You can also quit by typing control-D at the prompt. Attempts to reload the current target set (see :load ) if any of the modules in the set, or any dependent module, has changed.
Simply type a let followed by a newline: let ⏎. Then fac 0 = 1 ⏎. Then fac n = n * fac (n-1) ⏎ ⏎ and you're done!
% ghci
GHCi, version 7.0.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> :m -Prelude
> :i map
Top level: Not in scope: `map'
> :i Eq
Top level: Not in scope: data constructor `Eq'
However, I'm not sure about the instances and how ghci deals with them.
Is there a particular instance that you're concerned about?
The accepted answer doesn't seem to work anymore. This does work in ghci 8.0.2.
Prelude> :set -XNoImplicitPrelude
Prelude> :m -Prelude
>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With