by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 09:29
    nicolasstucki synchronize #8940
  • 09:25
    nicolasstucki synchronize #8940
  • 09:25
    odersky synchronize #9333
  • 09:09
    AleksanderBG commented #9274
  • 08:56
    TheElectronWill synchronize #9271
  • 08:17
    odersky synchronize #9333
  • 08:04
    odersky synchronize #9333
  • 07:29
    PengLoveHONG starred lampepfl/dotty
  • 05:58
  • Jul 09 23:55
    liufengyun synchronize #9335
  • Jul 09 22:28
    liufengyun synchronize #9335
  • Jul 09 22:14
    liufengyun synchronize #9335
  • Jul 09 21:49
    smarter commented #9271
  • Jul 09 21:49
    liufengyun synchronize #9335
  • Jul 09 21:42
    TheElectronWill commented #9271
  • Jul 09 21:22
    liufengyun synchronize #9335
  • Jul 09 21:07
    Cackbone starred lampepfl/dotty
  • Jul 09 20:48
    TheElectronWill commented #9271
  • Jul 09 20:48
    TheElectronWill commented #9271
  • Jul 09 20:47
    TheElectronWill review_requested #9271
Guillaume Martres
@smarter
up-to-date getting started info at http://dotty.epfl.ch/docs/usage/getting-started.html
Swoorup Joshi
@Swoorup
the documention seems a bit sparse. I tried creating a sample project.
~/learn/sbt on ☁️  saml took 5s
❯ sbt launchIDE
[info] welcome to sbt 1.3.12 (Private Build Java 14.0.1)
[info] loading project definition from /home/sjoshi/learn/sbt/project
[info] set current project to sbt (in build file:/home/sjoshi/learn/sbt/)
[error] Expected ';'
[error] Not a valid command: launchIDE
[error] Not a valid project ID: launchIDE
[error] Expected ':'
[error] Not a valid key: launchIDE
[error] launchIDE
[error]          ^
Guillaume Martres
@smarter
are you in the correct directory? when using "sbt new", a new directory is created for the project, you have to cd in that directory before running sbt again
Alexander Konovalov
@alexknvl
@nicolasstucki haha that label :P
I hope I am not annoying anyone with my fuzzing results
or at least not too much :)
they are sometimes so weird and require such a cascade of compiler errors to trigger that I am not sure I could come up with a real-life example
Guillaume Martres
@smarter
@Swoorup anyway, if you're completely new to Scala, I suggest looking for a resource that teaches you Scala from the ground up, there's no Scala 3 specific material for that yet, but a lot of things you'll find in existing Scala 2 tutorials is still valid, check out https://docs.scala-lang.org/overviews/scala-book/introduction.html for example
@alexknvl :heart:
Alexander Konovalov
@alexknvl
that's like 5 compiler errors in a row :sweat_smile:
Guillaume Martres
@smarter
maybe if someone's cat run over their keyboard while using an IDE.
Alexander Konovalov
@alexknvl
I have amassed over 170k snippets that compile with the current compiler :tada: 28 more crashes to investigate
takes about a day or two for me to recompile all of them from scratch :sweat_smile:
Guillaume Martres
@smarter
damn
this is all done using an RNN right?
Alexander Konovalov
@alexknvl
and some heuristics like "select a random interesting snippet (in terms of branch coverage) and randomly cross it over with the current snippet"
Guillaume Martres
@smarter
maybe we should train GPT-2 on a Scala corpus
Alexander Konovalov
@alexknvl
e.g. put them side by side and then try to reduce the number of identifiers
Guillaume Martres
@smarter
how do you measure branch coverage?
Alexander Konovalov
@alexknvl
instrumentation by a java agent
I have a "build server" that handles http requests, creates a new compiler context, collects branch coverage info and any error messages and sends it back to a python process
Guillaume Martres
@smarter
ooh neat I hadn't seen this
have you tried to use it to actually fuzz the compiler?
Alexander Konovalov
@alexknvl
@smarter not yet, haha, even though I have known about it for years now :sweat_smile:
it's really impressive when it fuzzes jsoup
pretty quickly finds a ton edge cases
to do it more efficiently, I think there is a way to start from a small initial corpus of samples with maximized coverage
Swoorup Joshi
@Swoorup
thank you @smarter
quick q, how do you pattern match on something like this:
var testVar: String | Integer = 1
Alexander Konovalov
@alexknvl
testVar match { case s: String => ...; case i: Int => ... }
Guillaume Martres
@smarter
Yeah and you should use Int instead of Integer
Swoorup Joshi
@Swoorup
Awesome, i realized union types were introduced in dotty, wouldn't union types be preferred over enums, and the inheritance way of doing sum types more now? Any cases why one would still use enums or code like this
  sealed trait List[+A]
  final case class Empty() extends List[Nothing]
  final case class Cons[+A](h: A, t: List[A]) extends List[A]
1 reply
Alexander Konovalov
@alexknvl
List[A] can have methods on it
I am not sure how Dotty handles methods on Empty | Cons[A]... I guess you could very carefully make them have the same methods.
Guillaume Martres
@smarter
union types are rarely a good idea.
Alexander Konovalov
@alexknvl
and type List[A] = Unit | (A, List[A]) would not compile
Guillaume Martres
@smarter
things will work out much better if you define an ADT, in dotty that can be done using enum, otherwise it can be done using a trait and children classes as you mentioned
Swoorup Joshi
@Swoorup
I see, I wasn't aware of the things mentioned above. In that case it does make sense. I do see the value of them in message based systems though, particularly highlighted by this comment: https://github.com/fsharp/fslang-suggestions/issues/538#issuecomment-279976406
Guillaume Martres
@smarter
Yeah there's some uses for them
Swoorup Joshi
@Swoorup
any rough ideas, as to when scala 3 will be released this year?
Guillaume Martres
@smarter
Plan is end of the year.
kc1212
@kc1212

Hi, what's the best way to create a group (something with unit, combine and inverse) typeclass and instantiate it using integer modulo some number? For example I have something like:

  trait SemiGroup[T] {
    extension (x: T) def combine(y: T): T
  }

  trait Monoid[T] extends SemiGroup[T] {
    def unit: T
  }

  trait Group[T] extends Monoid[T] {
    extension (x: T) def inverse: T
  }

  given Group[Int]:
    def unit = 0
    extension (x: Int) def combine(y: Int) = x + y
    extension (x: Int) def inverse = -x

If I want to implement integer modulo 7, a naive way is to do

case class ModInt7(x: Int, m: Int) {
  def add(y: ModInt7) = ModInt7((x + y.x) % m, m)
  def inv = ModInt7((-x) % m, m)
}
given Group[ModInt7]:
  def unit = ModInt7(0, 7)
  extension (x: ModInt7) def combine(y: ModInt7) = x.add(y)
  extension (x: ModInt7) def inverse = x.inv

what's the way to generalise this to modulo any number?

Guillaume Martres
@smarter
@kc1212 here's one way to do it:
trait SemiGroup[T] {
  extension (x: T) def combine(y: T): T
}

trait Monoid[T] extends SemiGroup[T] {
  def unit: T
}

trait Group[T] extends Monoid[T] {
  extension (x: T) def inverse: T
}

trait GroupMod[N <: Int] extends Group[Int] {
  def unit: N
  extension (x: Int) def combine(y: Int) = (x + y) % unit
  extension (x: Int) def inverse = (-x) % unit
}

given [N <: Int : ValueOf] as GroupMod[N] {
  val unit: N = valueOf[N]
}

def foo(x: Int, y: Int)(using GroupMod[7]): Int =
  x.combine(y)

@main def Test =
  println(foo(10, 3))
kc1212
@kc1212
I didn't know values are subtypes of their type, good to know!
Guillaume Martres
@smarter
@deusaquilus I'm not sure what you mean by "uniquely identify an Ident"
do you need to distinguish between a.x and b.x, if they both point to the same symbol for x?
do you care about local definitions? (e.g. inval x = { val a = ...; a }, a is local)