没有Prelude的ghci会话

Dan*_*ton 19 haskell ghci

这个问题出现在#haskell irc chat上:

如何在不导入前奏的情况下启动ghci?

可能的答案显而易见:

ghci -XNoImplicitPrelude,或加载文件 import Prelude ()

后者似乎有效,而前者则不然.但是,import Prelude ()从Prelude导入声明的实例,对吧?有没有更好的方法来创建一个ghci会话而不加载Prelude?

Rom*_*aka 17

% 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'
Run Code Online (Sandbox Code Playgroud)

但是,我不确定实例以及ghci如何处理它们.

您是否关注某个特定情况?

  • @NikitaVolkov:是的(我发现它很奇怪),但现在`-XNoImplicitPrelude`似乎按照Dan的预期工作(至少在GHC 7.6中) (3认同)

Qwe*_*tie 4

接受的答案似乎不再有效。这在 ghci 8.0.2 中有效。

Prelude> :set -XNoImplicitPrelude
Prelude> :m -Prelude
> 
Run Code Online (Sandbox Code Playgroud)