PParser.hs: filename: Explain failed parse with |fail|

This still provides misleading output from the parser about what it
was expecting, but does explain what the actual problem was:

    *Pkg.PParser> execout <$> runparser pPkg defaultPkg "foo.ipkg"
                  "package bar\n\nexecutable = \"invalid/filename\""
    Failure foo.ipkg:3:32: error: a filename
        must be non-empty and have no
        directory
        component, expected: space
    executable = "invalid/filename"<EOF>
                                   ^
This commit is contained in:
Jeremy W. Sherman 2015-10-12 23:16:00 -04:00
parent 3ccdc4b7c7
commit 67ff67e4d8

View File

@ -79,8 +79,9 @@ filename = (do
-- Through at least version 0.9.19.1, IPKG executable values were
-- possibly namespaced identifiers, like foo.bar.baz.
show <$> fst <$> iName []
guard $ isValidFilename filename
return filename)
if isValidFilename filename
then return filename
else fail "a filename must be non-empty and have no directory component")
<?> "filename"
where
isValidFilename :: FilePath -> Bool