Last active
December 25, 2015 12:09
-
-
Save kareblak/6974587 to your computer and use it in GitHub Desktop.
Why?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> case class Pair[A,B](head: A, tail: B) | |
defined class Pair | |
scala> type HeadlessPair[B] = Pair[Any, B] // Setting it to any, so the compiler wont care when type view is accessed | |
defined type alias HeadlessPair | |
scala> def f[A[_], B](ab: A[B]) {} | |
warning: there were 1 feature warning(s); re-run with -feature for details | |
f: [A[_], B](ab: A[B])Unit | |
scala> val headless: HeadlessPair[String] = Pair("begone", "tail") | |
headless: HeadlessPair[String] = Pair(begone,tail) | |
scala> f(headless) | |
<console>:13: error: no type parameters for method f: (ab: A[B])Unit exist so that it can be applied to arguments (Pair[_$1,String]) | |
--- because --- | |
argument expression's type is not compatible with formal parameter type; | |
found : Pair[_$1,String] where type _$1 | |
required: ?A | |
f(headless) | |
^ | |
<console>:13: error: type mismatch; | |
found : Pair[_$1,String] where type _$1 | |
required: A[B] | |
f(headless) | |
^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment