Marc

What is this strange syntax

columns = [ ("trackId", conT ''Int )

It looks like a not ended string literal unless I still have sth to learn about Haskell.

Thank you

J-C



On Thu, Sep 25, 2008 at 12:03 AM, Marc Weber <marco-oweber@gmx.de> wrote:
On Wed, Sep 24, 2008 at 11:17:01PM +0200, Manlio Perillo wrote:
>  Hi.
>
>  I need a simple, concurrent safe, database, written in Haskell.
>  A database with the interface of Data.Map would be great, since what I need
>  to to is atomically increment some integer values, and I would like to avoid
>  to use SQLite.

I've tried writing at least part of that. But it's still higly
experimental and uses template haskell.
It looks like this:
from that some datastructures are defined which look like
tables used in traditional RDBMS such as SQLite..
However if you don't want to use many "tables" you may be a lot faster
writing down what you need yourself. My lib automacially generates code
for inserting / deleting tuples into multi indexes such as (Map Int (Map
Int PrimIdx)).

$(let cds = defaultTable {
               tblName = "cds"
               , columns = [ ("cdId", conT ''Int) , ("title", conT ''Int) ]
               , primary = PrimaryUniq [ "cdId" ] [| 0 |]
               , indexes = [ Index "title" [] ]
               , tblStates = [ ( "nextCdId", [t| Int |], [| 0 |] ) ]
           }

     tracks = let
            a="a"
            -- updateNumRows n = [| \n -> cdUpdateByPK (\r -> r { num_tracks = (num_tracks r) + $(n) } ) |]
            in defaultTable {
            tblName = "tracks"
            , columns = [ ("trackId", conT ''Int )
                      , ("name", conT ''String)
                      , ("cd", conT ''Int) -- foreign key
                      ]
            , primary = PrimaryUniq [ "cd", "trackId" ] [| 0 |]
            , indexes = [ Index "cd" [ IndexUnique "trackId" ] ] --the id is uniq foreach cd
            -- checks = [ foreignConstraint "cd" "cds" "id" ]
            -- triggers =  [ InsertUpdate  (Just ["cd"]) [| cdUpdateByPK ( updateNum_tracks (+1) ) . pk |]
                          -- DeleteUpdate  (Just ["cd"]) [| cdUpdateByPK ( updateNum_tracks (-1) ) . pk |]
                          -- ]
                }
     db = defaultDB {
             dbName = "my"
           , tables = [ cds, tracks]
           , statistics = True
           }
 in createDB db)


If you're interested drop me a mail.

Marc
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe