Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monad last exercise doesn't compile #36

Open
ggalmazor opened this issue Aug 8, 2016 · 1 comment
Open

Monad last exercise doesn't compile #36

ggalmazor opened this issue Aug 8, 2016 · 1 comment

Comments

@ggalmazor
Copy link

The following code doesn't compile:

implicit def optionTMonad[F[_]](implicit F: Monad[F]) = {
  new Monad[OptionT[F, ?]] {
    def pure[A](a: A): OptionT[F, A] = OptionT(F.pure(Some(a)))
    def flatMap[A, B](fa: OptionT[F, A])(f: A => OptionT[F, B]): OptionT[F, B] =
      OptionT {
        F.flatMap(fa.value) {
          case None => F.pure(None)
          case Some(a) => f(a).value
        }
      }
  }
}

Running this code gives this error messages:

<console>:37: error: not found: type ?
         new Monad[OptionT[F, ?]] {
                              ^
<console>:37: error: OptionT[F,<error>] takes no type parameters, expected: one
         new Monad[OptionT[F, ?]] {

I'm running this in the REPL launched with sbt console and this build.sbt file:

name := "Scala Playground"

version := "1.0"

scalaVersion := "2.11.1"

libraryDependencies += "org.typelevel" %% "cats" % "0.6.1"

PS: Also, it's not very clear what's the point of this last exercise nor the result it should give... Maybe some extra explanation would make it easier to understand, especially about the type parameters' meanings in OptionT and optionTMonad...

@ggalmazor
Copy link
Author

Tried with this build.sbt:

name := "Scala Playground"

version := "1.0"

scalaVersion := "2.11.1"

resolvers += Resolver.sonatypeRepo("releases")

addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.8.0")

libraryDependencies += "org.typelevel" %% "cats" % "0.6.1"

Failing to compile as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant