git.iko.soy/typeable/xsd-parser
on master help sign in
Remove unnecessary code
commit666c1730b321fd36114e6e64d2bf6372b5ad9848 authorDenis Redozubov <denis.redozubov@gmail.com> dateFri 4 Oct 2019, 16:55 (7 years ago) parent99c9216
1 file changed+1−32
src/Text/XSD/Parser.hs+1−32
src/Text/XSD/Parser.hs+1−32
@@ -26,38 +26,6 @@ type XSDMonad a = WriterT (M.Map Text Datatype) (Either SomeException) a
2626parseXSD :: ParseSettings -> ByteString -> Either SomeException XSD
2727parseXSD ps bs = parseLBS ps bs >>= toXsd
2828
29−data Expectation
30− = ExpName Text
31− | Expectation :+: Expectation
32−
33−satisfy :: Expectation -> XML.Node -> Bool
34−satisfy exp node@(NodeElement (XML.Element name _ _)) =
35− case node of
36− NodeElement (XML.Element (Name name _ _) _ _) -> case exp of
37− ExpName n -> name == n
38− exp1 :+: exp2 -> satisfy exp1 node && satisfy exp2 node
39−
40−satisfySome
41− :: XML.Cursor
42− -> [Expectation]
43− -> Bool
44−satisfySome c e = satisfySome' True c e
45−
46−satisfySome'
47− :: Bool -- ^ check current
48− -> XML.Cursor
49− -> [Expectation]
50− -> Bool
51−satisfySome' checkCurrent cur [] = True
52−satisfySome' checkCurrent cur (exp:exps) = result
53− where
54− satisfyCurrent = satisfy exp (node cur)
55− validChildren = P.filter (satisfy (P.head exps) . node) (child cur)
56− result =
57− if checkCurrent && P.null exps
58− then satisfyCurrent
59− else P.foldr (\c r -> r && satisfySome' False c exps) True validChildren
60−
6129-- Show is Meh
6230throwXsd :: Show s => s -> XSDMonad a
6331throwXsd = throwError . SomeException . XSDException . show
@@ -91,6 +59,7 @@ safeHead :: [a] -> Maybe a
9159safeHead [] = Nothing
9260safeHead (a:_) = Just a
9361
62+-- | Takes a cursor to the element itself.
9463toElem :: Cursor -> XSDMonad XSD.Element
9564toElem cursor = do
9665 case node cursor of