summaryrefslogtreecommitdiff
path: root/test/files/pos/tcpoly_infer_ticket716.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2009-10-22 17:04:20 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2009-10-22 17:04:20 +0000
commitbf584e53207b837a3103a59614177ba39f06015e (patch)
treee68eeb41c745ccc848c5fbcd505249880daf021f /test/files/pos/tcpoly_infer_ticket716.scala
parenta2eab2215a7671e8abd8189ccc59388dffc1f3de (diff)
downloadscala-bf584e53207b837a3103a59614177ba39f06015e.tar.gz
scala-bf584e53207b837a3103a59614177ba39f06015e.tar.bz2
scala-bf584e53207b837a3103a59614177ba39f06015e.zip
the essence of tcpoly inference + test cases
fixes to check files and removed nonapplicable test case Tuple2 impl, but commented out so that we can bootstrap whitespace...
Diffstat (limited to 'test/files/pos/tcpoly_infer_ticket716.scala')
-rw-r--r--test/files/pos/tcpoly_infer_ticket716.scala26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/files/pos/tcpoly_infer_ticket716.scala b/test/files/pos/tcpoly_infer_ticket716.scala
new file mode 100644
index 0000000000..cfba07fa43
--- /dev/null
+++ b/test/files/pos/tcpoly_infer_ticket716.scala
@@ -0,0 +1,26 @@
+
+trait Functor[F[_]] {
+ def fmap[A,B](fun: A=>B, arg:F[A]): F[B]
+}
+object Functor{
+ implicit val ListFunctor: Functor[List] = new Functor[List] {
+ def fmap[A, B](f: A => B, arg: List[A]):List[B] = arg map f
+ }
+
+ final class OOFunctor[F[_],A](arg:F[A])(implicit ftr: Functor[F]) {
+ def fmap[B](fun: A=>B):F[B] = ftr.fmap(fun,arg)
+ }
+
+ //breaks if uncommented
+ implicit def lifttoOO[F[_],A](arg:F[A])(implicit ftr: Functor[F]) = new OOFunctor[F,A](arg)(ftr)
+
+ //works if uncommented
+ //implicit def liftListtoOO[A](arg:List[A]):OOFunctor[List,A] = new OOFunctor[List,A](arg)
+}
+
+object GeneralLiftingDemo extends Application {
+ import Functor._
+ val l = List(1,2,3)
+ val res = l fmap( 1+) // TODO: should not need explicit call to lifttoOO
+ println("OO : " + res )
+} \ No newline at end of file