2009/1/23 Brandon S. Allbery KF8NH <span dir="ltr"><<a href="mailto:allbery@ece.cmu.edu">allbery@ece.cmu.edu</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><div><div class="Ih2E3d"><div>On 2009 Jan 23, at 17:58, Olex P wrote:</div></div><blockquote type="cite"><div class="Ih2E3d">class Vector v where<br> (^+^) :: v -> v -> v<br><br></div><div class="Ih2E3d">
class Matrix m where<br> (^+^) :: m -> m -> m</div></blockquote><br></div><div>You can't reuse the same operator in different classes. Vector "owns" (^+^), so Matrix can't use it itself. You could say</div>
<div><br></div><div>> instance Matrix m => Vector m where</div><div>> (^+^) = ...</div><div></div></div></blockquote><div><br>No you can't! Stop thinking you can do that!<br><br>It would be sane to do:<br>
<br>class Vector m => Matrix m where<br> -- matrix ops that don't make sense on vector<br><br>Thus anything that implements Matrix must first implement Vector. Which is sane because matrices are square vectors with some additional structure, in some sense.<br>
<br>Luke<br></div></div>