Last active
November 18, 2019 08:55
-
-
Save smarter/e9c67df0dd089019b823fcfde91ec0e8 to your computer and use it in GitHub Desktop.
Should work with 0.20.0-RC1
This file contains hidden or 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
// Compiles with https://github.com/lampepfl/dotty/pull/4672 | |
// ./bin/dotc -classpath "$(coursier fetch -p org.typelevel:cats-core_2.13:2.0.0)" out/fmap.scala | |
import cats._ | |
import cats.implicits._ | |
object Test { | |
val fmap: [A, B] -> (A => B) => [F[_]] -> F[A] => (given Functor[F]) => F[B] = [A, B] -> (f: A => B) => ([F[_]] -> (fa: F[A]) => (given ev: Functor[F]) => fa.map(f)) | |
val addOne = fmap((x: Int) => x + 1) | |
val x = addOne(Option(42)) | |
val y = addOne(List(1,2,3)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This does not seem to work anymore with dotty 0.20.0-RC1:
val fmap: [A, B] => (A => B) => ([F[_]] => F[A] => given Functor[F] => F[B]) = [A, B] => (f: A => B) => ([F[_]] => (fa: F[A]) => given (ev: Functor[F]) => ev.map(fa)(f))
https://scastie.scala-lang.org/kwark/7sqzH8DqRnmUVKmFpOUdRw