And*_*ndy 3 io syntax monads haskell
嘿,很抱歉在这里转发错误信息,但我已经尝试了所有我能找到的东西,似乎没什么关系.此代码生成错误:
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'函数中的所有调用.我究竟做错了什么?
谢谢
do表达式中的最后一行缩进太多了.
另外,你可以写
load :: String -> IO ()
load fileName =
putStr . createNode . lines . head . lines =<< readFile filename
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1463 次 |
| 最近记录: |