Add 'tryParse' function to 'System.Path' (#2234)

This commit is contained in:
Ellis Kesterton 2021-12-31 00:23:45 +00:00 committed by GitHub
parent 266e06cab7
commit f016a81e37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -244,6 +244,13 @@ parsePath =
(x::xs) => x :: delete CurDir xs
pure $ MkPath vol (isJust root) body (isJust trailSep)
export
tryParse : String -> Maybe Path
tryParse str =
case parse parsePath (lexPath str) of
Right (path, []) => Just path
_ => Nothing
||| Parses a String into Path.
|||
||| The string is parsed as much as possible from left to right, and the invalid