title: Specifying invariants on value constructors
body: <p>Consider the following</p>
  
  <pre><code>data Predicate = Pred Name Arity Arguments
  
  type Name      = String
  type Arity     = Int
  type Arguments = [Entity]
  type Entity    = String
  </code></pre>
  
  <p>This would allow the creation of</p>
  
  <pre><code>Pred "divides" 2 ["1", "2"]
  Pred "between" 3 ["2", "1", "3"]
  </code></pre>
  
  <p>but also the "illegal"</p>
  
  <pre><code>Pred "divides" 2 ["1"]
  Pred "between" 3 ["2", "3"]
  </code></pre>
  
  <p>"Illegal" because the arity does not match the length of the argument list.</p>
  
  <p>Short of using a function like this</p>
  
  <pre><code>makePred :: Name -&gt; Arity -&gt; Arguments -&gt; Maybe Predicate
  makePred n a args | a == length args = Just (Pred n a args)
                    | otherwise = Nothing
  </code></pre>
  
  <p>and only exporting makePred from the Predicate module, is there a way to
  enforce the correctness of the value constructor?</p>