git.iko.soy/typeable/xml-isogen
on master help sign in
Export GenType
commit5a2076557c45ba309c1188cec6eacbc1a225e9d2 authorDenis Redozubov <denis.redozubov@gmail.com> dateThu 10 Oct 2019, 15:14 (7 years ago) parent5ee3f5c
1 file changed+12−7
src/Data/THGen/XML.hs+12−7
src/Data/THGen/XML.hs+12−7
@@ -22,7 +22,7 @@ wrapper around the field type:
2222
2323Example 1.
2424
25−> "Color" =:= enum
25+> "Color" =:= enum Both
2626> & "R"
2727> & "G"
2828> & "B"
@@ -40,7 +40,7 @@ to be either @R@, @G@ or @B@.
4040
4141Example 2.
4242
43−> "Message" =:= record
43+> "Message" =:= record Both
4444> ! "author"
4545> + "recipient"
4646> ? "message" [t|Text|]
@@ -67,10 +67,10 @@ enumeration is exhaustive (contains only the listed constructors) or
6767non-exhaustive (also contains a constructor for unknown values; this
6868is the default):
6969
70−> "Enum1" Exhaustive =:= enum
70+> "Enum1" Exhaustive =:= enum Generator
7171> ...
7272
73−> "Enum2" NonExhaustive =:= enum
73+> "Enum2" NonExhaustive =:= enum Generator
7474> ...
7575
7676To define a record, use the `record` function followed by the name of
@@ -78,7 +78,7 @@ the data type to be generated. The prefix for the record fields is
7878inferred automatically by taking all of the uppercase letters in the
7979name. You can override it manually like so:
8080
81−> "Reference" "ref" =:= record
81+> "Reference" "ref" =:= record Parser
8282> ...
8383
8484To describe a record field you must supply its name as it appears
@@ -93,10 +93,14 @@ The type of the field is inferred automatically from its name, so
9393if the field is called @"author"@ its type will be @Author@. You can
9494override the type by specifying it in quasiquotes like so:
9595
96−> "Message" =:= record
97−> ! "author" [t|Person|]
96+> "Message" =:= record Both
97+> ! "author" [t|Person|].
9898> ...
9999
100+Both @record@ and @enum@ take a @GenType@ argument which tells it to generate
101+generator, parser or both. It's being used to optimize compilation time by
102+skipping the unnecessary TH instance generation.
103+
100104-}
101105
102106
@@ -104,6 +108,7 @@ module Data.THGen.XML
104108 ( Exhaustiveness(..)
105109 , PrefixName(..)
106110 , ExhaustivenessName(..)
111+ , GenType(..)
107112 , record
108113 , enum
109114 , (!)