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 番目の文字列かどうかをチェックします)、それが存在するかどうかを確認します。存在する場合は元の文字列リストを返し、存在しない場合はエラーになります.なぜこれを行うのですか? :
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)