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

Error "Macro has not been expanded" when using monadic Nothing #41

Open
dominique-unruh opened this issue Aug 13, 2016 · 1 comment
Open

Comments

@dominique-unruh
Copy link

dominique-unruh commented Aug 13, 2016

In monadic[F] { ... }, if each is applied to a monad of type F[Nothing], a compilation error "Macro has not been expanded" occurs.

F[Nothing] is a natural type for a fail operation (e.g., Nil, None) in a monad, since the return value can be upcast to anything (e.g., val x = if (x >= 0) sqrt(x) else None.each would be a use case).

Example code:

object MonadicNeedsCast {
  def main(args: Array[String]): Unit = {
    val monad = monadic[Option] {
      None.each // Normally, this would be inside an if and represent a failure of the computation
//      (None:Option[Unit]).each // This one works
      55
    }
    println(monad) // Should be None
  }
}

The error also appears with monadic[List] or with custom monads. It also appears when using fail.each where fail has type [T]fail( => T).

I am using Scala 2.11.8 and Each 2.0.0.

@Atry
Copy link
Collaborator

Atry commented Aug 13, 2016

Seems like a bug in Scala compiler:
https://issues.scala-lang.org/browse/SI-9889

dominique-unruh referenced this issue in dominique-unruh/proof-editor Aug 13, 2016
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

2 participants