It is generally not possible to describe interesting restrictions like this using a type alias. Instead, you need a type class that proves that the type has some property.
With Shapeless, you can often accomplish this using the type classes that the library provides, but I don't think this is the case. Fortunately, it's not too hard to write your own:
import shapeless._
What we are doing here is a description of how to create evidence inductively, as a base case - singleton HList . At each step, we use an element of type In to keep track of what type of output should be next (i.e., earlier in the list).
And to confirm that he is doing what we expect:
scala> composable[(Int => String) :: (String => Char) :: HNil] scala> composable[(Int => Long) :: (Long => Char) :: (Char => String) :: HNil] scala> composable[(Int => String) :: (Symbol => Char) :: HNil] <console>:23: error: could not find implicit value for evidence parameter...
The first two work very well, and the third does not compile.
source share