Skip to content

Commit

Permalink
Add test for newly-supported type inference on syntax method
Browse files Browse the repository at this point in the history
  • Loading branch information
travisbrown committed Jan 30, 2016
1 parent 1b248a4 commit 815b7a2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions core/src/test/scala/simulacrum/typeclass.scala
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,22 @@ class TypeClassTest extends WordSpec with Matchers {
import Foo.ops._
Option(Option(1)).bar
}

"supports type inference for syntax for operations where the instance type is constrained" in {
@typeclass trait Ap[F[_]] {
def ap[A, B](ff: F[A => B])(fa: F[A]): F[B]
}

object Ap {
implicit val apOption: Ap[Option] = new Ap[Option] {
def ap[A, B](ff: Option[A => B])(fa: Option[A]): Option[B] = ff.flatMap(fa.map)
}
}

import Ap.ops._
val ff: Option[Int => String] = Some(_.toString)
ff.ap(Some(0)) shouldBe Some("0")
}
}

"support annotated companions" in {
Expand Down

0 comments on commit 815b7a2

Please sign in to comment.