Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 20:34
    apointeau review_requested #2263
  • 20:20
    liliatangxy opened #12510
  • 19:55
    SethTisue closed #1504
  • 19:55
    SethTisue commented #1504
  • 19:23
    SethTisue commented #1516
  • 19:23

    SethTisue on 2.13.x

    advance scalafx (#1516) (compare)

  • 19:23
    SethTisue closed #1516
  • 19:14
    SethTisue commented #1516
  • 19:13
    SethTisue commented #1516
  • 19:13
    SethTisue commented #1516
  • 19:13
    SethTisue ready_for_review #1516
  • 19:13
    SethTisue commented #1516
  • 19:12
    SethTisue synchronize #1516
  • 19:11
    SethTisue commented #1516
  • 19:11
    SethTisue commented #1516
  • 19:11
    SethTisue commented #1516
  • 19:11
    SethTisue commented #1516
  • 19:11
    SethTisue edited #12509
  • 19:10
    SethTisue edited #12509
  • 19:04
    SethTisue commented #1516
Li Haoyi
@lihaoyi
spark does runtime java source generation and it’s not bad; compiles fast enough, JITs down to fast assembly and is easier for most people to debug than malformed blobs of bytecode
Klas Segeljakt
@segeljakt
What does hygienic mean?
with quasiquotes :D
Li Haoyi
@lihaoyi
it means when you call a function foo in a quasiquote, the macro generated code calls the function foo that is lexically in scope where the quasiquote was defined, not whatever random foo may be in scope at the macro callsite
Gabriel Claramunt
@gclaramunt
@mtsouko_twitter since you can only mix one abstract class and many traits as you want, I try to use traits as much as I can... abstract classes is for when you really want OO and is a reasonable hierarchy
Justin du Coeur, AKA Mark Waks
@jducoeur
Yeah -- I tend to favor traits by default, unless I want constructor parameters or have some other reason to specifically want a class.
Fabio Labella
@SystemFw
abstract classes can have parameters, that's a big point (it will change though). They are also better for bincompat in 2.11, if you're writing a library
Rob Norris
@tpolecat
Once trait parameters exist get ready for "why do we even have classes?"
Elikar Ibn Mtsouko
@mtsouko_twitter
What were the design reasons behind not giving traits parameters in the first place?
Rob Norris
@tpolecat
Same reasoning as class/interface in Java I imagine.
nafg
@nafg
@klassegeljakt if the reason is JVM startup time, you may want to look into scala-native or Graal VM
Klas Segeljakt
@segeljakt
Ok I'll take a look
If you know any more libs please let me know 🙏
Rob Norris
@tpolecat
I guess I should own up to writing a cursed DSL. Take it as a warning https://github.com/tpolecat/basic-dsl
Miguel Pérez Pasalodos
@mpasa
That is just great :smile:
Hanns Holger Rutz
@Sciss

Is there a way to constrain a Double to "just smaller than 1.0" such that (aDouble * aPositiveInt).toInt < aPositiveInt is guaranteed to hold? I.e. I don't want to perform that check after each multiplication. Like I can empircally get a very long literal:

assert (0.999999999999999944488848768742172978818416595 < 1)

assert ((0.999999999999999944488848768742172978818416595 * Int.MaxValue).toInt < Int.MaxValue)

But I wasn't patient enough to keep looking for the digits (seems there are more)

(Plus I'm afraid this might rely on the particular JVM, OS, or something)
Hanns Holger Rutz
@Sciss
This looks better: java.lang.Double.longBitsToDouble(0x3fefffffffffffffL) - comments?
Otto Chrons
@ochrons
yea, use longBitsToDouble, that's what I would use :)
Martijn Hoekstra
@martijnhoekstra
I think what you're asking is equivalent to the largest double smaller than 1.0. That's java.lang.Math.nextAfter(1.0, -1.0)
Otto Chrons
@ochrons
funny enough, I had exactly the same concern in my scheduling algorithm yesterday as it takes in 0.0 <= x < 1.0
and I needed to scale that to 0..N-1 where N is the number of input elements
Luciano
@lJoublanc

I'm writing a typeclass that should have an instance for a type refinement (using shapelss' Aux trick). However, I keep on getting this kind of compiler error when trying to instantiate the extension ops:

<console>:21: error: inferred kinds of the type arguments (Int,Int,res1.F[a],res1.O[k],res
1.U) do not conform to the expected kinds of the type parameters (type K,type V,type F,typ
e O,type U).
res1.F[a]'s type parameters do not match type F's expected parameters:
type F has one type parameter, but type F has one, res1.O[k]'s type parameters do not matc
h type O's expected parameters:
type O has one type parameter, but type O has one
       Series.Indexable.ops.toAllIndexableOps(res1)
                            ^

It seems nonsensical to me. Anybody got ideas how to fix this?

The above occurs when calling e.g. Series.Indexable.ops.toAllIndexableOps(res1)
Jan Bessai
@JanBessai
does it need to be called with rest1.F instead of res1.F[a] maybe?
can you try and make an example with minimal context?
abstract class A {
  protected def foo(): Unit
}

object X {
  def proxyA(x: A): A = new A { def foo() = x.foo() }
}
any idea why this yields
Test.scala:6: error: method foo in class A cannot be accessed in A
 Access to protected method foo not permitted because
 prefix type A does not conform to
 <$anon: A> where the access takes place
  def proxyA(x: A): A = new A { def foo() = x.foo() }
I feel this is confusing, since access happens within a subclass of A
Jan Bessai
@JanBessai
this is fixable with protected [somePackage], but I'm not sure I understand why it doesn't work without that
Martijn Hoekstra
@martijnhoekstra
I think (I'm not sure) that what you wrote is the moral equivalent to object X = { def foo() = x.foo }; new A with X
at least, that's the only way I can make sense of it, and it sounds sort of kind of consistent
no, that's nonsense
disregard that
Harrison Houghton
@hrhino
I think you can't access protected methods of a superclass if you can't prove that it's a subclass of your enclosing class.
hrhino @hrhino has spent way too much time pondering how exactly does a protected do.
Muhammad Asif Adnan
@MuhammadAsifAdnan
Any beginner friendly tutorial on how to build a web application with the play framework scala 2.6x ? Thanks
every tutorial i try to follow is outdated like it uses some library that is deprecated or its in java. im a beginner on web server technology so im thinking if i should change my track
Hanns Holger Rutz
@Sciss
@martijnhoekstra java.lang.Math.nextAfter looks good, thanks
Ichoran
@Ichoran
You can also use java.lang.Math.nextDown(1.0) to avoid the second sign argument (which can be confusing).
Martijn Hoekstra
@martijnhoekstra
+1
Ichoran
@Ichoran
Do be sure you use 1.0 and not 1! It's overloaded and will select the Float version if you use 1.
Hanns Holger Rutz
@Sciss
LOL, ok
Hanns Holger Rutz
@Sciss

Is there a way to make import aliasing work with setters. Like

class Foo { var bar = 0 }

def test1(f: Foo): Unit = {
  import f.{bar => baz}
  baz += 1  // no
}

def test2(f: Foo): Unit = {
  import f.{bar => baz, bar_= => baz_=}
  baz += 1  // no
}

?

Luciano
@lJoublanc
You can do something similar with Lenses/Optics (set/get)
Harrison Houghton
@hrhino
that's a bug
Luciano
@lJoublanc
But it doesn't use import, but rather a lens, declared as a val.
Harrison Houghton
@hrhino
the hint is telling:
<console>:15: error: value += is not a member of Int
  Expression does not convert to assignment because:
    value baz is not a member of Foo
    expansion: f.<baz: error> = f.baz.$plus(1)
         baz += 1  // no
             ^
please report it?
Martijn Hoekstra
@martijnhoekstra
def test1(f: Foo): Unit = {
  import f.{bar => baz}
  baz += 1  // no
}
sounds like it should work. I'd investigate if not working is not a bug.
Luciano
@lJoublanc
@JanBessai Thanks for your hint. I've managed to minimize the use case, as follows:
import simulacrum.typeclass

@typeclass trait MyTypeclass[F[_[a] <: Option[a]]] {
  def foo[A,G[a] <: Option[a],H[a] <: Option[a]](fa : F[G]) : F[H]
}

trait Test[A] {
  type F[a] <: Option[a]
  type B <: Int
}

object Test {

  type Aux[A,F0[a] <: Option[a], B0 <: Int] = Test[A] { type F[a] = F0[a] ; type B = B0 }

  def apply[A,F0[a] <: Option[a],B0 <: Int] : Aux[A,F0,B0] = new Test[A] { type F[a] = F0[a]  ; type B = B0 }

  implicit def instance[A,B] : MyTypeclass[Aux[A,?[_],B]] = ???
}