Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 18 22:52

    xuwei-k on xuwei-k-patch-1

    (compare)

  • Jun 18 22:52

    xuwei-k on main

    Create CODEOWNERS https://docs… (compare)

  • Jun 18 22:52
    xuwei-k closed #2084
  • Jun 18 20:45
    jacobus commented #1248
  • Jun 18 20:01

    eed3si9n on main

    Update scala-for-java-programme… Merge pull request #2060 from h… (compare)

  • Jun 18 20:01
    eed3si9n closed #2060
  • Jun 18 19:54
    xuwei-k commented #2059
  • Jun 18 19:54
    xuwei-k review_requested #2084
  • Jun 18 19:54
    xuwei-k review_requested #2084
  • Jun 18 19:54
    xuwei-k opened #2084
  • Jun 18 19:53

    xuwei-k on xuwei-k-patch-1

    Create CODEOWNERS https://docs… (compare)

  • Jun 18 16:13
    SethTisue commented #12416
  • Jun 18 16:10
    SethTisue commented #2059
  • Jun 18 15:27
    smarter closed #12416
  • Jun 18 15:27
    smarter commented #12416
  • Jun 18 15:24
    chrislailee opened #12416
  • Jun 18 07:24
    dwijnand edited #9672
  • Jun 18 03:01
    jxnu-liguobin commented #2059
  • Jun 18 02:54
    jxnu-liguobin commented #2059
  • Jun 18 02:50
    som-snytt edited #9672
sinanspd
@sinanspd

a structural method call is reflective

correct

I might give it a shot and try to implement this and see where it blows up
might be a good learning experience
much easier to pull off in TS
i also wonder if Haskell has something like this
Martijn
@martijnhoekstra:matrix.org
[m]
a key point here is that overriding semantically does dynamic dispatch which at runtime works by being a built-in feature of the JVM, but when you do structural typing, you don't have a nominal compile-time subclassing so you don't have dynamic dispatch
A better general strategy to accomplish similar results is through encoding capabilities through typeclasses (that may be automatically derived, either by macro or, in scala 3, as a language feature)
sinanspd
@sinanspd

a key point here is that overriding semantically does dynamic dispatch which at runtime works by being a built-in feature of the JVM, but when you do structural typing, you don't have a nominal compile-time subclassing so you don't have dynamic dispatch

true but you also don't need to change the entire type system. Like TypeScript you can fall back to structural typing only when you need to. In case of a proxy, I think it is not entirely unreasonable as how the method calls will be dispatched are set in stone

A better general strategy to accomplish similar results is through encoding capabilities through typeclasses (that may be automatically derived, either by macro or, in scala 3, as a language feature)

I 100% agree with this. Mine is a mere curiosity of implications of this on the type system

the back story of this is I have been looking into imposters and chaperones from Racket. They are extremely powerful constructs and they are the perfect solution for problems Java people have been trying to solve using IFC which never worked
sinanspd
@sinanspd
I was curious how one would port them into a strongly typed language and where ever I looked, I hit reflection. That would be solving one problem by introducing even a worse one so...
cmhteixeira
@cmhteixeira
@sinanspd Literally yesterday, I posted on this channel a Scala macro annotation to accomplish just that: Achieve the delegate pattern at compile time. Have a look at the code. repo: https://github.com/cmhteixeira/delegate-macro
sinanspd
@sinanspd
@cmhteixeira I saw that but this is not the same proxying as Java's proxys or imposters/chaperones
and as far as I can see it still doesn't give a solution to interchangeable types.
But I will take a look at the code this weekend. At the very least it can be a good starting point for me so thank you for sending it over :)
Jim Newton
@jimka2001
Can someone remind me what is the correct way to execute a for comprehension for side effect? My code does not execute any of the assertions here.
    for{ v <- List("a","b","c","d","0","-1")}
      {
        println(s"testing with $v")
        assert(dfa5a.simulate(Seq(v)) == dfa5ac.simulate(Seq(v)))
        assert(dfa5b.simulate(Seq(v)) == dfa5bc.simulate(Seq(v)))
      }
Martijn
@martijnhoekstra:matrix.org
[m]
works for me @jimka2001
Jim Newton
@jimka2001
I get nothing printed at all.
IntelliJ underlines the for, and I don't know why. maybe this is some sort of warning, but there's no hover text
Screenshot 2021-06-10 at 10.24.35.png
ahhh, I found it. my fault. the text was hidden inside a lot of other debugging test.
Martijn
@martijnhoekstra:matrix.org
[m]
ah, no worries
Jim Newton
@jimka2001
I do wonder why IntelliJ is underlining the for though.
JohnGurin
@JohnGurin

Hi everybody. Can someone explain why a companion object allows

To get rid of the summon[...] ...
https://dotty.epfl.ch/docs/reference/contextual/type-classes.html#semigroups-and-monoids

zeroexcuses
@zeroexcuses
Is there any good example of prolog embedded in scala as a DSL?
Nikitha963
@Nikitha963

Hi All,

templatesImport ++= Seq(
        "views.html.helper._",
        "polaris._",
        "polaris.api._",
        "polaris.models._",
        "polaris.core._",
        "polaris.core.util._",
        "polaris.core.views.html._"
)

I have above syntax in multi project module in build.sbt file and getting below error:

build.sbt:29: error: not found: value templatesImport
templatesImport += Seq(
^

Kindly help me here . I tried to write like :

TwirlKeys.templateImports ++= Seq(
        "views.html.helper._",
        "polaris._",
        "polaris.api._",
        "polaris.models._",
        "polaris.core._",
        "polaris.core.util._",
        "polaris.core.views.html._"
)

Then also I am facing the issue like below :

[error] References to undefined settings: 
[error] 
[error]   pbxAppPhonebook/*:twirlTemplateImports from pbxAppPhonebook/*:twirlTemplateImports (/home/nikitha/Documents/Polaris/polaris_sbt_play_scala_upgrade_version/polaris-upgrade-sbt-1.3.0/modules/pbx-app-phonebook/build.sbt:20)
[error]
Gabriel Klappenbach
@klappenbach
Hello! In earlier releases of the Dotty compiler there was the -decompile flag to convert a tasty file into source code. I can no longer find that flag or how to decompile into source code in the latest scala 3 compiler... how is this done now?
Swoorup Joshi
@Swoorup
what do people use to package/dockerize scala application? (New to tooling)
Hanns Holger Rutz
@Sciss

How do you express this in "braceless" Scala 3:

        sl.reactions += {
          case ValueChanged(_) => synth.set("pitch" -> sl.value)
        }

?

where the argument is a PartialFunction literal

or similarly with a Function1 argument:

   Server.run(cfg) { s =>
      ...
  }

I tried : and with and do, but that doesn't seem to be accepted

and thunk arg (=> Unit) like

onEDT {
   bla
   blub
}

how to remove the braces?

rimeh bennjima
@rimeh-bennjima

Hi @here,

object webSocketSpec extends MessagingSpec with RestCall {
override def is: SpecStructure = "Specification to check the messaging".title ^ sequential ^
    s2"""
          UserCreatedMessage    ${e1.pendingUntilFixed}
      """


override def userId: UserId = PostUser("user1")
override def token: String = postSession("admin")


def e1 = todo

}


abstract class MessagingSpec  extends TestKit(ActorSystem("messagingTests"))
    with ImplicitSender
    with SpecificationLike
    with ClassLogging {

  def userId: UserId
  def token: String

....
}

when I run the spec I find that the content of userId and token is null, because the run of the two methods postUser and postSession not yet completes.
are there any propositions to wait for the termination of the two methods and take the correct values?

Hanns Holger Rutz
@Sciss
ok, i think i would need language.experimental.fewerBraces and this is not available in regular scala version...
Rob Norris
@tpolecat
@zeroexcuses I think @stewSquared has a mini-kanren implementation, check his gh
Guillaume Martres
@smarter

@Sciss Your second example can be written using parens instead of braces:

  Server.run(cfg)(s =>
      ...
  )

because => starts an indentation region

Hanns Holger Rutz
@Sciss
ok
well I hope fewerBraces becomes official :) especially for thunks it's nice
writing anonymous classes in swing looks nice now
new Frame:
  title = "bla"
  contents = new Slider:
    min = 10
    max = 1234
Rob Norris
@tpolecat
Yes. It’s not Prolog but it’s a logic-programming system that can do the same kinds of things.
Swoorup Joshi
@Swoorup
you can get rid of the name of the trait as well if you specify return type in your function signature
new:
  title = "bla"
  contents = new Slider:
    min = 10
    max = 1234
Rob Norris
@tpolecat
@zeroexcuses Also note that implicit search in Scala is a similar idea. Type-level computations are done by searching, and you can solve [simple] logic problems by encoding them in the type system.
Jim Newton
@jimka2001
A couple of days, someone suggested I get rid of a 0-ary method and replace it with an optional/default argument.
When I tried to implement the suggestion, I realize I don't know how to do it. Can someone suggest how to do this? I have method toDfa which a type parameter E. When E=Boolean. I have a default value of true. Is it possible to write this as one single method?
  def toDfa():Dfa[Any,SimpleTypeD,Boolean] = {
    toDfa(true)
  }
  def toDfa[E](exitValue:E):Dfa[Any,SimpleTypeD,E] = {
    val (rtes,edges) = try {
      derivatives()
    }
    catch {
    ...
Rob Norris
@tpolecat
Yes if you say exitValue: E = true it will default both the value and the type.
Jim Newton
@jimka2001
oh really, but I'll still have a generic method for other types, without a default? that/s cool
Rob Norris
@tpolecat
Yes. If you make that change and delete the nullary overload your program should compile and work the same way.
octeep
@octeep:m.octeep.xyz
[m]
Is there a monadic parser library in Scala that allows parsing other data types besides String? Specifically I'm looking for something to parse binary data.
Jim Newton
@jimka2001
bravo to the compiler developer who had that bright idea!