Generate instances for converting lists of strings to records.
- rowRecords :: [Name] -> Q [Dec]
Documentation
rowRecords :: [Name] -> Q [Dec]Source
Generate a
instance for each of the named types.
ParseRow
Each type must have exactly one constructor, in record style.
Column names are derived from the record field names by dropping the first
'_'
-separated component. This allows for a prefix to disambiguate record
labels between types.
For example, with
data Foo = Foo { f_bar :: String , f_baz :: Int } $(rowRecords [''Foo])
we can parse files of the form
bar,baz abc,3 def,5
assuming an appropriate CSV parser.