我从文件中读取有问题.每当我需要从文件中读取时,我都会这样做:
main = do x <- readFile "/tmp/foo.txt"
putStr x
Run Code Online (Sandbox Code Playgroud)
但是现在我希望这条道路成为一个论点,所以我尝试了下面的内容
main s = do x <- readFile s
putStr x
Run Code Online (Sandbox Code Playgroud)
它不起作用.我看到以下错误:
Couldn't match expected type `IO t0'
with actual type `FilePath -> IO ()'
In the expression: main
When checking the type of the function `main'
Run Code Online (Sandbox Code Playgroud)
我的作业是编写一个程序,程序必须包含一个main函数(因为它将被编译),而call的参数必须包含文件的名称.我不确定我是否理解这一点,我不知道如何继续.我会感激一些帮助.
haskell ×1