I'm learning my first functional programming language but having some trouble with the initial logistics (the professor basically said, "get it set up somehow" and didn't provide much detail.)
Anyway, I have Mac OS X version 10.6.8. To start out, I installed GHC in my home directory and found that I could open it with the command "ghci" in terminal. From there (excuse my utter lack of knowledge), I followed the vague instructions in the syllabus and opened another window with the a1.hs file I am to modify for an assignment. When I was done defining a function, I typed the command "ghc a1-skeleton.hs" to open the interpreter with that loaded into it (that's what I would be doing, right?) but got this error:
a1.hs:5:8:
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.
I'm guessing this is like missing an "#include" or something similar in a language like C++. Do I just need to find/add something to a particular directory?
Also, since I didn't catch on right away with this stuff, what exactly does the interpreter do? Is it a program that skips 'compiling' in the procedural language sense and just tries to follow the commands in a .hs file straight away?
Thanks!
UPDATE:: The code that seems to be the issue:
2 module Main where
3
4 import Test.HUnit
5 import System
The problem is probably that the System
module is the old, non-hierarchical name. I think you now need to use modules called something like System.Environment
(depending on the exact function you want to import).
Since you haven't used any functions from those modules, I can't tell you exactly what to import. In GHCi, you can view which functions a module defines like this:
Prelude> :browse System.Environment
getArgs :: IO [String]
getEnv :: String -> IO String
getEnvironment :: IO [(String, String)]
getProgName :: IO String
withArgs :: [String] -> IO a -> IO a
withProgName :: String -> IO a -> IO a
You could try getting rid of the import System
statement and loading the file. You should then get some identifiers that are not in scope. Now you can input these into Hoogle (which will be your best friend, coincidentally) to see where they are defined.
My understanding is that the functions from the old System
module are now in System.Environment
, System.Process
and System.Exit
. If you don't want to think too deeply about it, you could just import all three :P.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With