Haskell --- Passing Command Line Argument File

I am new to Haskell and am currently working on a summer assignment. I am trying to pass a test file to my .hs as an argument from the command line in ghci. Can someone describe how this should happen? Below I have the initial code snippet 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: upload this .hs, am I adding the file as an argument following it? For instance:

  :load csce322a03p01.hs test01.onemove 

I guess that is not the way it gives me the error:

  target `test01.onemove' is not a module name or a source file 
+6
source share
1 answer

First download the module file:

 ghci> :l fileName.hs 

And then pass the argument as follows:

 ghci> :main arg1 arg2 
+13
source

Source: https://habr.com/ru/post/973555/


All Articles