Created
September 15, 2011 17:57
-
-
Save jaimefjorge/1219966 to your computer and use it in GitHub Desktop.
My Scalaz error
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 scalaz._ | |
import Scalaz._ | |
scala> val a = (_:List[Int]).partition(_ > 5) | |
a: List[Int] => (List[Int], List[Int]) = <function1> | |
scala> val b = (_:List[Int]).partition(_ > 10) | |
b: List[Int] => (List[Int], List[Int]) = <function1> | |
scala> val c = (_:List[Int]).map(_ + 1) | |
c: List[Int] => List[Int] = <function1> | |
scala> a andThen b.first andThen c.first.first apply List(1,2,3,20,30,40,50,100,200,300) | |
res0: ((List[Int], List[Int]), List[Int]) = ((List(21, 31, 41, 51, 101, 201, 301),List()),List(1, 2, 3)) | |
scala> a andThen b.first andThen c.first.second apply List(1,2,3,20,30,40,50,100,200,300) | |
<console>:17: error: polymorphic expression cannot be instantiated to expected type; | |
found : [C(in method first), C(in method second)](C(in method second), (List[Int], C(in method first))) => (C(in method second), (List[Int], C(in method first))) | |
required: ((List[Int], List[Int]), List[Int]) => ? | |
a andThen b.first andThen c.first.second apply List(1,2,3,20,30,40,50,100,200,300) | |
scala> a andThen b.second andThen c.second.second apply List(1,2,3,20,30,40,50,100,200,300) | |
res5: (List[Int], (List[Int], List[Int])) = (List(20, 30, 40, 50, 100, 200, 300),(List(),List(2, 3, 4))) | |
scala> a andThen b.second andThen c.second.first apply List(1,2,3,20,30,40,50,100,200,300) | |
<console>:17: error: polymorphic expression cannot be instantiated to expected type; | |
found : [C(in method second), C(in method first)]((C(in method second), List[Int]), C(in method first)) => ((C(in method second), List[Int]), C(in method first)) | |
required: (List[Int], (List[Int], List[Int])) => ? | |
a andThen b.second andThen c.second.first apply List(1,2,3,20,30,40,50,100,200,300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In case of
c.first.first
composition succeeds because types match.