cassava icon indicating copy to clipboard operation
cassava copied to clipboard

Add 'lookupChoice' and '(.::)'

Open bsima opened this issue 6 years ago • 1 comments

This helper function allows code like:

data Person = Person { first :: ByteString, last :: ByteString }

instance FromNamedRecord Person where
  parseNamedRecord r =
    Person <$> r .:: ["firstName", "fname"] <*> lookupChoice r ["lastName", "lname"]

which is useful when working with a small set of similarly-structured CSV files, or where field names vary slightly.

bsima avatar Feb 18 '19 20:02 bsima

Let me know if you need version numbers bumped, more docs, etc before merging.

bsima avatar Feb 18 '19 20:02 bsima