In Haskell, I wrote:
lt :: (Ord a) => a -> a -> Bool
lt x y
| x < y = True
| otherwise = False
I tried the following unsuccessfully in Scala:
scala> def lt[A <: Ordered[A]](a: A, b: A): Boolean = a < b
lt: [A <: Ordered[A]](a: A, b: A)Boolean
Here's the REPL error:
scala> lt(10, 100)
<console>:9: error: inferred type arguments [Int] do not conform to method lt's type parameter bounds [A <: Ordered[A]]
lt(10, 100)
^
<console>:9: error: type mismatch;
found : Int(10)
required: A
lt(10, 100)
^
<console>:9: error: type mismatch;
found : Int(100)
required: A
lt(10, 100)
^
How can I create a function lt
in the above way for Scala?