git.iko.soy/typeable/xsd-isogen
on master help sign in
Generate catch-all clause in fromDom for extensions (#23)
319fd85Yuras
golden/extension.xsd.hs+1
@@ -51,6 +51,7 @@ instance FromDom AnyXmlBasetype where
51 "Basetype" -> TheXmlBasetype <$> fromDom
51 "Basetype" -> TheXmlBasetype <$> fromDom
52 "Ext2" -> TheXmlExt2 <$> fromDom
52 "Ext2" -> TheXmlExt2 <$> fromDom
53 "Ext1" -> TheXmlExt1 <$> fromDom
53 "Ext1" -> TheXmlExt1 <$> fromDom
54+ _ -> throwParserError (PEOther "Unexpected type")
54
55
55instance ToXML AnyXmlBasetype where
56instance ToXML AnyXmlBasetype where
56 toXML (TheXmlBasetype a) = toXML a
57 toXML (TheXmlBasetype a) = toXML a
src/Main.hs+4−1
@@ -138,7 +138,10 @@ genExtension base = do
138 ]
138 ]
139 clauses <- mapM mkClause (base : map fst types)
139 clauses <- mapM mkClause (base : map fst types)
140 writeCode clauses
140 writeCode clauses
141− writeCode [""]
141+ writeCode
142+ [ " _ -> throwParserError (PEOther \"Unexpected type\")"
143+ , ""
144+ ]
142 unless (mode == Parser) $ do
145 unless (mode == Parser) $ do
143 writeCode
146 writeCode
144 [ "instance ToXML Any" <> baseTypeName <> " where"
147 [ "instance ToXML Any" <> baseTypeName <> " where"