git.iko.soy/typeable/xml-isogen
on master help sign in
Fix code and improve haddocks
commit987ed57fcd7631d6d75910f7e38719086a546b2e authorDenis Redozubov <denis.redozubov@gmail.com> dateWed 23 Oct 2019, 19:49 (7 years ago) parentb768c73
2 files changed+14−11
src/Data/THGen/XML/Internal.hs+8−5 test/TestDefs.hs+6−6
src/Data/THGen/XML/Internal.hs+8−5
@@ -24,10 +24,11 @@ import Text.XML.ParentAttributes
2424import qualified Text.XML.Writer as XW
2525
2626
27−-- | Marks the type of code generation:
28−-- Parser - generate only instances for xml parsing (@FromDom@)
29−-- Generator - generate only @ToXML@ instances
30−-- Both - generate @FromDom@ and @ToXML@ instances
27+{- | Marks the type of code generation:
28+@Parser@ - generate only instances for xml parsing (@FromDom@)
29+@Generator@ - generate only @ToXML@ instances
30+@Both@ - generate @FromDom@ and @ToXML@ instances
31+-}
3132data GenType = Parser | Generator | Both
3233
3334{- | Marks the style of code generation regarding records fields
@@ -324,7 +325,9 @@ isoXmlGenerateDatatype
324325 -- generate a newtype instead to do less allocations later
325326 then THC.newtypeD name (TH.recC name fields) [''Eq, ''Show, ''Generic]
326327 else THC.dataD name [TH.recC name fields] [''Eq, ''Show, ''Generic]
327− lensDecls <- makeFieldOpticsForDec lensRules termDecl
328+ lensDecls <- case generateLens of
329+ NoLens -> pure []
330+ LensRenaming -> makeFieldOpticsForDec lensRules termDecl
328331 nfDataInst <- do
329332 TH.instanceD
330333 (return [])
test/TestDefs.hs+6−6
@@ -23,13 +23,13 @@ import Test.QuickCheck.Instances ()
2323 & "US"
2424
2525"Foo" =:= record Both NoLens
26− ^ "Shmuux" [t|XmlQuux|]
27− + "Bar"
28− ? "Baz" [t|Text|]
29− !% "Quux"
30− ?% "Muux" [t|XmlQuux|]
26+ ^ "shmuux" [t|XmlQuux|]
27+ + "bar"
28+ ? "baz" [t|Text|]
29+ !% "quux"
30+ ?% "muux" [t|XmlQuux|]
3131
32−"Root" =:= record Both LensRename
32+"Root" =:= record Both LensRenaming
3333 ! "{http://example.com/ns/my-namespace}Foo"
3434
3535instance Arbitrary XmlRoot where