就像它在标题中所说:什么The last statement in a 'do' construct must be an expression意思?我结束了我的do块,putStrLn就像我在几个例子中看到的那样,我得到了一个错误.
码:
main = do args <- getArgs
file <-readFile "TWL06.txt"
putStrLn results
Run Code Online (Sandbox Code Playgroud) 嘿,很抱歉在这里转发错误信息,但我已经尝试了所有我能找到的东西,似乎没什么关系.此代码生成错误:
import System.Environment
import System.Directory
import System.IO
import Data.List
data Node = PathNode String Float Float [String] | NoNode deriving (Show)
main = do
(filename:args) <- getArgs
load filename
load :: String -> IO ()
load fileName = do
contents <- readFile fileName
let pathStrings = lines contents
first = head pathStrings
args = lines first
path = createNode args
putStr path
createNode [String] -> Node
createNode (name:x:y:paths) = PathNode name x y paths
createNode [] = NoNode
Run Code Online (Sandbox Code Playgroud)
我知道它与对齐有关,但我已正确对齐'load'函数中的所有调用.我究竟做错了什么?
谢谢