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

sweeping aside a documentation stumbling block for new people #108

Merged
merged 2 commits into from
May 28, 2014
Merged

sweeping aside a documentation stumbling block for new people #108

merged 2 commits into from
May 28, 2014

Conversation

bitemyapp
Copy link
Contributor

Cheers :)

@bitemyapp
Copy link
Contributor Author

Also, please rebuild and push the documentation afterward, Hackage docs are broken for current version. New people won't know to walk the version back a notch.

See here for example of manual doc pushing:

https://github.com/bitemyapp/bloodhound/blob/master/Makefile#L27-L29

@lpsmith
Copy link
Owner

lpsmith commented May 27, 2014

Would it make more sense to use :: IO [Only Int]? At least, that's what I would do...

@bitemyapp
Copy link
Contributor Author

@lpsmith Point of the change is to make the documented example "just work" for new people as it currently doesn't, I just tried what you suggested and the following happened:

λ> query_ conn "select 2 + 2" :: IO [[Int]]
[[4]]
λ> query_ conn "select 2 + 2" :: IO [[Only Int]]

<interactive>:6:1:
    No instance for (Database.PostgreSQL.Simple.FromField.FromField
                       (Only Int))
      arising from a use of ‘query_’
    In the expression: query_ conn "select 2 + 2" :: IO [[Only Int]]
    In an equation for ‘it’:
        it = query_ conn "select 2 + 2" :: IO [[Only Int]]

@lpsmith
Copy link
Owner

lpsmith commented May 27, 2014

You have an extra list type constructor, that should be only one set of brackets, not two.

Only is a 1-tuple introduced by mysql-simple and adopted by postgresql-simple, it's FromRow instance looks for only one column of a given type whereas [a]'s instances consumes all of the remaining columns, and the postgresql type of every column must be compatible with a's FromField instance. (Although they need not all be the same postgresql type.)

@bitemyapp
Copy link
Contributor Author

@lpsmith I see now, I'll change accordingly.

λ> query_ conn "select 2 + 2" :: IO [Only Int]
[Only {fromOnly = 4}]

But you should note that I didn't figure this out from the documentation. People cannot derive this stuff themselves if they didn't write the library.

@bitemyapp
Copy link
Contributor Author

@lpsmith changed per recommendation, thanks :)

@lpsmith
Copy link
Owner

lpsmith commented May 28, 2014

I don't doubt the documentation could be better, and I do very much appreciate having a beginner look at this. But I would point out that despite a fair number of users, I don't get that many questions via email or IRC, and Only is documented

lpsmith added a commit that referenced this pull request May 28, 2014
sweeping aside a documentation stumbling block for new people
@lpsmith lpsmith merged commit 1d65029 into lpsmith:master May 28, 2014
lpsmith added a commit that referenced this pull request Jul 26, 2014
Taken from paul-rouse/mysql-simple@620a639

Turns out that issue #108 was fixed in mysql-simple before postgresql-simple's
first release,  but before I started examining mysql-simple.   So by some
mechanism,  I started work on postgresql-simple from a slightly out-of-date
version of mysql-simple.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants