feat(users/Profpatsch/jbovlaste-sqlite): add XML parser

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>
This commit is contained in:
Profpatsch 2023-06-04 02:34:48 +02:00 committed by clbot
parent c2baefbecc
commit 9a91669ba7
4 changed files with 299 additions and 22 deletions

View file

@ -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