<br><font size=2 face="sans-serif">Hello,</font>
<br>
<br><tt><font size=2>&gt; dbCreateIndices con dtn dof = do<br>
&gt; &nbsp; &nbsp;let dummy = newDbItem<br>
&gt; &nbsp; &nbsp;let query = &quot;SELECT id FROM &quot; ++ (dtn dummy)
++ &quot; ORDER BY &quot; ++ (dof dummy)<br>
&gt; &nbsp; &nbsp;ids &lt;- liftM (map fromSql . concat ) $! quickQuery
con query []<br>
&gt; &nbsp; &nbsp;return $ IntMap.fromList $ zip ids [0..]<br>
&gt; <br>
&gt; quickQuery returns a lazy list of results, and I expected ($!) to
make<br>
&gt; it strict. But my program crashes if I use it this way. But, if I
add<br>
&gt; a print to the function:<br>
&gt; </font></tt>
<br><tt><font size=2>When using lazy DB connections in HDBC (I'm assuming
you're using HDBC since quickQuery is the pre-packaged lazy query call
in HDBC), you have to be careful about forcing all the data your'e expecting
from a query on a connection before using the same connection for something
else. As the previous poster mentioned, $! will only evaluate the list
to weak head normal form. Printing out the list will indeed force everything
in the list to be evaluated. </font></tt>
<br>
<br><tt><font size=2>There is an extended discussion of this same issue
(in the context of lazy file io) in this thread from haskell-cafe: </font></tt>
<br><tt><font size=2>&nbsp; &nbsp; http://www.haskell.org/pipermail/haskell-cafe/2007-March/023498.html</font></tt>
<br>
<br><tt><font size=2>-Jeff</font></tt>
<br>
<br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">---</span><br>
<br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">This e-mail may contain confidential and/or privileged information. If you </span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">are not the intended recipient (or have received this e-mail in error) </span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">please notify the sender immediately and destroy this e-mail. Any </span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">unauthorized copying, disclosure or distribution of the material in this </span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">e-mail is strictly forbidden.</span><br>