rowrecord-0.1: Build records from lists of strings, as from CSV files.

Text.RowRecord.TH

Description

Generate instances for converting lists of strings to records.

Synopsis

Documentation

rowRecords :: [Name] -> Q [Dec]Source

Generate a ParseRow instance for each of the named types.

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.