You&#39;re partially right. The Typeable is redundant because Data has the type:<br><br>(Typeable a) =&gt; Data a<br><br clear="all">-R. Kyle Murphy<br>--<br>Curiosity was framed, Ignorance killed the cat.<br>
<br><br><div class="gmail_quote">On Tue, Aug 3, 2010 at 15:01, Ozgur Akgun <span dir="ltr">&lt;<a href="mailto:ozgurakgun@gmail.com">ozgurakgun@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Why do you need them to be Typeable? toConstr has the following type:<br><br>toConstr :: (Data a) =&gt; a -&gt; Constr<br><br>Best,<div><div></div><div class="h5"><br><br><div class="gmail_quote">On 3 August 2010 19:50, Kyle Murphy <span dir="ltr">&lt;<a href="mailto:orclev@gmail.com" target="_blank">orclev@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">I was close, this actually does what was asked:<br><br>import Data.Data<br><br>typeChecker :: (Typeable a, Typeable b, Data a, Data b) =&gt; a -&gt; b -&gt; Bool<br>

typeChecker a b = toConstr a == toConstr b<div><br><br clear="all">
-R. Kyle Murphy<br>--<br>Curiosity was framed, Ignorance killed the cat.<br>
<br><br></div><div><div></div><div><div class="gmail_quote">On Tue, Aug 3, 2010 at 14:42, Kyle Murphy <span dir="ltr">&lt;<a href="mailto:orclev@gmail.com" target="_blank">orclev@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Actually looking at the original question I&#39;m not sure my code does what was intended. I was looking at does some type (a b) == (a c), which wasn&#39;t exactly the question. Oh well, back to the drawing board.<div>
<br><br clear="all">
-R. Kyle Murphy<br>--<br>Curiosity was framed, Ignorance killed the cat.<br>
<br><br></div><div><div></div><div><div class="gmail_quote">On Tue, Aug 3, 2010 at 14:38, Kyle Murphy <span dir="ltr">&lt;<a href="mailto:orclev@gmail.com" target="_blank">orclev@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Less of a dirty dirty hack (requires that SchemeVal be an instance of Typeable):<br><br>import Data.Typeable<br>import Data.Maybe<br><br>typeChecker :: (Typeable a, Typeable b) =&gt; a -&gt; b -&gt; Bool<br>typeChecker a b = f a == f b<br>




        where<br>                f :: (Typeable a) =&gt; a -&gt; Maybe TypeRep<br>                f = listToMaybe . typeRepArgs . typeOf<br><br><br clear="all">-R. Kyle Murphy<br><font color="#888888">--<br>Curiosity was framed, Ignorance killed the cat.</font><div>



<div></div><div><br>

<br><br><div class="gmail_quote">On Tue, Aug 3, 2010 at 13:51, Alex Rozenshteyn <span dir="ltr">&lt;<a href="mailto:rpglover64@gmail.com" target="_blank">rpglover64@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">




<div dir="ltr">That is a dirty, dirty hack.<div><div></div><div><br><br><div class="gmail_quote">On Tue, Aug 3, 2010 at 8:45 PM, Christian Maeder <span dir="ltr">&lt;<a href="mailto:Christian.Maeder@dfki.de" target="_blank">Christian.Maeder@dfki.de</a>&gt;</span> wrote:<br>





<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Matt Andrew schrieb:<br>
<div>&gt; Hi all,<br>
&gt;<br>
&gt; I am in the process of writing a Scheme interpreter/compiler in Haskell as my first serious project after learning the basics of Haskell. The goal is to really get a feel for Haskell. I am trying to accomplish this as much as I can on my own, but am referring to Jonathan Tang&#39;s &#39;Write Yourself a Scheme in 48 hours&#39; whenever I get really stuck.<br>






&gt;<br>
&gt; I have a question regarding a pattern that I have found within my code for which I cannot seem to find an abstraction.<br>
&gt;<br>
&gt; I am implementing some of the primitive Scheme type-checker functions with the following code:<br>
&gt;<br>
&gt; numberP :: SchemeVal -&gt; SchemeVal<br>
&gt; numberP (Number _) = Bool True<br>
&gt; numberP _          = Bool False<br>
&gt;<br>
&gt; boolP :: SchemeVal -&gt; SchemeVal<br>
&gt; boolP (Bool _) = Bool True<br>
&gt; boolP _        = Bool False<br>
&gt;<br>
&gt; symbolP :: SchemeVal -&gt; SchemeVal<br>
&gt; symbolP (Atom _) = Bool True<br>
&gt; symbolP _        = Bool False<br>
&gt;<br>
&gt; This is a pattern that I could easily provide an abstraction for with a Lisp macro, but I&#39;m having trouble discovering if/how it&#39;s possible to do so elegantly in Haskell. The closest (but obviously incorrect) code to what I&#39;m trying to accomplish would be:<br>






&gt;<br>
&gt; typeChecker :: SchemeVal -&gt; SchemeVal -&gt; SchemeVal<br>
&gt; typeChecker (cons _) (cons2 _) = Bool $ cons == cons2<br>
&gt;<br>
&gt; I understand this code drastically misunderstands how pattern matching works, but (hopefully) it expresses what I&#39;m trying to accomplish. Anyone have any suggestions?<br>
<br>
</div>typeChecker s1 s2 = let f = takeWhile isAlphaNum . show in<br>
   Bool $ f s1 == f s2<br>
<br>
hoping that my &quot;f&quot; just extracts the constructor as string.<br>
<font color="#888888"><br>
C.<br>
</font><div><div></div><div><br>
&gt; I do realise that such an abstraction is barely worth it for the amount of code it will save, but this exercise is about learning the ins and outs of Haskell.<br>
&gt;<br>
&gt; Appreciate you taking the time to read this,<br>
&gt;<br>
&gt; Matt Andrew<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</div></div></blockquote></div><br><br clear="all"><br></div></div><div>-- <br><div>()  ascii ribbon campaign - against html e-mail <div>/\  <a href="http://www.asciiribbon.org" target="_blank">www.asciiribbon.org</a>   - against proprietary attachments</div>





</div><div><br></div><div>          Alex R</div><br>
</div></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>
</div></div><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br></div></div><font color="#888888">Ozgur Akgun<br>
</font></blockquote></div><br>