Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bsima
Copy link

@bsima bsima commented Feb 18, 2019

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
Copy link
Author

bsima commented Feb 18, 2019

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