Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 为什么我能';是否使用(cnt<;-hGeth)表达式代替cnt?_Haskell - Fatal编程技术网

Haskell 为什么我能';是否使用(cnt<;-hGeth)表达式代替cnt?

Haskell 为什么我能';是否使用(cnt<;-hGeth)表达式代替cnt?,haskell,Haskell,我学哈斯克尔。它工作得很好: import System.IO main = do h <- openFile "text.txt" ReadMode cnt <- hGetContents h mapM_ putStrLn $ lines cnt hClose h import System.IO main=do 问题是cntcnt>=\cnt-> 它不是一个表达式,而是用于do块中自己的行的 如果仍希望将其保留在一行中,则可以执行此操作,但稍后将无法引用该文件

我学哈斯克尔。它工作得很好:

import System.IO

main = do
  h <- openFile "text.txt" ReadMode
  cnt <- hGetContents h
  mapM_ putStrLn $ lines cnt
  hClose h
import System.IO
main=do

问题是
cnt
cnt>=\cnt->

它不是一个表达式,而是用于do块中自己的行的

如果仍希望将其保留在一行中,则可以执行此操作,但稍后将无法引用该文件的内容:

import System.IO

main = do
  h <- openFile "text.txt" ReadMode  
  hGetContents h >>= mapM_ putStrLn . lines
  hClose h
import System.IO
main=do
h>=mapM_uuputstrn。线
盐酸
hGetContents h >>= \ cnt -> {- rest of do block -}
hGetContents h >>= \ cnt -> mapM_ putStrLn (lines cnt)
hGetContents h >>= mapM_ putStrLn . lines
import System.IO

main = do
  h <- openFile "text.txt" ReadMode  
  hGetContents h >>= mapM_ putStrLn . lines
  hClose h