Great effort!<div><br></div><div>That is a mammoth patch.</div><div>Could you use git add -p to create 2 commits- one with as much of the refactoring as possible, and the other focusing on the additions?</div><div><br></div>

<div>Greg Weber</div><div><br><div class="gmail_quote">On Sun, Mar 20, 2011 at 7:02 PM, Aur Saraf <span dir="ltr">&lt;<a href="mailto:sonoflilit@gmail.com">sonoflilit@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On Tue, Mar 15, 2011 at 2:45 AM, Aur Saraf &lt;<a href="mailto:sonoflilit@gmail.com">sonoflilit@gmail.com</a>&gt; wrote:<br>
&gt; Right now I&#39;m having lots of trouble with the TH code generation. I&#39;ll<br>
&gt; post my code once the first unit tests pass - a lot before it would<br>
&gt; actually be useful - to see what you guys say about my methods. Also,<br>
&gt; there&#39;s a lot of cleaning up - or at least restyling, but I like to<br>
&gt; think it is cleaning up - of TH.hs, which is useful in general.<br>
<br>
</div>At last, my first unit test passes. I have something to show.<br>
<br>
    _join = do<br>
      a &lt;- insert $ Person &quot;Aur&quot; 12 Nothing<br>
      b &lt;- insert $ Person &quot;Bar&quot; 13 $ Just &quot;Blue&quot;<br>
      c &lt;- insert $ Pet a &quot;Mazal&quot; Cat<br>
      d &lt;- insert $ Pet b &quot;Sasha&quot; Dog<br>
      pets &lt;- selectList [PetOwner $ PersonNameEq &quot;Hanners&quot;] [] 0 0<br>
      assertEmpty pets<br>
      pets &lt;- selectList [PetOwner $ PersonNameEq &quot;Aur&quot;] [] 0 0<br>
      assertNotEmpty pets<br>
      return ()<br>
<br>
&quot;BEGIN&quot;<br>
&quot;INSERT INTO \&quot;Person\&quot;(\&quot;name\&quot;,\&quot;age\&quot;,\&quot;color\&quot;) VALUES(?,?,?)&quot;<br>
&quot;SELECT last_insert_rowid()&quot;<br>
&quot;INSERT INTO \&quot;Person\&quot;(\&quot;name\&quot;,\&quot;age\&quot;,\&quot;color\&quot;) VALUES(?,?,?)&quot;<br>
&quot;SELECT last_insert_rowid()&quot;<br>
&quot;INSERT INTO \&quot;Pet\&quot;(\&quot;owner\&quot;,\&quot;nick\&quot;,\&quot;type\&quot;) VALUES(?,?,?)&quot;<br>
&quot;SELECT last_insert_rowid()&quot;<br>
&quot;INSERT INTO \&quot;Pet\&quot;(\&quot;owner\&quot;,\&quot;nick\&quot;,\&quot;type\&quot;) VALUES(?,?,?)&quot;<br>
&quot;SELECT last_insert_rowid()&quot;<br>
&quot;SELECT \&quot;Pet\&quot;.\&quot;id\&quot;,\&quot;Pet\&quot;.\&quot;owner\&quot;,\&quot;Pet\&quot;.\&quot;nick\&quot;,\&quot;Pet\&quot;.\&quot;type\&quot;<br>
FROM \&quot;Pet\&quot; INNER JOIN \&quot;Person\&quot; ON<br>
\&quot;Person\&quot;.\&quot;id\&quot;=\&quot;Pet\&quot;.\&quot;owner\&quot; WHERE \&quot;Person\&quot;.\&quot;name\&quot;=?&quot;<br>
&quot;SELECT \&quot;Pet\&quot;.\&quot;id\&quot;,\&quot;Pet\&quot;.\&quot;owner\&quot;,\&quot;Pet\&quot;.\&quot;nick\&quot;,\&quot;Pet\&quot;.\&quot;type\&quot;<br>
FROM \&quot;Pet\&quot; INNER JOIN \&quot;Person\&quot; ON<br>
\&quot;Person\&quot;.\&quot;id\&quot;=\&quot;Pet\&quot;.\&quot;owner\&quot; WHERE \&quot;Person\&quot;.\&quot;name\&quot;=?&quot;<br>
&quot;COMMIT&quot;<br>
&quot;INSERT INTO \&quot;Person\&quot;(\&quot;name\&quot;,\&quot;age\&quot;,\&quot;color\&quot;) VALUES(?,?,?) RETURNING id&quot;<br>
&quot;INSERT INTO \&quot;Person\&quot;(\&quot;name\&quot;,\&quot;age\&quot;,\&quot;color\&quot;) VALUES(?,?,?) RETURNING id&quot;<br>
&quot;INSERT INTO \&quot;Pet\&quot;(\&quot;owner\&quot;,\&quot;nick\&quot;,\&quot;type\&quot;) VALUES(?,?,?) RETURNING id&quot;<br>
&quot;INSERT INTO \&quot;Pet\&quot;(\&quot;owner\&quot;,\&quot;nick\&quot;,\&quot;type\&quot;) VALUES(?,?,?) RETURNING id&quot;<br>
&quot;SELECT \&quot;Pet\&quot;.\&quot;id\&quot;,\&quot;Pet\&quot;.\&quot;owner\&quot;,\&quot;Pet\&quot;.\&quot;nick\&quot;,\&quot;Pet\&quot;.\&quot;type\&quot;<br>
FROM \&quot;Pet\&quot; INNER JOIN \&quot;Person\&quot; ON<br>
\&quot;Person\&quot;.\&quot;id\&quot;=\&quot;Pet\&quot;.\&quot;owner\&quot; WHERE \&quot;Person\&quot;.\&quot;name\&quot;=?&quot;<br>
&quot;SELECT \&quot;Pet\&quot;.\&quot;id\&quot;,\&quot;Pet\&quot;.\&quot;owner\&quot;,\&quot;Pet\&quot;.\&quot;nick\&quot;,\&quot;Pet\&quot;.\&quot;type\&quot;<br>
FROM \&quot;Pet\&quot; INNER JOIN \&quot;Person\&quot; ON<br>
\&quot;Person\&quot;.\&quot;id\&quot;=\&quot;Pet\&quot;.\&quot;owner\&quot; WHERE \&quot;Person\&quot;.\&quot;name\&quot;=?&quot;<br>
&quot;BEGIN&quot;<br>
&quot;DELETE FROM \&quot;Pet\&quot;&quot;<br>
&quot;DELETE FROM \&quot;Person\&quot;&quot;<br>
&quot;COMMIT&quot;<br>
&quot;DELETE FROM \&quot;Pet\&quot;&quot;<br>
&quot;DELETE FROM \&quot;Person\&quot;&quot;<br>
<br>
  join: [OK]<br>
<br>
<br>
<br>
The code is sketchier than an etch-a-sketch-sketch. But it is a place<br>
to start playing from.<br>
<br>
<br>
It can be found at <a href="https://github.com/SonOfLilit/persistent" target="_blank">https://github.com/SonOfLilit/persistent</a>, in the<br>
branch template-haskell-refactoring. It is a fork from<br>
kaoskorobase/persistent, to enjoy the work he did on separating the TH<br>
to a separate package.<br>
<br>
I&#39;ll say again: This is very experimental code, it doesn&#39;t work in all<br>
- or most - cases, but it shows the way, or at least one way. It can<br>
probably be made to work reasonably well with little work. I&#39;ll be<br>
very happy for any comments or patches cleaning up my code, since this<br>
is the most advanced Haskell that I&#39;ve had the opportunity to write<br>
and many a time I found myself working by guessing or by brute force.<br>
<br>
Also, Michael, you might want to port some refactoring that I did to<br>
the TH code that in my opinion makes it easier to work with, although<br>
I am sure I over-did it, so apply some thought to it before taking<br>
everything.<br>
<br>
Somehow it happened that this whole thing is one huge commit. I wanted<br>
it to compile before I commited, and the test needed a lot of new<br>
features to compile, and it kinda dragged away into days of work<br>
without commiting... Kids, don&#39;t do this at home. I shouldn&#39;t have.<br>
<br>
I&#39;ll be very glad for some code review, I feel it is long due. I&#39;m in<br>
deeper water than I know how to navigate.<br>
<font color="#888888"><br>
<br>
 -- Aur<br>
</font></blockquote></div><br></div>