Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

runhaskell - how to make a script compatible with ghc 7.4 and 6?

Tags:

haskell

After I upgraded to ghc 7.4, I had to remove import System from various scripts, but that makes them incompatible with runhaskell from GHC 6.0, which is still used in many environments.

Is there a way to support both versions?

The message I get when I run a script with import System in ghc 7.4:

% ./script.hs
    Could not find module `System'
    It is a member of the hidden package `haskell98-2.0.0.1'.
    Use -v to see a list of the files searched for.
like image 513
Penz Avatar asked May 07 '12 16:05

Penz


2 Answers

The System module is a deprecated non-hierarchical Haskell 98 module; you should import the relevant hierarchical modules (such as System.Environment, System.IO, and System.Exit; see the base package for a full list) you need instead. The easiest way to accomplish this might be to simply remove the System import, and use Hoogle to find out which modules the definitions you need are in, from the compiler errors.

In older GHCs, Haskell 98 modules could be used in tandem with hierarchical modules, but this is no longer possible. Changing the imports should be relatively easy, and will bring your program up to date with the latest Haskell 2010 standard.

like image 110
ehird Avatar answered Oct 22 '22 22:10

ehird


The System module was an old Haskell-98 compatibility module, and all its functionality can be found in the System.Cmd, System.Environment and System.Exit modules, which have all been available since at least as far back as GHC 5.04, so it should be a simple matter of just fixing your import statements to use some appropriate subset of those modules instead.

like image 28
hammar Avatar answered Oct 22 '22 20:10

hammar