[Haskell-beginners] Getting the Takusen example code to compile -failed import problem

Daniel Everett djeinbrum at yahoo.co.uk
Thu Aug 6 14:21:19 EDT 2009

> > 
> > I have Takusen 0.8.5 installed and I'm trying to build
> the 
> > code found at 
> > http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.
> html using ghc 6.10.3.  This always fails with the
> error:  
> > 
> > Could not find module `Database.Oracle.Enumerator'
> > 
> > The analogous errors are encountered if I substitute
> Oracle 
> > with Sqlite, Postgresql or ODBC.  Any ideas how
> to resolve this?
OK, this now compiles thanks to (a) hacking Setup.hs to refer to odbc_config rather than odbcconf and (b) unregistering the user packages with ghc-pkg --user unregister Takusen.

However, if I then create a table in MySQL with:

create table dummy (id int primary key);

and then use a reduced form of the example code:

import Database.Enumerator
import Database.ODBC.Enumerator
import Control.Monad.Trans(liftIO)

query1Iteratee :: (Monad m) => Int -> String -> Double -> IterAct m [(Int, String, Double)]
query1Iteratee a b c accum = result' ((a, b, c):accum)

main :: IO ()
main = do
  withSession (connect "DSN=test") ( do
                                     -- simple query, returning reversed list of rows.
                                     r <- doQuery (sql "select id from dummy") query1Iteratee []
                                     liftIO(putStrLn(show r))

then I get the error:

fromUTF8Ptr: zero byte found in string as position 8

Is there any thing wrong with the above code?

Also, what does liftIO actually do?  Its documentation at http://cvs.haskell.org/Hugs/pages/libraries/mtl/Control-Monad-Trans.html does not actually say!  The link at the top of that page is dead as well.




More information about the Beginners mailing list