checkstring :: [String] -> Int -> [String]
checkstring p n = do z <- doesFileExist (p !! n)
if z
then p
else error $ "'" ++ (p !! n) ++ "' file path does not exist"
"n"を調べると、文字列の要素がチェックされます(n = 2の場合、リストの2番目の文字列があるかどうかを確認します)。存在していれば、元の文字列リストを返します。そうでなければ、エラーになります。なぜこれをしますか? :Haskellで奇妙な結果が返ってくる
Couldn't match expected type `[t0]' with actual type `IO Bool'
In the return type of a call of `doesFileExist'
In a stmt of a 'do' expression: z <- doesFileExist (p !! n)
http://stackoverflow.com/questions/6904169/managing-the-io-monadの回答とディスカッションを参照 – MatrixFrog