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

Can't run example of using Eff #104

Closed
oskoi opened this issue May 19, 2017 · 2 comments
Closed

Can't run example of using Eff #104

oskoi opened this issue May 19, 2017 · 2 comments

Comments

@oskoi
Copy link

oskoi commented May 19, 2017

import cats._, data._
import org.atnos.eff._

type ReaderInt[A] = Reader[Int, A]
type WriterString[A] = Writer[String, A]

type Stack = Fx.fx3[WriterString, ReaderInt, Eval]

import org.atnos.eff.all._
import org.atnos.eff.syntax.all._

// useful type aliases showing that the ReaderInt and the WriterString effects are "members" of R
// note that R could have more effects
type _readerInt[R]    = ReaderInt |= R
type _writerString[R] = WriterString |= R

def program[R :_readerInt :_writerString :_eval]: Eff[R, Int] = for {
// get the configuration
  n <- ask[R, Int]

  // log the current configuration value
  _ <- tell("the required power is "+n)

  // compute the nth power of 2
  a <- delay(math.pow(2, n.toDouble).toInt)

  // log the result
  _ <- tell("the result is "+a)
} yield a

// run the action with all the interpreters
// each interpreter running one effect
program[Stack].runReader(6).runWriter.runEval.run

After compilation get:

No instance found for Member[[β$0$]cats.data.Kleisli[[A]A,Int,β$0$], A$A57.this.Stack].
The effect [β$0$]cats.data.Kleisli[[A]A,Int,β$0$] is not part of the stack A$A57.this.Stack
 or it was not possible to determine the stack that would result from removing [β$0$]cats.data.Kleisli[[A]A,Int,β$0$] from A$A57.this.Stack
program[Stack].runReader(6).runWriter.runEval.run;}
                        ^

What i do wrong? I took this example from introduction http://atnos-org.github.io/eff/org.atnos.site.Introduction.html

@etorreborre
Copy link
Member

In the Installation part there's a paragraph about the necessary sbt settings, like -Ypartial-unification. Do you have that?

@oskoi
Copy link
Author

oskoi commented May 19, 2017

Oops ... no. Thank you!
Everything worked!

@oskoi oskoi closed this as completed May 19, 2017
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