Skip to content

Instantly share code, notes, and snippets.

@smarter
Last active November 18, 2019 08:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smarter/e9c67df0dd089019b823fcfde91ec0e8 to your computer and use it in GitHub Desktop.
Save smarter/e9c67df0dd089019b823fcfde91ec0e8 to your computer and use it in GitHub Desktop.
Should work with 0.20.0-RC1
// 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))
}
@kwark
Copy link

kwark commented Nov 15, 2019

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

@smarter
Copy link
Author

smarter commented Nov 18, 2019

@kwark Parens are required around given xxx, I've updated the gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment