[Haskell] ANNOUNCE: HaskellDB 2.0: Scrap your SQL strings

2010-10-08 Thread Justin Bailey
What is it?


The HaskellDB library lets you generate SQL queries without writing
any actual SQL. Unlike other query generating libraries, you choose
the abstraction level. Queries can be built out of independent
fragments, just like your programs. Leave hand-written, string-based,
SQL libraries behind and check out HaskellDB.

Where to get it?


You can get it  from Hackage
(http://hackage.haskell.org/package/haskelldb) or by using cabal
(cabal install haskelldb).

You also need drivers for your specific database. HaskellDB currently
supports the HDBC family of drivers. First, download haskelldb-hdbc
(http://hackage.haskell.org/package/haskelldb-hdbc), then get the
appropriate package  for your database:

  * ODBC: haskelldb-hdbc-odbc
(http://hackage.haskell.org/package/haskelldb-hdbc-odbc)
  * Postgres: haskelldb-hdbc-postgresql
(http://hackage.haskell.org/package/haskelldb-hdbc-postgresql)
  * Sqllite: haskelldb-hdbc-sqlite3
(http://hackage.haskell.org/package/haskelldb-hdbc-sqlite3)

Documentation, Mailing List, Source, etc
===

Go to http://trac.haskell.org/haskelldb for detailed information.

What's New?
=

  * New query capabilities: stored procedures, CASTs, query
parameters, constants, and more.
  * Postgres SQL improvements.
  * Bug fixes around AND and OR associativity.
  * Query optimization improvements around aggregate expressions.
  * More tests.

Details
=

Back in June 2009, Bjorn Bringert passed maintainership of HaskellDB
to me. I've been working this summer to get a release out, which
included:

  * Adding an examples/ directory to the source distribution.
  * Archiving and consolidating information to
http://trac.haskell.org/haskelldb.
  * Accepting patches for various issues.

I have used a lot of ORM & SQL-wrapper libraries during my career and
HaskellDB is the first that I've found which does not require you to
eventually break the abstraction.

Learning to use the the library was a fun challenge but not one that
many people are willing to take, when they can easily write SQL by
hand. If the library was easier to get started with, I think it would
be much more widely used. Help me get HaskellDB better documentation!

If you are using HaskellDB and want to help: go to
http://trac.haskell.org/haskelldb and write an article, write a blog
post, get in touch with me, etc. When I saw that Rails 3.0 uses the
"ARel" gem (based on the relational algebra) I groaned - Haskell has
had that forever! We need to get the word out!

Why 2.0?
--

Last year Brian Bloniarz contributed an awesome patch which replaced
HaskellDB's home-grown record system with the HList library by Oleg
Kiselyov (and colleagues). I intended to work with the library for
awhile and get a 1.0 release out.

Unfortunately, HList proved too daunting for GHC and for me. Compile
times went way up, and I could not isolate it enough to give GHC HQ a
repro case. Even worse, HList required too many Oleg units for me to
comprehend. I could usually fix compile errors, but found myself
struggling to extend HaskellDB's functionality. In the end I felt I
needed to back the patch out. I really hated to lose some of the
functionality but in the end maintainability won out. At that point I
had pushed a few patches with a v1.0 cabal file, so I thought it best
to make this release 2.0.

Who am I?
---

I started using HaskellDB in early 2009. I use it more as a
query-generating library than for executing SQL statements. I have
written a largish system for generating a data-access layer in PHP
from query descriptions in HaskellDB. Yes, I'm using Haskell to write
PHP ... dirty!

Unmaintained & Unrelated Packages
-

A couple of haskelldb related packages on Hackage are not maintained by me:

  * haskelldb-hdbc-mysql - This project was created and uploaded
independent of me. Contact the author for specifics. However, the
haskelldb-hdbc-odbc library is maintained by me and can be used to
talk to MySQL.
  * HSQL (haskelldb-hsql, etc)  - I cannot get this backend to compile
on my platform. HSQL seems unmaintained so I have let the drivers
decay. You'll notice I have not uploaded new packages or changed their
version dependencies.
  * haskelldb-flat and haskelldb-dynamic - Both of these packages have
suffered serious bitrot and are not maintained any longer.
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Building a library for C users

2009-07-28 Thread Justin Bailey
You should be able to find information on this in the haskell wiki
(www.haskell.org). Searching for "foreign" will probably bring it up.

You'll probably end up having to link a static library - GHC doesn't
yet produce dynamic libraries, though there is work in that area going
on right now. Look for the "Industrial Haskell Group" blog for more.

On Mon, Jul 27, 2009 at 2:46 AM, Thomas Davie wrote:
> Hiya all,
>  I'm trying to build a library that can be called from C code.  The ghc
> manual implies that this can be done, but does not specify the compiler
> options that I need to throw at it, and into which files I should put
> initialisation/end routines.  Does anyone know the magic I need to invoke to
> get ghc to produce for me (a) a header file, (b) preferably a dynamic
> library, put a static one if all else fails.
>
> Thanks
>
> Tom Davie
> ___
> Haskell mailing list
> Haskell@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] ANNOUNCE: HCL v1.0 -High-level library for building command line interfaces

2007-07-09 Thread Justin Bailey

I'm please to announce HCL 1.0 - a library for building command line
interfaces. The library exports a mix of low and high-level functions
for building programs which gather simple values, ask yes/no
questions, or present hierarchical menus. The library is not intended
to do complex, full-screen UIs ala ncurses - it is intended for
line-oriented interfaces.

Included with the library is a hangman game, so if nothing else you
can enjoy that.

Where do I get it?
=

Download from Hackage at:

 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HCL-1.0

How do I use it it?
=

It's Cabal-ized so, after downloading and unpacking:

 runghc Setup.hs configure
 runghc Setup.hs build
 runghc Setup.hs install

Note I had some inconsistent results building with HEAD cabal, but the
version distributed with GHC works great (1.1.6.2).

To play hangman, execute 'hangman'. Once installed, you can look at it
in GHCi by loading the "HCL" module.

Tell me more!
==

This library lets you do a lot of cool things. For example, here's a
simple guess a number game:

guess_num_fun =
  do
target <- reqIO $ getStdRandom (randomR (1::Integer,100))
let guessed val =
  case compare target val of
GT -> do { reqIO $ putStrLn "Too low!"; return False }
LT -> do { reqIO $ putStrLn "Too high!"; return False }
EQ -> do { reqIO $ putStrLn "You win!"; return True }
reqUntil guessed (prompt "Enter a number between 1 and 100: "
reqInteger)

"reqUntil" takes a predicate and asks for a response until the
predicate is true. In the case above, the user is asked to enter an
integer. Once they guess the number, the program ends.

The library makes it easy to gather structured values. For example,
imagine this data structure:

 data Taxpayer = Taxpayer { name :: String, age :: Int, ssn :: String }
deriving (Read, Show)

One way to use HCL to get Taxpayer values from the user is to take
advantage of its Read instance:

reqTaxpayer :: Request Taxpayer
reqTaxpayer = prompt "Please enter tax payer information: " (reqRead reqResp)

But that is ugly because the user has to type a "Read"-able string:

> getTaxpayer reqTaxpayer
Please enter tax payer information: Taxpayer {name="John", age = 30, ssn = "" }

However, we can build a form of sorts and make life much easier for the user:

reqTaxpayerEasy :: Request Taxpayer
reqTaxpayerEasy =
  do
name <- prompt "Please enter the tax payer's name: " reqResp
age <- prompt "Please enter their age: " reqInt
ssn <- prompt "What is their SSN/ASN: " reqResp
return (Taxpayer name age ssn)

Which looks like this:

> getTaxpayer reqTaxpayerEasy
Please enter the tax payer's name: Bob
Please enter their age: 50
Please enter their SSN/ASN: 111-11-

The library also makes simple hierarchical menus easy to build. The
below defines the menu structure for a hypothetical PIM:

  reqMenu $
  reqSubMenu topMenu "Manage contacts" manageContactsMenu $
  reqSubMenu topMenu "Manage calendar"
(reqMenuItem "Add an event" ... $
  ...
  reqMenuExit "Return to previous menu"
  reqMenuEnd) $
  -- End the menu definition
  reqMenuEnd

-- Defines a partial menu
manageContactsMenu =
  reqMenuItem "Add a contact" ... $
  ...
  reqMenuExit "Return to previous menu"
  reqMenuEnd

These and more examples are distributed with the library in the
examples directory.

Anything else?
===

Feedback, praise and criticism are welcome. Feedback regarding
'idiomatic' usage is especially desired. This is a first for me so any
responses are appreciated.

The library was developed on Windows using GHC - please let me know of
any odd *nix and Hugs bugs.

This library was inspired in part by the Ruby HighLine library
(http://highline.rubyforge.org/).  Many thanks Mark Jones for his
input on HCL's design and implementation.
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell