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
Just load the module file initially:
ghci> :l fileName.hs
And then pass the argument like this:
ghci> :main arg1 arg2
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