Skip to content

JP - Adds free algebra for Evaluator Client API #19

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

Merged
merged 2 commits into from
Aug 8, 2016

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.

1 participant