本文介绍了GHC包冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用GHC编译以下代码:

I'm trying to compile the following code with GHC:

module Test where

import Maybe
import Prelude hiding (null)
import System.IO

null = ()

main :: IO ()
main = putStrLn "Hello, world!"



如果我只是运行 ghc Test.hs ,我得到:

Could not find module `Maybe'
It is a member of the hidden package `haskell98-2.0.0.1'.

所以我试试 ghc -package haskell98 Test.hs

Ambiguous module name `Prelude':
  it was found in multiple packages: base haskell98-2.0.0.1

这似乎不对,但我尝试 ghc -package haskell98 -hide-package base Test.hs

It doesn't seem right, but I try ghc -package haskell98 -hide-package base Test.hs:

Could not find module `System.IO'
It is a member of the hidden package `base'.
It is a member of the hidden package `haskell2010-1.1.0.1'.

那么我试试 ghc -package haskell98 -hide-package base -package haskell2010 Test.hs

Ambiguous module name `Prelude':
  it was found in multiple packages:
  haskell2010-1.1.0.1 haskell98-2.0.0.1

如何编译这段代码?我正在使用GHC 7.4.1。

How do I compile this code? I'm using GHC 7.4.1.

推荐答案

导入 Data.Maybe haskell98 包不再与 base 兼容,因此使用 haskell98 模块带来了不必要的痛苦。

Import Data.Maybe. The haskell98 package is no longer compatible with base, so using the haskell98 modules brings just unnecessary pain.

这篇关于GHC包冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 03:55