7

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

1 Answer 1

13

Just load the module file initially:

ghci> :l fileName.hs

And then pass the argument like this:

ghci> :main arg1 arg2
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.