I am trying to use the fold_ function from Haskell's sqlite-simple package, but how do I call it? I have it in a 'do block' in main, but none of my attempts have been able to compile. I am able to get the query_ function to work, but now I need to retrive the values one at a time. As an example, I am trying to sum a list of integers from the database.
main :: IO ()
main = do
conn <- open "C:\\project.DB"
theSum <- fold_ conn "SELECT rserial from conitr1" 0 (\tot val -> val + tot )
close conn
I understand that it's doing an IO operation, and that I probably need to specify the type somewhere, but nothing I try seems to work. The api documentation is here http://hackage.haskell.org/packages/archive/sqlite-simple/0.4.2.0/doc/html/Database-SQLite-Simple.html#v:fold