diff options
author | Profpatsch <mail@profpatsch.de> | 2023-06-04T00·34+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-07-13T23·03+0000 |
commit | 9a91669ba75955dbb20300c7ef44e72274750a95 (patch) | |
tree | f00df63c5769d65eab009e0c9035df034e2299ef /users/Profpatsch/netencode/Netencode/Parse.hs | |
parent | c2baefbecc22986338563775524d41bb2f522bf1 (diff) |
feat(users/Profpatsch/jbovlaste-sqlite): add XML parser r/6411
nice. Change-Id: Iea90578742bfb689cd0508dbaf641c31aed577ad Reviewed-on: https://cl.tvl.fyi/c/depot/+/8709 Tested-by: BuildkiteCI Autosubmit: Profpatsch <mail@profpatsch.de> Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'users/Profpatsch/netencode/Netencode/Parse.hs')
-rw-r--r-- | users/Profpatsch/netencode/Netencode/Parse.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/users/Profpatsch/netencode/Netencode/Parse.hs b/users/Profpatsch/netencode/Netencode/Parse.hs index adfd1e0a6534..e55eedf568db 100644 --- a/users/Profpatsch/netencode/Netencode/Parse.hs +++ b/users/Profpatsch/netencode/Netencode/Parse.hs @@ -32,6 +32,15 @@ newtype Parse from to ((,) [Text]) ) +instance Semigroupoid Parse where + o p2 p1 = Parse $ \from -> case runParse' p1 from of + Failure err -> Failure err + Success to1 -> runParse' p2 to1 + +instance Category Parse where + (.) = Semigroupoid.o + id = Parse $ \t -> Success t + runParse :: Error -> Parse from to -> from -> Either ErrorTree to runParse errMsg parser t = (["$"], t) @@ -43,15 +52,6 @@ runParse errMsg parser t = runParse' :: Parse from to -> ([Text], from) -> Validation (NonEmpty ErrorTree) ([Text], to) runParse' (Parse f) from = f from -instance Semigroupoid Parse where - o p2 p1 = Parse $ \from -> case runParse' p1 from of - Failure err -> Failure err - Success to1 -> runParse' p2 to1 - -instance Category Parse where - (.) = Semigroupoid.o - id = Parse $ \t -> Success t - parseEither :: (([Text], from) -> Either ErrorTree ([Text], to)) -> Parse from to parseEither f = Parse $ \from -> f from & eitherToListValidation |