Skip to content

Instantly share code, notes, and snippets.

@bandrzejczak
Created May 16, 2018 09:24
Show Gist options
  • Save bandrzejczak/714e6db01f561bfac05d399e96edfda1 to your computer and use it in GitHub Desktop.
Save bandrzejczak/714e6db01f561bfac05d399e96edfda1 to your computer and use it in GitHub Desktop.
// F[G[_]] ~> H[_]
type MapNestedK[F[_], G[_], H[_]] = FunctionK[λ[a => F[G[a]]], H]
// This compiles
implicit def flatten[F[_]](implicit F: FlatMap[F]): MapNestedK[F, F, F] =
λ[λ[a => F[F[a]]] ~> F](F.flatten(_))
// But for some reason this doesn't
implicit def flatten[F[_]](implicit F: FlatMap[F]): MapNestedK[F, F, F] =
λ[MapNestedK[F, F, F]](F.flatten(_))
// Even though explicit instance creating works
implicit def flatten[F[_]](implicit F: FlatMap[F]): MapNestedK[F, F, F] =
new MapNestedK[F, F, F] {
override def apply[A](fa: F[F[A]]): F[A] = F.flatten(fa)
}
@bandrzejczak
Copy link
Author

The error I get is not found: value λ

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