4
我尝试解析haskell中的命令行参数。解析命令行参数
下面是一个示例代码:
import System.Environment
work :: [Integer] -> Int
work (s:r:t:es) = length es
main :: IO()
main = getArgs >>= putStrLn . show . work . (map read)
我与执行它:
./test 2 10 10 [7, 3, 5, 4, 4]
输出是5像预期。 但是如果我更换之和Int长度整数执行引发错误
test: Prelude.read: no parse
有人能解释如何做到这一点?