title: What's the Scala syntax for a function taking any subtype of Ordered[A]?
body: <p>I want to write a function that works on any Scala type with a total ordering (i.e. I can use '&lt;' on it).  What's the syntax for that?  The best I've come up with is</p>
  
  <pre><code>def lessThan[T &lt;: Ordered[T]](x: T, Y: T) = x &lt; y
  </code></pre>
  
  <p>That doesn't work, though, when I try using it from the REPL:</p>
  
  <pre><code>scala&gt; lessThan(1, 2)
  &lt;console&gt;:8: error: inferred type arguments [Int] do not conform to method lessThan's type parameter bounds [T &lt;: Ordered[T]]
         lessThan(1, 2)
         ^
  
  scala&gt; import runtime._
  import runtime._
  
  scala&gt; lessThan(new RichInt(1), new RichInt(2))
  &lt;console&gt;:8: error: inferred type arguments [scala.runtime.RichInt] do not conform to method lessThan's type parameter bounds [T &lt;: Ordered[T]]
         lessThan(new RichInt(1), new RichInt(2))
  </code></pre>
  
  <p>Essentially, I believe I want the equivalent of this Haskell code:</p>
  
  <pre><code>lessThan :: (Ord a) =&gt; a -&gt; a -&gt; Bool
  lessThan x y = x &lt; y
  </code></pre>
  
  <p>I'm using scala 2.7.3 on a Debian system.</p>
  
  <p>What am I missing, and where?</p>