Code Monkey home page Code Monkey logo

Comments (4)

Axiometry avatar Axiometry commented on June 12, 2024

I've come up with a slightly more elegant solution:

def bindingSeq[A](seqInBinding: Binding[Iterable[A]]): BindingSeq[A] =
  Constants(Binding(Constants(seqInBinding.bind.toSeq: _*))).flatMap(_.bind)

(and for related conversions:)

def bindingSeq[A](seqOfBinding: Iterable[Binding[A]]): Binding[Iterable[A]] =
  Constants(seqOfBinding.toSeq: _*).map(_.bind).all
def bindingSeq[A](seqOfBinding: Iterable[Binding[A]]): BindingSeq[A] =
  Constants(seqOfBinding.toSeq: _*).map(_.bind)

Feel free to close this if employing Constants in this way is the most idiomatic method.

Note that this still doesn't work when positioned in an implicit value class:

implicit class Wrapper[A](val seqInBinding: Binding[Iterable[A]]) extends AnyVal {
  def bindingSeq: BindingSeq[A] =
    Constants(Binding(Constants(seqInBinding.bind.toSeq: _*))).flatMap(_.bind)
}

Could not find proxy for x$4: binding.this.Binding in List(value x$4, value $anonfun, method bindingSeq, class Wrapper, module class ScalaFiddle, package class , package class ) (currentOwner= value $anonfun )

Though this can be worked around by defining the body of bindingSeq elsewhere and calling it from within the implicit value class:

object Conversions {
  def toBindingSeq[A](data: Binding[Iterable[A]]): BindingSeq[A] =
    Constants(Binding(Constants(data.bind.toSeq: _*))).flatMap(_.bind)
}
implicit class Wrapper[A](val seqInBinding: Binding[Iterable[A]]) extends AnyVal {
  def bindingSeq: BindingSeq[A] = Conversions.toBindingSeq(seqInBinding)
}

from binding.scala.

Axiometry avatar Axiometry commented on June 12, 2024

I've created a separate issue for the implicit value class error: #300

from binding.scala.

Atry avatar Atry commented on June 12, 2024

Could not find proxy for ...

This is definitely a Scala compiler bug

from binding.scala.

Atry avatar Atry commented on June 12, 2024

vars.all.bind was fixed in #302

from binding.scala.

Related Issues (20)

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.