2013-04-21 2 views
0

나는 다음과 같은 오류를 받고 있어요 ...하스켈 구문 분석 오류는 내부`입력에

구문 분석 오류를 차단 할 인수 '

...

다음 코드를 컴파일하는 동안 :

import System.Environment (getArgs) 

interactWith function inputFile outputFile = do 
    input <- readFile inputFile 
    writeFile outputFile (function input) 

main = mainWith myFunction 
    where mainWith function = do 
     args <- getArgs 
     case args of 
      [input,output] -> interactWith function input output 
      _ -> putStrLn "error: exactly two arguments needed" 

     -- replace "id" with the name of our function below 
     myFunction = id 

코드는 의 Real World Haskell의 4 장에서 가져온 것입니다.

답변

1

문제는 들여 쓰기되었습니다. 이 책에서 들여 쓰기를 올바르게 해석하지 못했습니다. 코드는 다음과 같이해야한다 : 나는 모호한 컴파일 에러가 하스켈 학습과 데 더 큰 문제의

import System.Environment (getArgs) 

interactWith function inputFile outputFile = do 
    input <- readFile inputFile 
    writeFile outputFile (function input) 

main = mainWith myFunction 
    where 
     mainWith function = do 
      args <- getArgs 
      case args of 
       [input,output] -> interactWith function input output 
       _ -> putStrLn "error: exactly two arguments needed" 

     -- replace "id" with the name of our function below 
     myFunction = id 

하나.

0

질문 코드에 들여 쓰기가 정확합니다. 아마도 코드에 던져 넣었을 것입니다. 편집기가 모든 탭을 4 칸으로 대체하도록하는 많은 방법이 있습니다.

관련 문제