Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

haskell---Command Line Argument File Passing

Tags:

haskell

ghci

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
like image 759
hashes4merkle Avatar asked Aug 08 '14 16:08

hashes4merkle


1 Answers

Just load the module file initially:

ghci> :l fileName.hs

And then pass the argument like this:

ghci> :main arg1 arg2
like image 166
Sibi Avatar answered Sep 29 '22 08:09

Sibi