title: Inheritance to extend a data structure in Haskell
body: <p>A C++ programmer trying to learn Haskell here.  Please excuse this probably easy question.  I want to translate a program that represents 3D shapes.  In C++ I have something like:</p>
  
  <pre><code>class Shape {
  public:
    std::string name;
    Vector3d position;
  };
  
  class Sphere : public Shape {
  public:
    float radius;
  };
  
  class Prism : public Shape {
  public:
    float width, height, depth;
  };
  </code></pre>
  
  <p>I am trying to translate this to Haskell (using records?) so that I can have some functions which know how to operate on a Shape (like accessing its name and position), and others than know only how to operate on spheres, like calculating something based on its position and radius.</p>
  
  <p>In C++ a member function could just access these parameters but I'm having a hard time figuring out how to do this in Haskell with records, or type classes, or whatever.</p>
  
  <p>Thanks.</p>