开发者

A ghci session without Prelude

开发者 https://www.devze.com 2023-04-12 14:04 出处:网络
This question arose on #haskell irc chat: How can I start ghci without importing prelude? The possible answer seemed obvious:

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 with import 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
> 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号