<br><br><div class="gmail_quote">On Sun, Apr 11, 2010 at 4:15 PM, Ozgur Akgun <span dir="ltr"><<a href="mailto:ozgurakgun@gmail.com">ozgurakgun@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><div class="gmail_quote">On 11 April 2010 22:54, Jason Dagit <span dir="ltr"><<a href="mailto:dagit@codersbase.com" target="_blank">dagit@codersbase.com</a>></span> wrote:<br><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex" class="gmail_quote">
<div> </div></blockquote><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex" class="gmail_quote">...<br></blockquote><div class="im"><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex" class="gmail_quote">
<div> </div></blockquote><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">class Vehicle a where<div class="gmail_quote"><div><br></div><div>data Car</div>
<div>data Truck</div><div><br></div><div>instance Vehicle Car where</div><div>instance Vehicle Truck where</div><div><br></div><div>Now you can have things that take a Car or a Truck or they can take a Vehicle instead.</div>
<div><br></div><div>moveVehicle :: Vehicle v => v -> Simulation ()</div><br></div></blockquote></div><div><br>unfortunately, now you cannot use pattern matching while defining moveVehicle. <br></div></div></blockquote>
<div><br></div><div>That's true. Although, if you're writing a simulation where Cars and Trucks are objects in that simulation, they are likely to be defined as records as they will probably have many fields. If that's the case, it's unlikely you'd be using pattern matching with them anyway. It's just a small step from there to using typeclass functions to access the parts you care about.</div>
<div><br></div><div>Jason</div></div>