From 2df952a2d7051fda168f8abeaeb8ed80a746defe Mon Sep 17 00:00:00 2001 From: RedContritio <591369735@qq.com> Date: Fri, 30 Aug 2019 21:32:26 +0800 Subject: [PATCH] fixed a bug in 9.rst RecursiveContents.hs:10:5: error: The last statement in a 'do' block must be an expression paths <- forM properNames $ \ name -> do { let ...; isDirectory <- doesDirectoryExist path; .... } --- chp/9.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/chp/9.rst b/chp/9.rst index c26d361..2ccb40a 100644 --- a/chp/9.rst +++ b/chp/9.rst @@ -24,12 +24,13 @@ find命令 getRecursiveContents topdir = do names <- getDirectoryContents topdir let properNames = filter (`notElem` [".", ".."]) names - paths <- forM properNames $ \name -> do - let path = topdir name - isDirectory <- doesDirectoryExist path - if isDirectory - then getRecursiveContents path - else return [path] + paths <- forM properNames + $ \name -> do + let path = topdir name + isDirectory <- doesDirectoryExist path + if isDirectory + then getRecursiveContents path + else return [path] return (concat paths) 单个表达式可以识别像“符合这个全局模式的名称”,“目录项是一个文件”,“当前最后一个被修改的文件”以及其他诸如此类的表达式,通过and或or算子就可以把他们装配起来构成更加复杂的表达式