Generate catch-all clause in fromDom for extensions (#23)
commit319fd85b20bfda7d869cf5ddbe509ff9162d35e5
authorYuras <shumovichy@gmail.com>
dateThu 27 Feb 2020, 13:22 (7 years ago)
parent06793fd
golden/extension.xsd.hs+1
@@ -51,6 +51,7 @@ instance FromDom AnyXmlBasetype where
5151 "Basetype" -> TheXmlBasetype <$> fromDom
5252 "Ext2" -> TheXmlExt2 <$> fromDom
5353 "Ext1" -> TheXmlExt1 <$> fromDom
54+ _ -> throwParserError (PEOther "Unexpected type")
5455
5556instance ToXML AnyXmlBasetype where
5657 toXML (TheXmlBasetype a) = toXML a
src/Main.hs+4−1
@@ -138,7 +138,10 @@ genExtension base = do
138138 ]
139139 clauses <- mapM mkClause (base : map fst types)
140140 writeCode clauses
141− writeCode [""]
141+ writeCode
142+ [ " _ -> throwParserError (PEOther \"Unexpected type\")"
143+ , ""
144+ ]
142145 unless (mode == Parser) $ do
143146 writeCode
144147 [ "instance ToXML Any" <> baseTypeName <> " where"