Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 11:46
    julienrf commented #782
  • 11:22
    Kordyjan synchronize #1284
  • 10:44
    marc0der commented #782
  • 09:54
    bjornregnell commented #782
  • 09:51
    marc0der commented #782
  • 09:33
    Kordyjan synchronize #1284
  • 09:33
    Kordyjan synchronize #1284
  • 09:33
    Kordyjan synchronize #1284
  • 08:59
    Kordyjan synchronize #1284
  • 06:40
    julienrf commented #782
  • 00:20

    SethTisue on 2.12.x

    2.12: advance project SHAs (#14… (compare)

  • 00:20
    SethTisue closed #1498
  • Oct 19 22:37
    SethTisue edited #1498
  • Oct 19 22:36
    SethTisue synchronize #1498
  • Oct 19 22:36
    SethTisue edited #1498
  • Oct 19 22:36
    SethTisue edited #1498
  • Oct 19 19:58
    SethTisue synchronize #1498
  • Oct 19 18:28
    SethTisue edited #1498
  • Oct 19 18:28
    SethTisue labeled #1498
  • Oct 19 18:28
    SethTisue assigned #1498
Jan Bessai
@JanBessai
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]] = ???
}
And I think I know what causes this ... I now recall asking this before. I think it's a problem with partial unification.
This doesn't raise errors when F0[a] is the last parameter.
Harrison Houghton
@hrhino
@martijnhoekstra it's a bug because when the rewrite happens, the setter is referenced by name, not by symbol
or at least, that's what I'd say
Martijn Hoekstra
@martijnhoekstra
I'd say the same, but the spec surprised me before. Then again, if this is as specced, I'd argue it's a bug in the spec and the implementation both
Harrison Houghton
@hrhino
If x is a parameterless method defined in some template, and the same template contains a setter method x_= as member, then the assignment x = e is interpreted as the invocation x_=(e) of that setter method. Analogously, an assignment f.x = e to a parameterless method x is interpreted as the invocation f.x_=(e).
hmm, so, that's vaguely ambiguous since x is a symbol, not a name, but it doesn't explain what a "setter method" is
other than that in this case x's setter method is x_=

when it comes to imports,

If x is bound by an import clause, then the simple name x is taken to be equivalent to the qualified name to which x is mapped by the import clause.

which is also kinda ambiguous

but I would argue that on the whole, if some expression works with a non-renaming import, it should work with the renaming import modulo α-conversion of the name within the scope of the import
Martijn Hoekstra
@martijnhoekstra

If x is a parameterless method defined in some template, and the same template contains a setter method x_= as member

if you import rename x => y, that doesn't change that the template doesn't contain a setter method x_=

so I'd call it a bug in both spec and impl :D
Harrison Houghton
@hrhino
right...
although that's not the correct spot, because that's the bit that deals with class T { var x = 1 ; x = 2 }
the "analogously..." sentence is the applicable one
I would say it should define "setter method" as "the method in the same template with the name derived from x by appending _=", or something
Klas Segeljakt
@segeljakt
What type of polymorphism is:
def func[A,B,C](a: A, b: B, c: C) = ...
func(3, "abc", 'o')
Harrison Houghton
@hrhino
then the method has a setter method...
@klassegeljakt just your bog standard parametric polymorphism.
Martijn Hoekstra
@martijnhoekstra
I'll leave you to the specese. gl;hf
Harrison Houghton
@hrhino
nah
I'd rather just fix the bug, and let others write the specese
Klas Segeljakt
@segeljakt
ok, what type of polymorphism is
def func[T](l: T*) = ...
func(3, "abc", 'o')
Harrison Houghton
@hrhino
Exact same.
Parametric polymorphism is polymorphism done with type parameters, hence the name
Fabio Labella
@SystemFw
well, that case is weird
well, not weird