Hello there,

There's an odd error every time I try to run this code:

import Network.CGI
import Text.XHtml
import qualified Text.Html as H
import Database.HDBC
import Database.HDBC.Sqlite3
import System.Random

...

sqlReaderIO = do
    handle <- connectSqlite3 "table2.db"
    scoresSql <- quickQuery' handle "SELECT * FROM pachinkoScores ORDER BY score, name" []
    let scores = map (map (\x -> fromSql x :: String)) scoresSql
    return (show scores)

...

cgiTMain = do ...
              scoresPassed <- sqlReaderIO
              output . renderHtml $ (inputForm n ss) maybe (inputForm n ss) (\mT -> page "Loading..." (visual t v a mT ss) n v a (t + 1) mT) maxT


main = runCGI $ handleErrors cgiTMain


When I remove the "scoresPassed <- sqlReaderIO" line, the code run smoothly. Nothing else references "scoresPassed". The ghc, however, gives me this error when the line is included:

tankwSql.hs:144:15:
    No instance for (MonadCGI IO)
      arising from a use of `output'
    Possible fix: add an instance declaration for (MonadCGI IO)
    In the first argument of `(.)', namely `output'
    In the expression: output . renderHtml
    In the expression: output . renderHtml $ inputForm n

tankwSql.hs:147:30:
    Couldn't match expected type `CGIT m0 CGIResult'
                with actual type `IO CGIResult'
    In the first argument of `handleErrors', namely `cgiTMain'
    In the second argument of `($)', namely `handleErrors cgiTMain'
    In the expression: runCGI $ handleErrors cgiTMain

Thanks,

Will