<div dir="ltr">Marc <br><br>What is this strange syntax<br><br> columns = [ (&quot;trackId&quot;, conT <b><u>&#39;&#39;Int</u></b> )<br><br>It looks like a not ended string literal unless I still have sth to learn about Haskell.<br>
<br>Thank you<br><br>J-C<br><br><br><br><div class="gmail_quote">On Thu, Sep 25, 2008 at 12:03 AM, Marc Weber <span dir="ltr">&lt;<a href="mailto:marco-oweber@gmx.de">marco-oweber@gmx.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Wed, Sep 24, 2008 at 11:17:01PM +0200, Manlio Perillo wrote:<br>
&gt; &nbsp;Hi.<br>
&gt;<br>
&gt; &nbsp;I need a simple, concurrent safe, database, written in Haskell.<br>
&gt; &nbsp;A database with the interface of Data.Map would be great, since what I need<br>
&gt; &nbsp;to to is atomically increment some integer values, and I would like to avoid<br>
&gt; &nbsp;to use SQLite.<br>
<br>
</div>I&#39;ve tried writing at least part of that. But it&#39;s still higly<br>
experimental and uses template haskell.<br>
It looks like this:<br>
from that some datastructures are defined which look like<br>
tables used in traditional RDBMS such as SQLite..<br>
However if you don&#39;t want to use many &quot;tables&quot; you may be a lot faster<br>
writing down what you need yourself. My lib automacially generates code<br>
for inserting / deleting tuples into multi indexes such as (Map Int (Map<br>
Int PrimIdx)).<br>
<br>
$(let cds = defaultTable {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tblName = &quot;cds&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;, columns = [ (&quot;cdId&quot;, conT &#39;&#39;Int) , (&quot;title&quot;, conT &#39;&#39;Int) ]<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;, primary = PrimaryUniq [ &quot;cdId&quot; ] [| 0 |]<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;, indexes = [ Index &quot;title&quot; [] ]<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;, tblStates = [ ( &quot;nextCdId&quot;, [t| Int |], [| 0 |] ) ]<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp;tracks = let<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a=&quot;a&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -- updateNumRows n = [| \n -&gt; cdUpdateByPK (\r -&gt; r { num_tracks = (num_tracks r) + $(n) } ) |]<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; in defaultTable {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tblName = &quot;tracks&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , columns = [ (&quot;trackId&quot;, conT &#39;&#39;Int )<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , (&quot;name&quot;, conT &#39;&#39;String)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , (&quot;cd&quot;, conT &#39;&#39;Int) -- foreign key<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , primary = PrimaryUniq [ &quot;cd&quot;, &quot;trackId&quot; ] [| 0 |]<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , indexes = [ Index &quot;cd&quot; [ IndexUnique &quot;trackId&quot; ] ] --the id is uniq foreach cd<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -- checks = [ foreignConstraint &quot;cd&quot; &quot;cds&quot; &quot;id&quot; ]<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -- triggers = &nbsp;[ InsertUpdate &nbsp;(Just [&quot;cd&quot;]) [| cdUpdateByPK ( updateNum_tracks (+1) ) . pk |]<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -- DeleteUpdate &nbsp;(Just [&quot;cd&quot;]) [| cdUpdateByPK ( updateNum_tracks (-1) ) . pk |]<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -- ]<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; &nbsp;db = defaultDB {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dbName = &quot;my&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;, tables = [ cds, tracks]<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;, statistics = True<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
 &nbsp;in createDB db)<br>
<br>
<br>
If you&#39;re interested drop me a mail.<br>
<font color="#888888"><br>
Marc<br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div>