<div class="gmail_quote">In addition to fixing &#39;Float&#39;, you should define the &#39;Fractional&#39; instance for MathExpression. This would let you use:<div class="im"><div>   let pi = 3.14 :: MathExpression</div><div>
<br></div></div><div>So your instance of Fractional would look like:</div>
<div><br></div><div>    </div><font face="&#39;courier new&#39;, monospace">instance Num MathExpression where<br></font><div><div><font face="&#39;courier new&#39;, monospace">  (+) a b = Add a b</font></div>
<div><font face="&#39;courier new&#39;, monospace">  (*) a b = Multiply a b</font></div><div><font face="&#39;courier new&#39;, monospace">  (-) a b = Subtract a b</font></div>
<div><font face="&#39;courier new&#39;, monospace">  negate b = Subtract 0 b</font></div><div><font face="&#39;courier new&#39;, monospace">  fromInteger = MathFloat . fromInteger</font></div>
<div><font face="&#39;courier new&#39;, monospace">  abs    = undefined</font></div><div><font face="&#39;courier new&#39;, monospace">  signum = undefined</font></div><div>
<font face="&#39;courier new&#39;, monospace">instance Fractional MathExpression where<br>  fromRational = MathFloat . fromRational<br></font><font face="&#39;courier new&#39;, monospace">  (/) a b = Divide a b<br>
</font><font face="&#39;courier new&#39;, monospace">  recip b = Divide 1 b</font></div><div><font face="&#39;courier new&#39;, monospace">  <br></font><div><div><div><div>
<div class="gmail_quote"><font face="arial, helvetica, sans-serif">That would give &#39;fromRational&#39; and &#39;fromInteger&#39; which are the main numeric conversion functions.</font></div><div class="gmail_quote">
<font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_quote"><font face="arial, helvetica, sans-serif">Regards,</font></div><div class="gmail_quote">
<font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_quote"><font face="arial, helvetica, sans-serif">Dave</font></div><div class="im"><div class="gmail_quote"><font face="&#39;courier new&#39;, monospace"><br>

</font></div><div class="gmail_quote">On Fri, Aug 19, 2011 at 1:40 PM, Paul Reiners <span dir="ltr">&lt;<a href="mailto:paul.reiners@gmail.com" target="_blank">paul.reiners@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">

I&#39;ve created a simple type declaration:<br><br><div style="margin-left:40px"><span style="font-family:courier new,monospace">data MathExpression = Float</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    | Add MathExpression MathExpression</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">    | Subtract MathExpression MathExpression</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    | Multiply MathExpression MathExpression</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">    | Divide MathExpression MathExpression</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">      deriving (Show)</span><br>


</div><br>Now how do I create an instance of MathExpression which is just a Float?<br></blockquote><div><br></div></div></div></div></div></div></div></div></div>
</div><br>