title: What is wrong with this class/instance?
body: <p>I have this:</p>
  
  <pre><code>data Vector3 t = Vector3 { ax, ay, az :: t }
  data Point3 t = Point3 { x, y, z :: t }
  data Ray3 t = Ray3 { ori :: Point3 t, dir :: Vector3 t }
  data Sphere t = Sphere { center :: Point3 t, radius :: t }
  </code></pre>
  
  <p>I want a Shape type class, so I did this:</p>
  
  <pre><code>class Shape s where
        distance :: s -&gt; Ray3 t -&gt; t
  </code></pre>
  
  <p><code>distance</code> takes a shape and a ray and computes the distance to the shape along the given ray.  When I try to create an instance, it doesn't work.  This is what I have so far:</p>
  
  <pre><code>instance Shape (Sphere t) where
           distance (Sphere center radius) ray = -- some value of type t --
  </code></pre>
  
  <p>How do I create an instance of Shape?  I've tried everything I can think of, and I'm getting all kind of errors.</p>