Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GHC 7.4 update breaks haskell98?

Tags:

haskell

ghc

I updated ghc today and my small program stopped working:

https://github.com/BrisFunctional/misere-oxo/blob/master/OXO/misere.hs

GHC is now version 7.4.1-2 and from what I managed to understand it now defaults to haskell2010 standard, instead of haskell98. (as I can see from the output of ghc-pkg list):

haskell2010-1.1.0.1
(haskell98-2.0.0.1)

So I changed my "import List" to "import Data.List" which I thought was the only problem but now I get the following:

 misere.hs:1:1: Not in scope: `System.Environment.withArgs'

where does that come from since I never even import System.Environment? Any hint? Thanks

EDIT: I updated the version on github to reflect this error. and actually using Data.List ghc compiles the file perfectly, so it's runhaskell that generates this problem..

like image 223
andrea_crotti Avatar asked Mar 04 '12 14:03

andrea_crotti


2 Answers

You need not only change List to Data.List, but also Random to System.Random and import getArgs from System.Environment (but at the moment, the code uses neither getArgs nor anything from System.Random, so for the time being, you can also remove those imports).

The old non-hierarchical modules are only accessible from the haskell98 package, which is no longer compatible with base. That means that using the haskell98 modules also requires explicitly hiding base on the command line, or not listing base in the dependencies field of the .cabal file.

I'm a bit surprised by the error message, I would expect it to say

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

but that difference may be a quirk of runhaskell.

like image 200
Daniel Fischer Avatar answered Sep 19 '22 12:09

Daniel Fischer


If your program is pure Haskell98 you can use the following GHC invokation:

ghc -package haskell98 -hide-package base

In the long term, though, it would be better if you upgraded at least to hierarchical module names. Use Hoogle to find out the name of the module. E.g., http://www.haskell.org/hoogle/?hoogle=withArgs lists System.Environment as the exporting module.

like image 36
nominolo Avatar answered Sep 20 '22 12:09

nominolo