Created
July 26, 2017 13:59
-
-
Save kubukoz/cc4e0f983e39c0daf7650f53ae6ac4bd to your computer and use it in GitHub Desktop.
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
import shapeless._ | |
def abc0[M[_]] = ??? | |
def abc1[M[+_]] = ??? | |
def abc2[M[-_]] = ??? | |
//this one should accept an arbitrary invariant M | |
def abc3[M[_] <: Set[_]] = ??? | |
type Predicate[-a] = a => Boolean | |
//M[_] works for all | |
abc0[Predicate] | |
abc0[List] | |
abc0[Set] | |
//M[+_] works for covariant types | |
illTyped("""abc1[Predicate]""") | |
abc1[List] | |
illTyped("""abc1[Set]""") | |
//M[-_] works for contravariant types | |
abc2[Predicate] | |
illTyped("""abc2[List]""") | |
illTyped("""abc2[Set]""") | |
//this should happen | |
illTyped("""abc3[List]""") | |
illTyped("""abc3[Predicate]""") | |
abc3[Set] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment