我正在開發一個函數,讀取形式「a 2」的用戶輸入,然後將其轉換爲元組並將其添加到元組列表。這應該繼續發生,直到用戶鍵入「完成」。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函數運行良好。 –