Trivial database access in Haskell

I'm an Oracle DBA, and I have been looking at Haskell with interest for a long while now. But I don't feel particularly that I could use it in my "day job", mainly because I can't seem to find a nice, simple way of doing (Oracle) database access in Haskell. What I'm after is very simple - I want to be able to connect to a database and issue SQL queries and DML (updates, inserts, etc). There's nothing particularly "functional" in this - it's more of a basic building block (like file I/O) as far as I'm concerned, so I'm happy for database access to sit in the IO monad. I've looked at the various database access libraries for Haskell, but they all seem to be missing a couple of key pieces if I want to use them: 1. Simple documentation of how to install the library (starting from a vanilla GHC installation on Windows, plus Oracle software, to the point where I can use the library in my code). All I need is Oracle access, so other database client libraries can be ignored. I'd rather not use ODBC, but will if required. 2. Simple examples on how to actually run a query. For example, how do I code the follwing SQL*Plus code (should be pretty self-explanatory) in Haskell: connect scott/tiger@mydb select * from emp; (Connect to the database "mydb" as user "scott", password "tiger", and issue the query "select * from emp"). Ideally, I'd like the Haskell code to not be *too* much more verbose than this (although I can accept that Haskell, beng a general language, won't be able to be quite as concise as a special tool can manage). Without this basis, I don't really have a way to evaluate the various libraries available... If anyone can offer any assistance, I'd be very grateful. Paul.

On 12/11/06, Paul Moore
I've looked at the various database access libraries for Haskell, but they all seem to be missing a couple of key pieces if I want to use them:
1. Simple documentation of how to install the library (starting from a vanilla GHC installation on Windows, plus Oracle software, to the point where I can use the library in my code). All I need is Oracle access, so other database client libraries can be ignored. I'd rather not use ODBC, but will if required.
2. Simple examples on how to actually run a query. For example, how do I code the follwing SQL*Plus code (should be pretty self-explanatory) in Haskell:
connect scott/tiger@mydb select * from emp;
(Connect to the database "mydb" as user "scott", password "tiger", and issue the query "select * from emp"). Ideally, I'd like the Haskell code to not be *too* much more verbose than this (although I can accept that Haskell, beng a general language, won't be able to be quite as concise as a special tool can manage).
Without this basis, I don't really have a way to evaluate the various libraries available...
This is when you write that documentation :-) And I say that without knowing anything about any of the Haskell database libraries -- I just suspect that if you can't find any good documentation for them, that's your cue to write it. This might not seem like a helpful answer, but often it's the best answer anyone can give. I realize that you only have so many hours in the day, but only a few people get paid to work on Haskell full-time. So if you really wanted to find out whether the existing libraries would work for your purposes, try it, and write up what you found so that other people can benefit from it. Cheers, Kirsten -- Kirsten Chevalier* chevalier@alum.wellesley.edu *Often in error, never in doubt "We used to say that our love was like hemp rope / Three times as strong as the rope that you buy domestically." -- Dar Williams

On 12/11/06, Kirsten Chevalier
This is when you write that documentation :-) And I say that without knowing anything about any of the Haskell database libraries -- I just suspect that if you can't find any good documentation for them, that's your cue to write it.
Sorry, I didn't make that clear - I absolutely would be happy to write up whatever I ended up with that works. The point I was trying (badly!) to make was that without sample code on how to do "trivial" queries, I can't work out which library is closest to what I want. And without installation instructions, I can't try them out. What I *can* do, is to attempt to install one of the libraries that looks closest to what I want (probably HDBC, because I'm familiar with the Python DB-API). But I honestly have little or no idea how to start - following the HDBC link on the Haskell Wiki leads to a huge list of tar.gz files, with no indication of which one I might want :-( Option 2, Takusen, leads to a file listing, but no downloadable package. Option 3, HSQL, leads to a page which doesn't mention Oracle support (even though the Wiki page does) so I'm put off trying further...
This might not seem like a helpful answer, but often it's the best answer anyone can give. I realize that you only have so many hours in the day, but only a few people get paid to work on Haskell full-time. So if you really wanted to find out whether the existing libraries would work for your purposes, try it, and write up what you found so that other people can benefit from it.
Will do, but I need help with "try it", and I'm guessing as to which library is my best bet :-( This is my first real experience with trying to obtain and use a 3rd party library with Haskell, so I apologise if these are newbie-level dumb issues. I'm not trying to complain, but I do suspect there is an issue here with easy library availability that the Haskell community could look at. Python was in a similar situation for a long time, and I suspect it's just a bit further down the track. Certainly from what I've seen of Cabal, it's similar in philosophy to Python's distutils. But this is going off on a tangent - maybe I'll revisit it when I've got some more experience under my belt with installing DB libraries :-) Paul.

On 12/11/06, Paul Moore
The point I was trying (badly!) to make was that without sample code on how to do "trivial" queries, I can't work out which library is closest to what I want. And without installation instructions, I can't try them out.
Well, if anyone has that sample code, someone who is reading this mailing list probably does. But if you can't find even simple sample code, that's probably a sign that not a lot of people have tried to write large database applications in Haskell using the existing libraries, or at all. I may be wrong, but I suspect that that's true. Somebody has to be first. So this is your cue to RTFS. And I'm trying to say "RTFS" in the nicest possible way in which I can say it. With an "F" that stands for "friendly" although I suspect that the code is going to look to you like anything but.
This is my first real experience with trying to obtain and use a 3rd party library with Haskell, so I apologise if these are newbie-level dumb issues. I'm not trying to complain, but I do suspect there is an issue here with easy library availability that the Haskell community could look at. Python was in a similar situation for a long time, and I suspect it's just a bit further down the track. Certainly from what I've seen of Cabal, it's similar in philosophy to Python's distutils. But this is going off on a tangent - maybe I'll revisit it when I've got some more experience under my belt with installing DB libraries :-)
Don't apologize; you're not being dumb. But, you have to realize that if you're using Haskell at all, you *are* the Haskell community. Cheers, Kirsten -- Kirsten Chevalier* chevalier@alum.wellesley.edu *Often in error, never in doubt "...I thought the secret of life was obvious: be here now, love as if your whole life depended on it, find your life's work, and try to get hold of a giant panda." -- Anne Lamott

On 12/11/06, Kirsten Chevalier
Don't apologize; you're not being dumb. But, you have to realize that if you're using Haskell at all, you *are* the Haskell community.
OK, thanks for the gentle push. After a bit of digging, I decided that the takusen link looked like a darcs repository, and I downloaded darcs and got takusen. I installed GHC 6.6 in a spare VM (no PC round I can install stuff on just now, I'll do this properly later). On the assumption that the takusen.cabal file means I should look at Cabal, I had a dig and found the incantation "runhaskell setup.hs". I got the error: F:\takusen>runhaskell setup.hs setup.hs:11:7: Could not find module `Distribution.Compat.FilePath': it is hidden (in package Cabal-1.1.6) I assume this relates to the note in setup.hs "For ghc-6.6 you will need to first install Cabal-1.1.6.1", but as I got GHC from a Windows binary install, I'm not sure where to go from here. I found the Cabal webpage and downloaded 1.1.6.1. Trying to install it, I got the following: F:\cabal-1.1.6.1>runhaskell Setup.lhs install Setup.lhs: error reading ./.setup-config; run "setup configure" command? F:\cabal-1.1.6.1>runhaskell Setup.lhs configure Configuring Cabal-1.1.6.1... configure: Dependency base-any: using base-2.0 configure: Using install prefix: C:\Program Files configure: Binaries installed in: C:\Program Files\Haskell\bin configure: Libraries installed in: C:\Program Files\Haskell\Cabal-1.1.6.1\ghc-6.6 configure: Private binaries installed in: C:\Program Files\Cabal-1.1.6.1 configure: Data files installed in: C:\Program Files\Common Files\Cabal-1.1.6.1 configure: Using compiler: c:\ghc\ghc-6.6\bin\ghc.exe configure: Compiler flavor: GHC configure: Compiler version: 6.6 configure: Using package tool: c:\ghc\ghc-6.6\bin\ghc-pkg.exe configure: Using ar found on system at: c:\ghc\ghc-6.6\bin\ar.exe configure: No haddock found configure: No pfesetup found configure: No ranlib found configure: Using runghc found on system at: c:\ghc\ghc-6.6\bin\runghc.exe configure: No runhugs found configure: No happy found configure: No alex found configure: Using hsc2hs: c:\ghc\ghc-6.6\bin\hsc2hs.exe configure: No c2hs found configure: No cpphs found configure: No greencard found F:\cabal-1.1.6.1>runhaskell Setup.lhs install Installing: C:\Program Files\Haskell\Cabal-1.1.6.1\ghc-6.6 & C:\Program Files\Haskell\bin Cabal-1.1.6.1... Setup.lhs: Error: Could not find module: Distribution.Compiler with any suffix: ["hi"] OK, that's as far as I can go. Remember, what I *want* to do is to run some SQL against my database to get some data into a Haskell program. I'm not up to debugging a Cabal install. (At this point, if I was doing this for "real work", I'd be off to the Python website like a shot...) Can anyone help? I promise, I will document what I end up with! Paul.

Now you're getting somewhere! (Even though it may not seem like it.) At this point, this is probably a better place to ask: http://www.haskell.org/cabal/ In particular, it says where to ask questions. I haven't used Cabal much myself and I suspect that the people who know about Cabal are more likely to notice your question if you ask somewhere other than on this list, which is noisy. Good luck. Cheers, Kirsten -- Kirsten Chevalier* chevalier@alum.wellesley.edu *Often in error, never in doubt "I'm sick of my genitalia being used as an insult. Are you?" -- Bitch and Animal

On 12/11/06, Paul Moore
F:\cabal-1.1.6.1>runhaskell Setup.lhs install Installing: C:\Program Files\Haskell\Cabal-1.1.6.1\ghc-6.6 & C:\Program Files\Haskell\bin Cabal-1.1.6.1... Setup.lhs: Error: Could not find module: Distribution.Compiler with any suffix: ["hi"]
The magic commands are:
runhaskell Setup.lhs configure
runhaskell Setup.lhs build
runhaskell Setup.lhs install
--
Taral

Taral wrote:
On 12/11/06, Paul Moore
wrote: F:\cabal-1.1.6.1>runhaskell Setup.lhs install Installing: C:\Program Files\Haskell\Cabal-1.1.6.1\ghc-6.6 & C:\Program Files\Haskell\bin Cabal-1.1.6.1... Setup.lhs: Error: Could not find module: Distribution.Compiler with any suffix: ["hi"]
The magic commands are:
runhaskell Setup.lhs configure
Also, if you're going to profile the code that uses this module, you need to compile the libraries with profiling enabled; you can do this by doing "configure -p" instead of "configure" above.
runhaskell Setup.lhs build runhaskell Setup.lhs install

On Mon, Dec 11, 2006 at 11:25:59PM +0000, Paul Moore wrote:
On 12/11/06, Kirsten Chevalier
wrote: Don't apologize; you're not being dumb. But, you have to realize that if you're using Haskell at all, you *are* the Haskell community.
OK, thanks for the gentle push. After a bit of digging, I decided that the takusen link looked like a darcs repository, and I downloaded darcs and got takusen. I installed GHC 6.6 in a spare VM (no PC round I can install stuff on just now, I'll do this properly later). On the assumption that the takusen.cabal file means I should look at Cabal, I had a dig and found the incantation "runhaskell setup.hs".
I got the error:
F:\takusen>runhaskell setup.hs
setup.hs:11:7: Could not find module `Distribution.Compat.FilePath': it is hidden (in package Cabal-1.1.6)
'hidden' means that it is installed, but access is forbidden (no, I don't know why the feature exists). To allow access: ghc-pkg expose Cabal (disclaimer: untested command)

if you're using Haskell at all, you *are* the Haskell community.
[..lots of "I searched, I found, I tried, I got this error, I thought, I tried this workaround, I got to this point, now I'm stuck here..]
I just wanted to comment that I find this kind of "experience report"
very helpful, especially if someone does not give up at the first hurdle,
and goes through the trouble of writing up all the frustrating steps and
thoughts rather than summarizing ("it didn't work"/"I got it to work
after some fiddling") - thanks!
The problem with mindsets is that minds get set in them, and not only
do people outside find it very difficult to "get in", but the people inside
find it very difficult to understand what it is like "outside".
While you are looking for documentation of the supposedly easy first
steps to get you started on your more detailed investigation, so you
have just provided the rest of the community with some documentation
of what its works currently look like.
That situation seems to be slightly embarrassing (if only because we
are tempted to think that we have no time for the traditional README
and INSTALL files - after all, all darcs/cabal stuff is self-explanatory,
isn't it, and has been discussed to death somewhere, hasn't it, and the
library does the obvious thing, doesn't it, and isn't quite ready for prime
time yet anyway, at which time it is going to be carved in stone and
documented thoroughly by a team of Pulitzer-price-winning authors?-)
Seriously, and as Simon PJ has been fond of reminding us: the user is
always right, so I very much hope that those of us involved with the
projects mentioned in your report will take note and do something
about it (for easy reference I repeat it at the end of this message;-).
Some suggestions, gleaned from your experience (perhaps you could
comment on whether they'd have been of any use?):
cabal:
- the separation into interpreter/compiler and resource as Setup
does not set up the right mindset in users. for instance, you can
"runhaskell Setup.hs --help" as for most unixy tools, but who'd
think of that in this situation, and how much does it help?
+ add a dedicated command "cabal", which does nothing more
than "runhaskell Setup", but is more memorable and suggestive
+ when anything goes wrong, also mention "cabal --help" in the
error message
+ in "cabal --help", explicitly and prominently mention the typical
usage cycle (configure/build/install); also point to cabal home
page, with more documentation, bug reports, newest version
and known problem info, downloads, ..
- the three step separation into configure/build/install is traditional
and has good justifications, but is unhelpful for the most typical
use case (I need a library for a part of my work, it isn't installed
by default, it doesn't have an installer, so I have to do this cabal
thing to get on with my work). if someone types "cabal install"
as the first command, cabal might engage in a simple dialogue:
"would you like to configure then build then install
- following the HDBC link on the Haskell Wiki leads to a huge list of tar.gz files, with no indication of which one I might want :-(
Option 2, Takusen, leads to a file listing, but no downloadable package.
Option 3, HSQL, leads to a page which doesn't mention Oracle support (even though the Wiki page does) so I'm put off trying further...
- installing database libraries is not the main activity, it just gets in the way of running SQL queries from Haskell, and may well be the first experience with getting/building/installing 3rd party libs for Haskell - other languages and their bindings are tempting if potential users get stuck I hope this summary/rephrasing of Paul's report is helpful. what do users and implementors think (cc-ed to libraries list)? Claus
OK, thanks for the gentle push. After a bit of digging, I decided that the takusen link looked like a darcs repository, and I downloaded darcs and got takusen. I installed GHC 6.6 in a spare VM (no PC round I can install stuff on just now, I'll do this properly later). On the assumption that the takusen.cabal file means I should look at Cabal, I had a dig and found the incantation "runhaskell setup.hs".
I got the error:
F:\takusen>runhaskell setup.hs
setup.hs:11:7: Could not find module `Distribution.Compat.FilePath': it is hidden (in package Cabal-1.1.6)
I assume this relates to the note in setup.hs "For ghc-6.6 you will need to first install Cabal-1.1.6.1", but as I got GHC from a Windows binary install, I'm not sure where to go from here. I found the Cabal webpage and downloaded 1.1.6.1. Trying to install it, I got the following:
F:\cabal-1.1.6.1>runhaskell Setup.lhs install Setup.lhs: error reading ./.setup-config; run "setup configure" command?
F:\cabal-1.1.6.1>runhaskell Setup.lhs configure Configuring Cabal-1.1.6.1... configure: Dependency base-any: using base-2.0 configure: Using install prefix: C:\Program Files configure: Binaries installed in: C:\Program Files\Haskell\bin configure: Libraries installed in: C:\Program Files\Haskell\Cabal-1.1.6.1\ghc-6.6 configure: Private binaries installed in: C:\Program Files\Cabal-1.1.6.1 configure: Data files installed in: C:\Program Files\Common Files\Cabal-1.1.6.1 configure: Using compiler: c:\ghc\ghc-6.6\bin\ghc.exe configure: Compiler flavor: GHC configure: Compiler version: 6.6 configure: Using package tool: c:\ghc\ghc-6.6\bin\ghc-pkg.exe configure: Using ar found on system at: c:\ghc\ghc-6.6\bin\ar.exe configure: No haddock found configure: No pfesetup found configure: No ranlib found configure: Using runghc found on system at: c:\ghc\ghc-6.6\bin\runghc.exe configure: No runhugs found configure: No happy found configure: No alex found configure: Using hsc2hs: c:\ghc\ghc-6.6\bin\hsc2hs.exe configure: No c2hs found configure: No cpphs found configure: No greencard found
F:\cabal-1.1.6.1>runhaskell Setup.lhs install Installing: C:\Program Files\Haskell\Cabal-1.1.6.1\ghc-6.6 & C:\Program Files\Haskell\bin Cabal-1.1.6.1... Setup.lhs: Error: Could not find module: Distribution.Compiler with any suffix: ["hi"]
OK, that's as far as I can go. Remember, what I *want* to do is to run some SQL against my database to get some data into a Haskell program. I'm not up to debugging a Cabal install. (At this point, if I was doing this for "real work", I'd be off to the Python website like a shot...)
Can anyone help? I promise, I will document what I end up with!
Paul. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

From: libraries-bounces@haskell.org [mailto:libraries-bounces@haskell.org] On Behalf Of Claus Reinke
That situation seems to be slightly embarrassing (if only because we are tempted to think that we have no time for the traditional README and INSTALL files - after all, all darcs/cabal stuff is self-explanatory, isn't it, and has been discussed to death somewhere, hasn't it, and the library does the obvious thing, doesn't it, and isn't quite ready for prime time yet anyway, at which time it is going to be carved in stone and documented thoroughly by a team of Pulitzer-price-winning authors?-)
I guess I should comment, as one of the Takusen authors. Yes, this is embarrasing. We have made a number of assumptions which Paul exposed: - users should know to do darcs get, then runhaskell Setup.hs configure/build/install - users should know to look for Haddock docs - users should know how to look for and install dependent libraries (Cabal-1.1.6.1, in this case) If you're an experienced Haskell programmer then these assumptions are valid, so yes, we do need to do more for the novice. It is nice to actually get some kind of feedback, even if negative. It means we can make our library nicer to install and use, which hopefully will encourage more users to install and use it...
+ add a dedicated command "cabal", which does nothing more than "runhaskell Setup", but is more memorable and suggestive
Did you mean an executable that comes with cabal or the compiler (i.e. in ghc's bin), or something provided by the library author? From my POV (as a library author) I could provide a cabal.bat (for Windows users) and a cabal.sh (for everyone else), but that seems a bit messy.
- cabal/darcs/haddock are no replacement for minimal help texts: cabal should require the existence of a README (darcs should complain if there is a *.cabal, but no README..).
Yes. I will create one of these.
- sample code for "trivial queries" (aka, I know about databases, but I need to see the way this particular library handles things, so that I can figure out whether it is the right one for me) is not obvious to find
We have made a reasonable effort in Takusen to document the API extensively, and give example code. The problem seems to be that the documentation is too well hidden: http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html The best thing I can think of now is to put a reference to this in the README file. Any other ideas? I wanted to keep the documentation in Haddock (so that it stays close to, and hopefully consistent with, the source) but maybe that's not the best idea for this kind of documentation, which is really a HOW-TO manual.
- distributions are bare-boned:
Option 2, Takusen, leads to a file listing, but no
downloadable package.
My fault for not providing a proper release. I'm still learning about darcs, so the instructions in http://www.haskell.org/haskellwiki/How_to_write_a_Haskell_program#Releas es are quite valuable. If you have any further Takusen-specific questions, don't hesitate to contact me. Also, if you're having trouble installing or chasing down dependent libraries then I should be able to help. 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. *****************************************************************

On 12/12/06, Claus Reinke
if you're using Haskell at all, you *are* the Haskell community.
[..lots of "I searched, I found, I tried, I got this error, I thought, I tried this workaround, I got to this point, now I'm stuck here..]
I just wanted to comment that I find this kind of "experience report" very helpful, especially if someone does not give up at the first hurdle, and goes through the trouble of writing up all the frustrating steps and thoughts rather than summarizing ("it didn't work"/"I got it to work after some fiddling") - thanks!
Thank you! That's exactly the sort of report I was trying to give,
although (from my point of view) it's pretty hard to report this sort
of thing without feeling like you're giving a complaining and
ungrateful impression. It's nice to have the reassurance that I got my
message across.
On 12/12/06, Bayley, Alistair
Yes, this is embarrasing. We have made a number of assumptions which Paul exposed:
It's hardly embarrassing - as Claus pointed out, the developers of any package are *always* too close to the problem to see this sort of issue.
- users should know to do darcs get, then runhaskell Setup.hs configure/build/install - users should know to look for Haddock docs - users should know how to look for and install dependent libraries (Cabal-1.1.6.1, in this case)
Yes, those are probably the key ones I tripped up on.
If you're an experienced Haskell programmer then these assumptions are valid, so yes, we do need to do more for the novice.
One thing that (from my POV as a Windows user) helped enormously in the Python community was adding the ability to distutils (their Cabal equivalent) to build Windows binary installers. With that, it became relatively easy for developers to package up binaries of their libraries, which made the Windows experience a simple "download and run" one. I've no idea if that is a practical or useful goal for Cabal, and I anticipate it being a long time before I'm at a level of understanding where I could help in implementing it, but it may be something to think about.
- sample code for "trivial queries" (aka, I know about databases, but I need to see the way this particular library handles things, so that I can figure out whether it is the right one for me) is not obvious to find
We have made a reasonable effort in Takusen to document the API extensively, and give example code. The problem seems to be that the documentation is too well hidden: http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html
Yes, I suspect that's the case.
The best thing I can think of now is to put a reference to this in the README file. Any other ideas? I wanted to keep the documentation in Haddock (so that it stays close to, and hopefully consistent with, the source) but maybe that's not the best idea for this kind of documentation, which is really a HOW-TO manual.
Something as simple as "here's how to issue a query and print the results" in the README would have been enough for me. When I get to that point, I'll write a few lines and let you see what you think.
If you have any further Takusen-specific questions, don't hesitate to contact me. Also, if you're having trouble installing or chasing down dependent libraries then I should be able to help.
Thanks for the offer. As others have pointed out, the level of help available from "the community" is excellent - it's just that needing to ask for help puts off those of us who work on a "let's just play with this Haskell stuff while my backup runs" basis :-) The backup has finished now, so I must run. Thanks again! Paul.

Hello Paul, Tuesday, December 12, 2006, 1:35:52 PM, you wrote:
Thank you! That's exactly the sort of report I was trying to give, although (from my point of view) it's pretty hard to report this sort of thing without feeling like you're giving a complaining and ungrateful impression. It's nice to have the reassurance that I got my message across.
we are very interested in such sort of reports because it enlightens information that is considered as self-evident, but not so evident for new haskellers -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Hello Alistair, Tuesday, December 12, 2006, 12:50:43 PM, you wrote:
I guess I should comment, as one of the Takusen authors.
Yes, this is embarrasing. We have made a number of assumptions which Paul exposed: - users should know to do darcs get, then runhaskell Setup.hs configure/build/install - users should know to look for Haddock docs - users should know how to look for and install dependent libraries (Cabal-1.1.6.1, in this case)
If you're an experienced Haskell programmer then these assumptions are valid, so yes, we do need to do more for the novice.
these steps are standard for any haskell library and it's really sort of knowledge that is spread in air. can someone just put this into wiki? there is a great wikipage on creating your own library, thanks to Donald, who is started it. but there is no even simpler page about using libraries. while we don't have cabal-get it will be great to setup such page -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

bulat.ziganshin:
Hello Alistair,
Tuesday, December 12, 2006, 12:50:43 PM, you wrote:
I guess I should comment, as one of the Takusen authors.
Yes, this is embarrasing. We have made a number of assumptions which Paul exposed: - users should know to do darcs get, then runhaskell Setup.hs configure/build/install - users should know to look for Haddock docs - users should know how to look for and install dependent libraries (Cabal-1.1.6.1, in this case)
If you're an experienced Haskell programmer then these assumptions are valid, so yes, we do need to do more for the novice.
these steps are standard for any haskell library and it's really sort of knowledge that is spread in air. can someone just put this into wiki?
there is a great wikipage on creating your own library, thanks to Donald, who is started it. but there is no even simpler page about using libraries. while we don't have cabal-get it will be great to setup such page
The wiki can be edited by anyone! Start now! -- Don

On 12/12/06, Donald Bruce Stewart
bulat.ziganshin:
there is a great wikipage on creating your own library, thanks to Donald, who is started it. but there is no even simpler page about using libraries. while we don't have cabal-get it will be great to setup such page
The wiki can be edited by anyone! Start now!
My plan is to write up what I end up doing (plus some notes on my false starts, if they seem helpful) on the wiki. I'll probably add a new page off the "Libraries and Tools" page - does that sound reasonable? I have to admit that I haven't found the obvious place on the wiki for this yet - I'm familiar with wikis in general, but the structure of the Haskell wiki is a bit hard to get to grips with. That's not a very helpful comment, because I can't articulate *why* I feel this :-( As a data point, the old Haskell wiki felt a bit easier to navigate - maybe because it was less structured in some way. Paul.

We have made a number of assumptions which Paul exposed: - users should know to do darcs get, then runhaskell Setup.hs configure/build/install - users should know to look for Haddock docs - users should know how to look for and install dependent libraries (Cabal-1.1.6.1, in this case)
and there you have the beginnings of your README file!-)
If you're an experienced Haskell programmer then these assumptions are valid, so yes, we do need to do more for the novice.
the difference, as far as it is relevant for getting going, is often just context, which can be rectified by surprisingly small steps, such as collecting the assumptions in one obvious-to-find file.
+ add a dedicated command "cabal", which does nothing more than "runhaskell Setup", but is more memorable and suggestive
Did you mean an executable that comes with cabal or the compiler
yes, part of the cabal infrastructure, not something from the library author. as Simon has pointed out, "cabal-setup" is going to do the job, and with a more descriptive name. thanks, claus

On 12/12/06, Claus Reinke
the difference, as far as it is relevant for getting going, is often just context, which can be rectified by surprisingly small steps, such as collecting the assumptions in one obvious-to-find file.
Indeed. I can now confirm that it's *not* hard to get takusen set up - it's just a bit hard to find out it's not hard :-) Paul

[trimmed replies] On 12/12/06, Paul Moore
On 12/12/06, Claus Reinke
wrote: the difference, as far as it is relevant for getting going, is often just context, which can be rectified by surprisingly small steps, such as collecting the assumptions in one obvious-to-find file.
Indeed. I can now confirm that it's *not* hard to get takusen set up - it's just a bit hard to find out it's not hard :-)
If you generalize from "takusen" there, I think you'll understand a lot about Haskell :-) Cheers, Kirsten -- Kirsten Chevalier* chevalier@alum.wellesley.edu *Often in error, never in doubt "Dare to be naive."--R. Buckminster Fuller

Claus Reinke wrote:
cabal: - the separation into interpreter/compiler and resource as Setup does not set up the right mindset in users. for instance, you can "runhaskell Setup.hs --help" as for most unixy tools, but who'd think of that in this situation, and how much does it help?
+ add a dedicated command "cabal", which does nothing more than "runhaskell Setup", but is more memorable and suggestive
cabal-setup does this, but wasn't included with the latest release of Cabal. It should be in the next one, I hope. The plan is to deprecate 'runhaskell Setup.lhs' in favour of 'cabal-setup'. Feel free to suggest changing the name to 'cabal', although some might argue that 'cabal-get' is the high-level tool and should therefore get the name 'cabal' instead.
- cabal/darcs/haddock are no replacement for minimal help texts: cabal should require the existence of a README
absolutely, this has occurred to me too. There should be a stanard Cabal README file, and Don's mkcabal tool could drop it in the tree. Cheers, Simon

simonmarhaskell:
Claus Reinke wrote:
cabal: - the separation into interpreter/compiler and resource as Setup does not set up the right mindset in users. for instance, you can "runhaskell Setup.hs --help" as for most unixy tools, but who'd think of that in this situation, and how much does it help?
+ add a dedicated command "cabal", which does nothing more than "runhaskell Setup", but is more memorable and suggestive
cabal-setup does this, but wasn't included with the latest release of Cabal. It should be in the next one, I hope. The plan is to deprecate 'runhaskell Setup.lhs' in favour of 'cabal-setup'. Feel free to suggest changing the name to 'cabal', although some might argue that 'cabal-get' is the high-level tool and should therefore get the name 'cabal' instead.
- cabal/darcs/haddock are no replacement for minimal help texts: cabal should require the existence of a README
absolutely, this has occurred to me too. There should be a stanard Cabal README file, and Don's mkcabal tool could drop it in the tree.
This occurred to me too. My current plan for mkcabal is that it creates: foo.cabal Setup.lhs README LICENSE based on a series of interactive questions, or command line args. -- Don

absolutely, this has occurred to me too. There should be a stanard Cabal README file, and Don's mkcabal tool could drop it in the tree.
This occurred to me too. My current plan for mkcabal is that it creates:
foo.cabal Setup.lhs README LICENSE
based on a series of interactive questions, or command line args.
is mkcabal going to be a standard part of cabal installations? btw, here is some suggested text for the useful "how to write.." page you started (I know it is a wiki, but I don't want to mess up the page at this point;-). thanks, claus -------------------------------------------- 0. The intended user experience When Haskell programmers go out in search of existing functionality, be it a library, a tool, or an application, the intended approach is roughly this: 1 visit haskell.org, 2 find the library/program they are looking for (if not found, try mailing list; if it is hidden, try improving haskell.org; if it does not exist, try contributing code/documentation/requirements/..) 3 download 4 install 5 enjoy but each of these steps is endangered by several potential road blocks, and code authors can do a lot to help code users avoid such blocks. Even if steps 1/2 are successful, and ensuring step 5 is the main concern of code authors and users, it is often steps 3/4 that get in the way: - which is the latest version? what state is it in? is it still maintained/in use? - what are its aims? where is the documentation? - which is the right version for given OS and Haskell implementation? - how is it packaged, and what tools are needed to get and unpack it? - how is it installed, and what tools are needed to install it? - how do we avoid IDR (infinite dependency recursion)? - how do we provide/acquire the knowledge and tool-chains needed? There is a well-established tradition for communicating the answers to these questions: the README text file, placed in a prominent position at the code's location (these days often accompanied, but not replaced, by a more extensive web page). But as other communities, the Haskell community has Haskell-specific answers to many of these questions, independent of the particular Haskell code to publish. This document is all about how to publish your Haskell code in such a way as to make the Haskell code users' experience as smooth as possible. Until there is a version of this text targetted more specifically at code users, they might find it helpful to browse this page for insights into the Haskell code authors' mind- and tool-set.

claus.reinke:
absolutely, this has occurred to me too. There should be a stanard Cabal README file, and Don's mkcabal tool could drop it in the tree.
This occurred to me too. My current plan for mkcabal is that it creates:
foo.cabal Setup.lhs README LICENSE
based on a series of interactive questions, or command line args.
is mkcabal going to be a standard part of cabal installations?
btw, here is some suggested text for the useful "how to write.." page you started (I know it is a wiki, but I don't want to mess up the page at this point;-).
Thanks Claus. I've added this text to the page: http://haskell.org/haskellwiki/How_to_write_a_Haskell_program#Guidelines_for... -- Don

Simon Marlow wrote:
+ add a dedicated command "cabal", which does nothing more than "runhaskell Setup", but is more memorable and suggestive
cabal-setup does this, but wasn't included with the latest release of Cabal. It should be in the next one, I hope. The plan is to deprecate 'runhaskell Setup.lhs' in favour of 'cabal-setup'. I'm possibly using cabal in a simplistic way, but I generally do either
./Setup.lhs configure -p ./Setup.lhs build ./Setup.lhs install or ./Setup.lhs configure -p --prefix=$HOME --user ./Setup.lhs build ./Setup.lhs install --user #perhaps not needed anymore? This is a lot of typing, and at least once I wrote a Makefile to automate it (oh, the irony of it!) Anyway, it would be nice if a 'cabal' command automated the whole sequence in one go, at least as an option. -k

On 12/12/06, Ketil Malde
I'm possibly using cabal in a simplistic way, but I generally do either
./Setup.lhs configure -p ./Setup.lhs build ./Setup.lhs install [...] This is a lot of typing, and at least once I wrote a Makefile to automate it (oh, the irony of it!) Anyway, it would be nice if a 'cabal' command automated the whole sequence in one go, at least as an option.
I come from a Python background, and Python's distutils (which feels very like cabal - or should that be the other way round?) tends to have later commands include earlier ones. So, setup.py install automatically does "build" (there is no explicit configure step). Distutils tracks changes somehow (probably by file timestamp) to avoid rerunning builds when not needed. Could cabal do that? I find it hard to see why someone would want to do "install" without having done an up to date "build". Paul.

Paul Moore wrote:
On 12/12/06, Ketil Malde
wrote: I'm possibly using cabal in a simplistic way, but I generally do either
./Setup.lhs configure -p ./Setup.lhs build ./Setup.lhs install
[...]
This is a lot of typing, and at least once I wrote a Makefile to automate it (oh, the irony of it!) Anyway, it would be nice if a 'cabal' command automated the whole sequence in one go, at least as an option.
I come from a Python background, and Python's distutils (which feels very like cabal - or should that be the other way round?) tends to have later commands include earlier ones. So,
setup.py install
automatically does "build" (there is no explicit configure step).
Sounds entirely reasonable to me. Though configure takes a bunch of arguments; so if configure is run automatically it'll always be with the default settings. Maybe that's ok. Simon

Hi
have later commands include earlier ones. So,
setup.py install
automatically does "build" (there is no explicit configure step).
Sounds entirely reasonable to me. Though configure takes a bunch of arguments; so if configure is run automatically it'll always be with the default settings. Maybe that's ok.
I would love this. I have a batch file on my computer called cabal-ghc, which does a configure, then a build, then an install. I've never felt the need to pass flags to configure, and as it happens, I wouldn't have a clue what flags to pass in anyway. This reduces the number of cabal steps to install a library, less is clearly better! I also have cabal-hugs which installs the library under hugs, and cabal-all, which configure/build/install's the library under hugs and ghc. Those 6 commands are really annoying, this way i can do cabal-all and go away and come back later. Thanks Neil

Hello Paul, Tuesday, December 12, 2006, 4:48:55 PM, you wrote:
./Setup.lhs configure -p ./Setup.lhs build ./Setup.lhs install
I come from a Python background, and Python's distutils (which feels very like cabal - or should that be the other way round?) tends to have later commands include earlier ones. So,
i suggest you to write simple script that automates this. i've attached makefile which i include with all my libs that does this - you need to run only "make install". i propose to all library developers to include such makefile with their libs -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Paul The people you want are probably HDBC John Goerzen [jgoerzen@complete.org] HaskellDB Anders Höckersten [chucky@dtek.chalmers.se] and Bjorn Bringert [d00bring@dtek.chalmers.se] HSQL Krasimir Angelov [ka2_mail@yahoo.com] Takusen Bayley, Alistair [Alistair_Bayley@ldn.invesco.com] (did I miss any?) They probably haven't been online since your msg, but I'm sure they'll be keen to help you use the fruit of their labours -- and would welcome your help in documenting them better. You might also find help on the #haskell IRC channel. Simon | OK, thanks for the gentle push. After a bit of digging, I decided that | the takusen link looked like a darcs repository, and I downloaded | darcs and got takusen. I installed GHC 6.6 in a spare VM (no PC round | I can install stuff on just now, I'll do this properly later). On the | assumption that the takusen.cabal file means I should look at Cabal, I | had a dig and found the incantation "runhaskell setup.hs".

Hi Paul, as Simon notes, I maintain HaskellDB. I think that HaskellDB isn't exactly what you are looking for at the moment. You seem to want to run SQL queries, and HaskellDB is designed to free you from writing SQL. I'm not sure if anyone has mentioned it yet, but HSQL 1.7 includes Oracle support (though I haven't tested it). You can get it from http://sourceforge.net/project/showfiles.php? group_id=65248&package_id=93958 Here's what I would do in your situation: 1. Join the #haskell IRC channel on irc.freenode.net. 2. Try to install your chosen library. 3. Ask questions in the IRC channel when you run into problems. Chances are that you will have some library and Cabal developers there to help you. /Björn On 12 dec 2006, at 10.11, Simon Peyton-Jones wrote:
Paul
The people you want are probably
HDBC John Goerzen [jgoerzen@complete.org]
HaskellDB Anders Höckersten [chucky@dtek.chalmers.se] and Bjorn Bringert [d00bring@dtek.chalmers.se]
HSQL Krasimir Angelov [ka2_mail@yahoo.com]
Takusen Bayley, Alistair [Alistair_Bayley@ldn.invesco.com]
(did I miss any?)
They probably haven't been online since your msg, but I'm sure they'll be keen to help you use the fruit of their labours -- and would welcome your help in documenting them better. You might also find help on the #haskell IRC channel.
Simon
| OK, thanks for the gentle push. After a bit of digging, I decided that | the takusen link looked like a darcs repository, and I downloaded | darcs and got takusen. I installed GHC 6.6 in a spare VM (no PC round | I can install stuff on just now, I'll do this properly later). On the | assumption that the takusen.cabal file means I should look at Cabal, I | had a dig and found the incantation "runhaskell setup.hs".

Paul Moore on 2006-12-11 22:46:44 +0000:
What I *can* do, is to attempt to install one of the libraries that looks closest to what I want (probably HDBC, because I'm familiar with the Python DB-API). But I honestly have little or no idea how to start - following the HDBC link on the Haskell Wiki leads to a huge list of tar.gz files, with no indication of which one I might want :-(
Option 2, Takusen, leads to a file listing, but no downloadable package.
Option 3, HSQL, leads to a page which doesn't mention Oracle support (even though the Wiki page does) so I'm put off trying further...
I believe HSQL provides a similar interface to the the Python DB-API, but you're right, I don't believe anyone has written Oracle support.

On Mon, 11 Dec 2006 22:46:44 +0000, Paul Moore wrote:
What I *can* do, is to attempt to install one of the libraries that looks closest to what I want (probably HDBC, because I'm familiar with the Python DB-API). But I honestly have little or no idea how to start - following the HDBC link on the Haskell Wiki leads to a huge list of tar.gz files, with no indication of which one I might want :-(
You're right, and that's my fault, and something I hope to fix this weekend. In the interim, you will want the latest hdbc_*.tar.gz file, then the latest hdbc-odbc_*.tar.gz file. You will connect to Oracle using the ODBC backend for HDBC. I can't help you set up your Oracle ODBC drivers, but once you have that going, connecting up to it should be fairly trivial. As far as example code goes, I've written a few programs that use HDBC. Check out DB.hs in hpodder (http://software.complete.org/hpodder) or gopherbot (http://darcs.complete.org/gopherbot). -- John

Hello,
1. Simple documentation of how to install the library (starting from a vanilla GHC installation on Windows, plus Oracle software, to the point where I can use the library in my code). All I need is Oracle access, so other database client libraries can be ignored. I'd rather not use ODBC, but will if required.
I use HDBC to connect (via the ODBC driver) to a MS SQL Server and a Sybase server (ASE). I'm running on a windows machine inside of cygwin. I had no trouble installing HDBC following the instructions in the distribution with GHC 6.6; by distribution I mean the files hdbc_1.0.1.2.tar.gz (general HDBC library) and hdbc-odbc_1.0.1.1.tar.gz (specific ODBC driver) from the HDBC gopher page (http://gopher.quux.org:70/devel/hdbc).
2. Simple examples on how to actually run a query. For example, how do I code the follwing SQL*Plus code (should be pretty self-explanatory) in Haskell:
connect scott/tiger@mydb select * from emp;
Here is a GHCi session: Prelude> :m Database.HDBC Database.HDBC.ODBC Prelude Database.HDBC.ODBC Database.HDBC>do c <- connectODBC conStr; handleSqlError $ quickQuery c "select * from emp" [] where conStr is an appropriate ODBC connection string (e.g. "DSN = mydb" if you have the DSN defined, or you can find the Oracle string at http://www.connectionstrings.com/). This should cause a list of lists of SqlValues to be printed which represent the rows in your result set. Here is the documentation for HDBC: http://darcs.complete.org/hdbc/doc/Database-HDBC.html Although it is mostly type signatures, there is some explanation. There are also a few useful haskell-cafe discussions on aspects of using HDBC. hope this helps, Jeff
participants (17)
-
Alec Berryman
-
Bayley, Alistair
-
Bjorn Bringert
-
Bulat Ziganshin
-
Claus Reinke
-
dons@cse.unsw.edu.au
-
jeff p
-
John Goerzen
-
Ketil Malde
-
Kirsten Chevalier
-
Neil Mitchell
-
Paul Moore
-
Seth Gordon
-
Simon Marlow
-
Simon Peyton-Jones
-
Stefan O'Rear
-
Taral