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

HDBC Snaplet Tutorial: Comments #1

Open
norm2782 opened this Issue Jan 11, 2012 · 3 comments

Comments

Projects
None yet
2 participants
@norm2782
Owner

norm2782 commented Jan 11, 2012

No description provided.

@norm2782

This comment has been minimized.

Show comment
Hide comment
@norm2782

norm2782 Jan 11, 2012

Owner

(Moved this comment by a guest commenter from the old Disqus comment system)

Have a question:

If I change the query from this:

query "SELECT * FROM messages WHERE somenum = ?" [toSql n]

To this:

query "SELECT * FROM messages"

Why do I now get [[Row]] as the result type instead of [Row]?

Owner

norm2782 commented Jan 11, 2012

(Moved this comment by a guest commenter from the old Disqus comment system)

Have a question:

If I change the query from this:

query "SELECT * FROM messages WHERE somenum = ?" [toSql n]

To this:

query "SELECT * FROM messages"

Why do I now get [[Row]] as the result type instead of [Row]?

@norm2782

This comment has been minimized.

Show comment
Hide comment
@norm2782

norm2782 Jan 11, 2012

Owner

You wouldn't. If you look at the type of query:

query :: HasHdbc m c s => String -> [SqlValue] -> m [Row]

You see that you need to apply this function to both a String (you SQL query) and a list of SqlValues. Since you have omitted the list in your example, you will be left with a partially applied function of type [SqlValue] -> m [Row]. In other words, if you do not want to bind any values to your query, you will still need to apply the function to an empty list to end up with a m [Row]

Owner

norm2782 commented Jan 11, 2012

You wouldn't. If you look at the type of query:

query :: HasHdbc m c s => String -> [SqlValue] -> m [Row]

You see that you need to apply this function to both a String (you SQL query) and a list of SqlValues. Since you have omitted the list in your example, you will be left with a partially applied function of type [SqlValue] -> m [Row]. In other words, if you do not want to bind any values to your query, you will still need to apply the function to an empty list to end up with a m [Row]

@danchoi

This comment has been minimized.

Show comment
Hide comment
@danchoi

danchoi Dec 3, 2012

Would you mind sketching how you would create the command line tool, outside the Snap context, with the HasHdbc typeclass? I understand typeclasses on a basic level, but the type signature of getHdbcState :: m (HdbcSnaplet c s) is a bit of a challenge for me to adapt to a program outside the Snap context.

danchoi commented Dec 3, 2012

Would you mind sketching how you would create the command line tool, outside the Snap context, with the HasHdbc typeclass? I understand typeclasses on a basic level, but the type signature of getHdbcState :: m (HdbcSnaplet c s) is a bit of a challenge for me to adapt to a program outside the Snap context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment