Skip to content

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

Open
bsima wants to merge 1 commit into
haskell-hvr:masterfrom
bsima:lookupChoice
Open

Add 'lookupChoice' and '(.::)'#168
bsima wants to merge 1 commit into
haskell-hvr:masterfrom
bsima:lookupChoice

Conversation

@bsima

@bsima bsima commented Feb 18, 2019

Copy link
Copy Markdown

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.

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

bsima commented Feb 18, 2019

Copy link
Copy Markdown
Author

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

@hvr hvr added the enhancement label Sep 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants