A ghci session without Prelude
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 w开发者_如何学Pythonork, 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?
% 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
>
精彩评论