【发布时间】:2017-08-28 22:24:24
【问题描述】:
出于某种原因-我希望通过提出这个问题来找出答案-最近对 haskell 脚本实施了一系列更新,包括添加:
import System.Directory (doesFileExist, removeFile,getPermissions)
这有助于促进以下功能:
validFile :: FilePath -> IO Bool
validFile path = do
exists <- (doesFileExist path)
if exists
then (readable <$> getPermissions path)
else return False
调用为:
pwds <- case cfgPasswords of
Just passPath -> do
pathChecksOut <- validFile passPath
when (not pathChecksOut) $
errorL' ("Failed to access file at : " ++ passPath)
(map (Just . T.unpack) . lines) <$> readFileUtf8 passPath
Nothing -> return $ replicate (length cfgPublicKeys) Nothing
我无法再在我的机器上构建项目。
我得到的错误是Couldn't match type ‘[Char]’ with ‘Text’,它指向以下行:
errorL' ("Failed to access file at : " ++ passPath)
似乎有一个关于 StackOverflow 的问题试图解决类似的问题,this one。为了遵循该建议,我像errorL' ("Failed to access file at : " ++ (passPath :: Text)) 一样调整了该行,但我仍然无法构建该项目。
在实施您在上一篇文章中推荐的更改后,我收到的确切控制台输出如下所示:
完整的文件和添加此功能的进度(相当bug!)很好地封装在this gist file中。
【问题讨论】:
标签: haskell