<p>How about generating a version of the records lifted to Maybe? </p>
<div class="gmail_quote">Am 06.05.2011 04:03 schrieb &quot;Max Cantor&quot; &lt;<a href="mailto:mxcantor@gmail.com">mxcantor@gmail.com</a>&gt;:<br type="attribution">&gt; Personally, I vote against this.  Putting in undefineds maintains type-safety.  However, in my mind the primary purpose of static type-safety is the avoidance of runtime errors.  This only encourages that.  Perhaps a better approach is to have some a TH function to generate &quot;subselects&quot; which would be records that only contain the requested data.  Its a bit more constraining, but I fear that the alternative is tantamount to curing the disease by killing the patient.<br>
&gt; <br>&gt; furthermore, I worry that allowing undefined&#39;s here will start a slippery, runtime-error-laden slope which we&#39;re better off avoiding..<br>&gt; <br>&gt; max<br>&gt; <br>&gt; <br>&gt; <br>&gt; On May 5, 2011, at 9:55 PM, Michael Snoyman wrote:<br>
&gt; <br>&gt;&gt; That&#39;s interesting: I&#39;d never considered the idea of inserting<br>&gt;&gt; undefined into fields you want excluded... That could work. The reason<br>&gt;&gt; I&#39;ve avoided putting in this (often requested) feature is that I could<br>
&gt;&gt; think of no way to do so and keep type safety. That might be an<br>&gt;&gt; approach.<br>&gt;&gt; <br>&gt;&gt; We may consider requiring the user to supply the value instead,<br>&gt;&gt; thereby avoiding the library inserting undefined.<br>
&gt;&gt; <br>&gt;&gt; Michael<br>&gt;&gt; <br>&gt;&gt; On Thu, May 5, 2011 at 4:32 PM, Greg Weber &lt;<a href="mailto:greg@gregweber.info">greg@gregweber.info</a>&gt; wrote:<br>&gt;&gt;&gt; An alternative to laziness would be selecting a subset of fields. There is<br>
&gt;&gt;&gt; no support for this directly in persistent, but it might be possible to add<br>&gt;&gt;&gt; it and the future and have the value of an unselected field be something<br>&gt;&gt;&gt; like undefined.<br>&gt;&gt;&gt; At the moment you can select sub fields by dropping down to lower-level sql<br>
&gt;&gt;&gt; methods (ask Michael about these methods if you are interested). I think<br>&gt;&gt;&gt; there is a technique for building your persistent data structure back up<br>&gt;&gt;&gt; from the return of raw sql, which again you might be able to do by inserting<br>
&gt;&gt;&gt; dummy error fields.<br>&gt;&gt;&gt; Greg Weber<br>&gt;&gt;&gt; <br>&gt;&gt;&gt; On Thu, May 5, 2011 at 4:18 AM, Michael Snoyman &lt;<a href="mailto:michael@snoyman.com">michael@snoyman.com</a>&gt; wrote:<br>&gt;&gt;&gt;&gt; <br>
&gt;&gt;&gt;&gt; On Thu, May 5, 2011 at 1:28 PM, Felipe Almeida Lessa<br>&gt;&gt;&gt;&gt; &lt;<a href="mailto:felipe.lessa@gmail.com">felipe.lessa@gmail.com</a>&gt; wrote:<br>&gt;&gt;&gt;&gt;&gt; On Thu, May 5, 2011 at 2:20 AM, Jeremy Hughes &lt;<a href="mailto:jedahu@gmail.com">jedahu@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt; Is Database.Persistent lazy wrt reading fields? I need to iterate over<br>&gt;&gt;&gt;&gt;&gt;&gt; entities containing both small and large fields. I do not need to use<br>&gt;&gt;&gt;&gt;&gt;&gt; the large fields in this instance, and so would rather they were not<br>
&gt;&gt;&gt;&gt;&gt;&gt; read from the database.<br>&gt;&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt;&gt; IIRC, they are read strictly.  I guess you should put them on a<br>&gt;&gt;&gt;&gt;&gt; different entity.<br>&gt;&gt;&gt;&gt; <br>
&gt;&gt;&gt;&gt; That&#39;s correct. In fact, Persistent avoids any form of lazy I/O to<br>&gt;&gt;&gt;&gt; ensure that database connections are returned to the pool as soon as<br>&gt;&gt;&gt;&gt; possible (amongst other reasons).<br>
&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt; Michael<br>&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt; _______________________________________________<br>&gt;&gt;&gt;&gt; web-devel mailing list<br>&gt;&gt;&gt;&gt; <a href="mailto:web-devel@haskell.org">web-devel@haskell.org</a><br>
&gt;&gt;&gt;&gt; <a href="http://www.haskell.org/mailman/listinfo/web-devel">http://www.haskell.org/mailman/listinfo/web-devel</a><br>&gt;&gt;&gt; <br>&gt;&gt;&gt; <br>&gt;&gt; <br>&gt;&gt; _______________________________________________<br>
&gt;&gt; web-devel mailing list<br>&gt;&gt; <a href="mailto:web-devel@haskell.org">web-devel@haskell.org</a><br>&gt;&gt; <a href="http://www.haskell.org/mailman/listinfo/web-devel">http://www.haskell.org/mailman/listinfo/web-devel</a><br>
&gt; <br>&gt; <br>&gt; _______________________________________________<br>&gt; web-devel mailing list<br>&gt; <a href="mailto:web-devel@haskell.org">web-devel@haskell.org</a><br>&gt; <a href="http://www.haskell.org/mailman/listinfo/web-devel">http://www.haskell.org/mailman/listinfo/web-devel</a><br>
</div>