hashes4merkle
hashes4merkle

Reputation: 404

haskell---Command Line Argument File Passing

I am fairly new to Haskell and am currently working on a summer assignment. I am attempting to pass a test file into my .hs as an argument from the command line in ghci. Could someone detail how this should occur? Below I have the beginning chunk of code from my .hs that uses getArgs and readFile to read the file and create a tuple from the data.

    import Prelude
    import System.Environment ( getArgs )
    import Data.List
    import Helpers

    -- The main method that will be used for testing / command line access
    main = do
    args <- getArgs
    filename <- readFile (head args)
    checkersState <- readonemoveFile filename

When I :load this .hs, do I add the file as an argument following it? Such as:

    :load csce322a03p01.hs test01.onemove

I assume not as this gives me an error:

    target `test01.onemove' is not a module name or a source file

Upvotes: 7

Views: 1459

Answers (1)

Sibi
Sibi

Reputation: 48766

Just load the module file initially:

ghci> :l fileName.hs

And then pass the argument like this:

ghci> :main arg1 arg2

Upvotes: 13

Related Questions