【发布时间】:2016-04-03 01:11:08
【问题描述】:
我试图从一个使用 do 表示法的函数返回一个 Maybe 值,但我似乎无法让它工作。这个函数接受一个字符串(“文件名”)和一个要搜索的路径...
findIn :: String -> Path -> Maybe Path
findIn search start = do
file <- ls start
if ((filename file) == search)
then Just file
else Nothing
在哪里...
ls :: Path -> Array Path
filename :: Path -> String
但我不断收到错误消息“Count not match Type Array with type Maybe”,因此编译器似乎期望 do 表示法返回一个数组。我将如何返回一个可能的值?
【问题讨论】:
标签: maybe purescript do-notation