GHC Package Conflicts

I am 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!" 

If I just ran ghc Test.hs , I get:

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

So I'm trying ghc -package haskell98 Test.hs :

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

Doesn't seem like it, 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'. 

So, I will try 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 

How to compile this code? I am using GHC 7.4.1.

+7
source share
2 answers

Import Data.Maybe . haskell98 no longer compatible with base , so using haskell98 only brings unnecessary pain.

+13
source

The idea is that you use exactly one of haskell98 , base or haskell2010 . haskell* packages are a set of libraries that conform to the appropriate locale, so if you use one of them, you have a better chance of being compatible with compilers other than GHC. However, the vast majority of packages on Hackage use base anyway, so you should probably stick with that.

Haskell98, strictly speaking, precedes hierarchical modules, so they are all called Maybe and List and IO , etc. (Actually, I think these are better names than what they are now, but this is another story). Your problem is that you tried to use the old Maybe and the new System.IO at the same time, and neither the old nor the new package provide both.

+12
source

All Articles