Merge pull request #1825 from josephcsible/nofilterm
Use findM instead of filterM
This commit is contained in:
commit
83d329c8da
|
@ -491,6 +491,12 @@ ioInterface options files = do
|
||||||
first <- a arg
|
first <- a arg
|
||||||
if not first then return False else b arg
|
if not first then return False else b arg
|
||||||
|
|
||||||
|
findM p = foldr go (pure Nothing)
|
||||||
|
where
|
||||||
|
go x acc = do
|
||||||
|
b <- p x
|
||||||
|
if b then pure (Just x) else acc
|
||||||
|
|
||||||
findSourceFile inputs sourcePathFlag currentScript sourcePathAnnotation original =
|
findSourceFile inputs sourcePathFlag currentScript sourcePathAnnotation original =
|
||||||
if isAbsolute original
|
if isAbsolute original
|
||||||
then
|
then
|
||||||
|
@ -500,11 +506,11 @@ ioInterface options files = do
|
||||||
find original original
|
find original original
|
||||||
where
|
where
|
||||||
find filename deflt = do
|
find filename deflt = do
|
||||||
sources <- filterM ((allowable inputs) `andM` doesFileExist) $
|
sources <- findM ((allowable inputs) `andM` doesFileExist) $
|
||||||
(adjustPath filename):(map (</> filename) $ map adjustPath $ sourcePathFlag ++ sourcePathAnnotation)
|
(adjustPath filename):(map (</> filename) $ map adjustPath $ sourcePathFlag ++ sourcePathAnnotation)
|
||||||
case sources of
|
case sources of
|
||||||
[] -> return deflt
|
Nothing -> return deflt
|
||||||
(first:_) -> return first
|
Just first -> return first
|
||||||
scriptdir = dropFileName currentScript
|
scriptdir = dropFileName currentScript
|
||||||
adjustPath str =
|
adjustPath str =
|
||||||
case (splitDirectories str) of
|
case (splitDirectories str) of
|
||||||
|
|
Loading…
Reference in New Issue