haskell ---命令行参数文件传递

时间:2014-08-08 16:56:26

标签: haskell ghci

我对Haskell相当新,目前正在参加暑期工作。我试图从ghci的命令行将测试文件作为参数传递给我的.hs。有人可以详细说明这应该如何发生?下面我有一些来自我的.hs的代码,它使用getArgs和readFile来读取文件并从数据中创建一个元组。

    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

当我:加载此.hs时,我是否将该文件作为参数添加?如:

    :load csce322a03p01.hs test01.onemove

我认为不是因为这给了我一个错误:

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

1 个答案:

答案 0 :(得分:13)

最初只需加载模块文件:

ghci> :l fileName.hs

然后传递这样的论点:

ghci> :main arg1 arg2
相关问题