From f016a81e37c538229d6a661fbcade0aadff29130 Mon Sep 17 00:00:00 2001 From: Ellis Kesterton <31514698+eayus@users.noreply.github.com> Date: Fri, 31 Dec 2021 00:23:45 +0000 Subject: [PATCH] Add 'tryParse' function to 'System.Path' (#2234) --- libs/contrib/System/Path.idr | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libs/contrib/System/Path.idr b/libs/contrib/System/Path.idr index 132f884df..d24dd2238 100644 --- a/libs/contrib/System/Path.idr +++ b/libs/contrib/System/Path.idr @@ -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