Getting the Takusen example code to compile - failed import problem

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? TIA, Daniel

From: beginners-bounces@haskell.org [mailto:beginners-bounces@haskell.org] On Behalf Of Daniel Everett
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?
Hello Daniel, Could you please send me the output from "ghc-pkg describe Takusen" ? It might be that the various backend modules have not been installed. The output from the installation process might also be useful e.g. setup -v configure Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. *****************************************************************

I have Takusen 0.8.5 installed and I'm trying to build
code found at http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.
the 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. Regards, Daniel

-----Original Message----- From: Daniel Everett [mailto:djeinbrum@yahoo.co.uk]
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.
Please create a darcs patch for Setup.hs and send it to me. IIRC, you were on Linux? I'm not sure if Takusen has been tested under Linux. We've receieved patches for OSX, Oleg uses BSD, and I have Windows, so it would be useful to get patches for Linux installs too.
create table dummy (id int primary key);
query1Iteratee :: (Monad m) => Int -> String -> Double -> IterAct m [(Int, String, Double)] query1Iteratee a b c accum = result' ((a, b, c):accum)
r <- doQuery (sql "select id from dummy") query1Iteratee [] liftIO(putStrLn(show r)) )
fromUTF8Ptr: zero byte found in string as position 8
Is there any thing wrong with the above code?
Yes. The iteratee function expects three columns in the result-set (with types Int, String, and Double, in that order), but your query only provides one column (dummy, of type Int). There is the beginnings of some code in a couple of the backends to validate the iteratee against the actual result-set, but it's nowhere near complete. So if you have a mismatch between iteratee and query, then you are likely to get marshaling erros and/or garbage. Note that it's OK to have a result-set return more columns than the iteratee consumes, but obviously to converse cannnot work.
Also, what does liftIO actually do?
The monad that your database session is in is a ReaderT wrapper over IO. In order to perform actions that run in the IO monad, you need to "lift" them. http://www.haskell.org/haskellwiki/Monad_Transformers_Explained Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. *****************************************************************
participants (2)
-
Bayley, Alistair
-
Daniel Everett