Giter VIP home page Giter VIP logo

monadtransformers's Introduction

monadtransformers's People

Contributors

mattfowler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

shaileshp0110

monadtransformers's Issues

Compiler error on explicit types in for-comprehension

Not an issue with your code, but a slight change leads to a compiler error which I cannot understand or fix. Perhaps you can shed some light on it.

adding types inside the for comprehension fails to compile:

      val summed = for {
        resultOne: Int <- one
        resultTwo: Int <- two
      } yield {
        resultOne + resultTwo
      }

The compiler error is: value filter is not a member of com.example.monadT.OptionTransformer[scala.concurrent.Future,Int] [error] resultOne: Int <- one

while this compiles and runs:

      val summed = for {
        resultOne <- one
        resultTwo <- two
      } yield {
        resultOne + resultTwo
      }

How is filter involved here? How would I fix it and still keep explicit types?

Using `Some` instead of `Option` fails to compile

Again, a slight change to the code leads to a compilation failure which I dont quite understand:

runs fine:
val one: OptionTransformer[Future, Int] = OptionTransformer(Future(Option(1)))

fails to compile:
val one: OptionTransformer[Future, Int] = OptionTransformer(Future(Some(1)))

[error]... no type parameters for method apply: (value: T[Option[A]])(implicit m: com.example.monadT.Monad[T])com.example.monadT.OptionTransformer[T,A] in object OptionTransformer exist so that it can be applied to arguments (scala.concurrent.Future[Some[Int]])
[error]  --- because ---
[error] argument expression's type is not compatible with formal parameter type;
[error]  found   : scala.concurrent.Future[Some[Int]]
[error]  required: ?T[Option[?A]]
[error]       val one: OptionTransformer[Future, Int] = OptionTransformer(Future(Some(1)))

A method returning Future(Some(1)) does compile and run:

  val getFO: (Int) => Future[Option[Int]] = (in) => Future.successful(Some(in + 1))
  ...
  resultOne <- OptionTransformer(getFO(0))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.