<div dir="ltr"><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif">Now that this is straightened out, I went back to what I was doing in the first place and realized that I haven&#39;t solved my problem.</font></font></font><div>

<font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><br></font></font></font></div><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif">Given </font></font></font></div><div>

<font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><br></font></font></font></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div>

data Person =</div></font></font></font></div><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div>      Man {name :: String, age :: Int, prostateCondition :: Condition}</div></font></font></font></div>

<div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div>  | Woman {name :: String, age :: Int, ovaryCondition    :: Condition}</div></font></font></font></div></blockquote><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div>

<br></div><div>I&#39;d like to define something like this.</div><div><br></div></font></font></font></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div>

type MensGroup = [Man]</div></font></font></font></div></blockquote><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div><br></div><div>Is there a way to do something like that?</div></font></font></font><div dir="ltr">

<font><font face="&#39;trebuchet ms&#39;, sans-serif"><i><font color="#003333"><br>-- Russ </font></i></font></font></div><div dir="ltr"><font><font face="&#39;trebuchet ms&#39;, sans-serif"><i><font color="#003333"><br>
</font></i></font></font></div>

<br><br><div class="gmail_quote">On Tue, Dec 14, 2010 at 1:06 PM, Russ Abbott <span dir="ltr">&lt;<a href="mailto:russ.abbott@gmail.com">russ.abbott@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">

<div dir="ltr"><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif">That&#39;s good. (It&#39;s more or less the way I was doing it.)  What I wanted to avoid was this.</font></font></font><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><br>


</font></font></font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div>getGenderSpecificCondition (  Man _ _ cond) = cond</div>


</font></font></font></div><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div>getGenderSpecificCondition (Woman _ _ cond) = cond</div></font></font></font></div></blockquote><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div>


<br></div><div>I know it seems like a small thing, but I would like to be able to write it like this.</div></font></font></font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div><div>getGenderSpecificCondition p</div></div></font></font></font></div><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div>


<div>   | p == (Man _ _ cond) = cond</div></div></font></font></font></div><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div><div>   | p == (Woman _ _ cond) = cond</div></div><div><br></div>


</font></font></font></div></blockquote><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div>But that&#39;s not legal syntax.  A pattern can&#39;t appear in that context. But this does the job.</div>


<div><br></div></font></font></font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div>
<span style="color:rgb(0, 0, 0);font-family:arial"><div><font color="#003333"><font size="2"><font face="trebuchet ms,sans-serif"><div><div><div>getGenderSpecificCondition :: Person -&gt; Condition</div>
<div>getGenderSpecificCondition p</div><div>   | isMan p = prostateCondition p</div><div>   | isWoman p = ovaryCondition p</div><div>   </div><div>isMan (     Man _ _ cond) = True</div><div>isMan _ = False</div><div>isWoman (Woman _ _ cond) = True</div>


<div>isWoman _ = False</div></div></div><div><br></div></font></font></font></div></span></div></font></font></font></div></blockquote><font color="#003333" face="&#39;trebuchet ms&#39;, sans-serif">That works! prostateCondition and ovaryCondition are both defined on Person. (I&#39;m surprised to see that.)</font><div>


<font color="#003333" face="&#39;trebuchet ms&#39;, sans-serif"><br></font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font color="#003333" face="&#39;trebuchet ms&#39;, sans-serif"><div>
*Person&gt; Group [Man &quot;Harry&quot; 32 OK, Woman &quot;Sally&quot; 29 Good]</div></font></div><div><font color="#003333" face="&#39;trebuchet ms&#39;, sans-serif"><div>Harry(32, OK)</div></font></div>
<div><font color="#003333" face="&#39;trebuchet ms&#39;, sans-serif"><div>Sally(29, Good)</div><div><br></div></font></div></blockquote><span style="font-family:&#39;trebuchet ms&#39;, sans-serif;color:rgb(0, 51, 51)">Also </span><br>


<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font color="#003333" face="&#39;trebuchet ms&#39;, sans-serif"><div><br></div><div><div>*Person&gt; prostateCondition (Woman &quot;Sally&quot; 29 Good)</div>


<div>*** Exception: No match in record selector prostateCondition</div><div>*Person&gt; prostateCondition (Man &quot;Harry&quot; 29 Good)</div><div>Good</div></div><div><br></div></font></div></blockquote><div><font color="#003333" face="&#39;trebuchet ms&#39;, sans-serif"><div>


<br></div></font><div><div dir="ltr"><font><font face="&#39;trebuchet ms&#39;, sans-serif"><i><font color="#003333">-- Russ </font></i></font></font></div><div><div></div><div class="h5"><div dir="ltr"><font><font face="&#39;trebuchet ms&#39;, sans-serif"><i><font color="#003333"><br>


</font></i></font></font></div>
<br><br><div class="gmail_quote">On Tue, Dec 14, 2010 at 12:31 PM, Michael Katelman <span dir="ltr">&lt;<a href="mailto:katelman@uiuc.edu" target="_blank">katelman@uiuc.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">


Perhaps this?<br>
<br>
<a href="https://gist.github.com/741048" target="_blank">https://gist.github.com/741048</a><br>
<br>
-Mike<br>
<div><div></div><div><br>
On Tue, Dec 14, 2010 at 2:27 PM, Russ Abbott &lt;<a href="mailto:russ.abbott@gmail.com" target="_blank">russ.abbott@gmail.com</a>&gt; wrote:<br>
&gt; What I&#39;m after is a version of my example that compiles.  Can you make one?<br>
&gt;<br>
&gt; -- Russ<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Dec 14, 2010 at 12:18 PM, Antoine Latter &lt;<a href="mailto:aslatter@gmail.com" target="_blank">aslatter@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Sorry, I really don&#39;t know enough about what you&#39;re after to attempt that.<br>
&gt;&gt;<br>
&gt;&gt; But you&#39;ll need to change you&#39;re signatures of the form:<br>
&gt;&gt;<br>
&gt;&gt; &gt; function :: Person -&gt; Foo<br>
&gt;&gt;<br>
&gt;&gt; to something of the form:<br>
&gt;&gt;<br>
&gt;&gt; &gt; function :: Person p =&gt; p -&gt; Foo<br>
&gt;&gt;<br>
&gt;&gt; Because again, a type class can not be used as a type.<br>
&gt;&gt;<br>
&gt;&gt; Antoine<br>
&gt;&gt;<br>
&gt;&gt; On Tue, Dec 14, 2010 at 2:12 PM, Russ Abbott &lt;<a href="mailto:russ.abbott@gmail.com" target="_blank">russ.abbott@gmail.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt; &gt; What got fouled up is all the adjustments I had to make to the other<br>
&gt;&gt; &gt; declarations.<br>
&gt;&gt; &gt; Can you complete the example so that it compiles using<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; class Person p where ...<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I&#39;d very much like to see an example that actually compiles.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Thanks.<br>
&gt;&gt; &gt; -- Russ<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Tue, Dec 14, 2010 at 11:58 AM, Antoine Latter &lt;<a href="mailto:aslatter@gmail.com" target="_blank">aslatter@gmail.com</a>&gt;<br>
&gt;&gt; &gt; wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; On Tue, Dec 14, 2010 at 1:52 PM, Russ Abbott &lt;<a href="mailto:russ.abbott@gmail.com" target="_blank">russ.abbott@gmail.com</a>&gt;<br>
&gt;&gt; &gt;&gt; wrote:<br>
&gt;&gt; &gt;&gt; &gt; If gender is a field in a Person type, then a Person must have both<br>
&gt;&gt; &gt;&gt; &gt; an<br>
&gt;&gt; &gt;&gt; &gt; ovaryCondition and a prostateCondition.  That seems awkward.<br>
&gt;&gt; &gt;&gt; &gt; Regarding<br>
&gt;&gt; &gt;&gt; &gt;      class Person p where<br>
&gt;&gt; &gt;&gt; &gt; I started down that path but got completely fouled up.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; How did this get fouled up? Every class declaration must take<br>
&gt;&gt; &gt;&gt; arguments - here, &#39;p&#39; is the argument for the class.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Thanks,<br>
&gt;&gt; &gt;&gt; Antoine<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;<br>
&gt;<br>
</div></div><div><div></div><div>&gt; _______________________________________________<br>
&gt; Beginners mailing list<br>
&gt; <a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div></div></div></div></div>
</blockquote></div><br></div></div>