Skip to content

Conversation

@juanpedromoreno
Copy link
Contributor

@juanpedromoreno juanpedromoreno commented Aug 8, 2016

This PR brings a preliminary version of the free algebra to interact with the evaluator service.

In this way, this would be an example of use case:

val client = new EvaluatorClient("<evaluator-service-url>",  "<evaluator-auth-key>")

  val response: Free[EvaluatorOp, EvaluationResponse[EvalResponse]] =
    client.api.evaluates(
      dependencies = List(
        Dependency(
          groupId = "org.typelevel",
          artifactId = "cats_2.11",
          version = "0.6.1")),
      code = "{import cats._; Eval.now(42).value}")

  response.exec[Eval].value match {
    case Xor.Right(EvaluationResult(result, _, _)) 
      println(result)
    case Xor.Left(ex)  throw ex
  }

Please, @dialelo @raulraja Could you review it? Thanks!


trait IdInstances {

implicit def idMonadError(implicit I: Monad[Id]): MonadError[Id, Throwable] =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that MonadError[Id, Throwable] is not realy a MonadError since Id values are computed eagerly and exceptions cannot be converted to values with MonadError#attempt. The definition of Id (something like type Id[A] = A) also makes it interact weirdly during implicit resolution.

My suggestion would be to remove this instance.

@ghost
Copy link

ghost commented Aug 8, 2016

Other than the comment LGTM!

@juanpedromoreno juanpedromoreno merged commit 63ea890 into master Aug 8, 2016
@juanpedromoreno juanpedromoreno deleted the jp-creates-free-algebra-ops branch August 8, 2016 14:39
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

Successfully merging this pull request may close these issues.

2 participants