title: How to enforce type relation and constraints when defing data type
body: <p>In the following code:</p>
  
  <pre><code>data Point = Point { x           :: Int, 
                       leftHeight  :: Int, 
                       rightHeight :: Int}
  data Rectangle = Rec Point Point
  
  rec1 = Rec p1 p2
  </code></pre>
  
  <p>There are several constraints when creating <code>Rec</code> such as: </p>
  
  <pre><code>x p1 &lt; x p2
  (leftHeight p1 ) should always be zero
  (rightHeight p2 ) should always be zero
  rightHeight p1 == leftHeight p2
  </code></pre>
  
  <p>Is there a way to enforce these constraints at type level?
  Because I'm using <code>QuickCheck</code> to generate some sample <code>Rec</code> but these contraints make <code>QuickCheck</code> very slow to generate random samples.</p>
  
  <p>edit: I've solved the slow QuickCheck issue. But anyway still curious if such constraint can be expressed in Haskell</p>