"a 2"형식의 사용자 입력을 읽은 다음이를 튜플로 변환하고 튜플 목록에 추가하는 함수를 개발 중입니다. 이것은 사용자가 "done"을 입력 할 때까지 계속 발생합니다. 다음과 같이Haskell IO 함수 -> 유형 일치 오류
코드는이 파일을 실행하려고 할 때
getVectorData vector1 = do
putStrLn "Enter dimension and coefficient separated by a space: Enter \"Done\" to move on to next vector: "
appData <- getLine
if appData == "done" then
putStrLn "That's it"
else do
createVectorTuple (words appData) : vector1
getVectorData vector1
createVectorTuple :: [String] -> (String, Float)
createVectorTuple vectorData = ((head vectorData) , (read (last vectorData) :: Float))
어떻게 지금, 나는 오류 내가 잘못 뭐하는 거지
> ERROR file:.\MainApp.hs:13 - Type error in final generator
*** Term : getVectorData vector1
*** Type : IO()
*** Does not match : [a]
을 얻을 ...인가?
참고로 createVectorTuple 함수는 잘 작동합니다. –