title: How to constrain a type to a subset of another?
body: <p>I have that <em>this is a dumb question</em> feeling, but here goes ... Can I define a type that is a subset of the elements of a another type? Here's a simplified example.</p>
  
  <pre><code>scala&gt; class Even(i: Int) {
       | assert(i % 2 == 0)  
       | }
  defined class Even
  
  scala&gt; new Even(3)
  java.lang.AssertionError: assertion failed
  </code></pre>
  
  <p>This is a runtime check. Can I define a type such that this is checked at compilation? IE, that the input parameter <code>i</code> is provably always even?</p>