git.iko.soy/typeable/xsd-parser
on master help sign in
Remove unnecessary code
666c173Denis Redozubov
src/Text/XSD/Parser.hs+1−32
@@ -26,38 +26,6 @@ type XSDMonad a = WriterT (M.Map Text Datatype) (Either SomeException) a
26parseXSD :: ParseSettings -> ByteString -> Either SomeException XSD
26parseXSD :: ParseSettings -> ByteString -> Either SomeException XSD
27parseXSD ps bs = parseLBS ps bs >>= toXsd
27parseXSD ps bs = parseLBS ps bs >>= toXsd
28
28
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−
61-- Show is Meh
29-- Show is Meh
62throwXsd :: Show s => s -> XSDMonad a
30throwXsd :: Show s => s -> XSDMonad a
63throwXsd = throwError . SomeException . XSDException . show
31throwXsd = throwError . SomeException . XSDException . show
@@ -91,6 +59,7 @@ safeHead :: [a] -> Maybe a
91safeHead [] = Nothing
59safeHead [] = Nothing
92safeHead (a:_) = Just a
60safeHead (a:_) = Just a
93
61
62+-- | Takes a cursor to the element itself.
94toElem :: Cursor -> XSDMonad XSD.Element
63toElem :: Cursor -> XSDMonad XSD.Element
95toElem cursor = do
64toElem cursor = do
96 case node cursor of
65 case node cursor of