我在读取文件时遇到问题。每当我需要从文件中读取数据时,我都会执行以下操作:
main = do x <- readFile "/tmp/foo.txt"
putStr x
但现在我希望路径成为一个论点,所以我尝试了以下
main s = do x <- readFile s
putStr x
它不起作用。我看到以下错误:
Couldn't match expected type `IO t0'
with actual type `FilePath -> IO ()'
In the expression: main
When checking the type of the function `main'
我的作业是编写一个程序,该程序必须包含一个主函数(因为它将被编译),并且调用的参数必须包含文件名。我不确定我是否理解这一点,我不知道如何继续。我会感谢一些帮助。