Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 26 07:25
    oskin1 starred fthomas/singleton-ops
  • Nov 23 04:44

    soronpo on master

    Update sbt to 1.4.4 Merge pull request #164 from sc… (compare)

  • Nov 23 04:44
    soronpo closed #164
  • Nov 23 02:40
    codecov[bot] commented #164
  • Nov 23 02:40
    codecov[bot] commented #164
  • Nov 23 02:39
    codecov[bot] commented #164
  • Nov 23 02:31
    scala-steward opened #164
  • Nov 22 06:45
    wanganran starred fthomas/singleton-ops
  • Nov 16 17:25

    soronpo on master

    Update sbt to 1.4.3 Merge pull request #163 from sc… (compare)

  • Nov 16 17:25
    soronpo closed #163
  • Nov 16 04:29
    codecov[bot] commented #163
  • Nov 16 04:28
    codecov[bot] commented #163
  • Nov 16 04:27
    codecov[bot] commented #163
  • Nov 16 04:19
    scala-steward opened #163
  • Nov 15 20:37

    soronpo on master

    Update sbt-scalajs, scalajs-com… Merge pull request #162 from sc… (compare)

  • Nov 15 20:37
    soronpo closed #162
  • Nov 15 16:03
    codecov[bot] commented #162
  • Nov 15 16:02
    codecov[bot] commented #162
  • Nov 15 16:01
    codecov[bot] commented #162
  • Nov 15 15:54
    scala-steward opened #162
Oron Port
@soronpo
Again, from what it looks like you're trying to call a "safe" constructor without the proper implicits
I assume SizedLized[]() has implicits....
Soren
@srnb_gitlab
Yeah
package tf.bug.matrix

import singleton.ops._

case class SizedList[N <: XInt, +T](unsafe: List[T])(
    implicit n: SafeInt[N],
    check: Require[N >= 0]
) {

  def apply[I <: XInt](
      i: I
  )(implicit check1: Require[I >= 0], check2: Require[I < N]): T = unsafe(i)

  def cut[I <: XInt](
      i: I
  )(
      implicit check1: Require[I >= 0],
      check2: Require[I < N],
      check3: Require[N > 0],
      outSize: SafeInt[N - 1]
  ): SizedList[outSize.Out, T] =
    SizedList[outSize.Out, T](unsafe.zipWithIndex.collect {
      case (e, n) if n != i => e
    })

}
Why can't SafeInt[T].Out <: T?
sounds like it'd fix a lot of this
and let me mainly write safe code
And why wouldn't N <: XInt prove SafeInt[N - 1].Out <: XInt?
Oron Port
@soronpo
It's not it. It's that you don't have a proof of SafeInt[outSize.Out]
remove the implicit from your case class
make the constructor private
and create a public constructor with the guard
There is no way around this
Soren
@srnb_gitlab
Why doesn't SafeInt[T].Out <: T then?
Like what problems arise if that's assumed
Oron Port
@soronpo
The compiler cannot possibly know this via a macro system
Soren
@srnb_gitlab
Can the macro system not specify that Out <: T in this specific case? Or no because it's just an extension of the Ops thing
Oron Port
@soronpo
All it knows is that Out <: XInt
That's the definition of the Op trait's type
Soren
@srnb_gitlab
Alright
Hopefully by rewriting this project I don't fall into implicits not being resolved like I did last time
Oron Port
@soronpo
I suggest you don't use <: XInt at all. No need for it IMO.
Soren
@srnb_gitlab
Ok
Frank S. Thomas
@fthomas
FYI: operations on singleton types in Dotty: lampepfl/dotty#7628
Oron Port
@soronpo
Nice!!!
I'll dive into that. It is my goal to not require singleton-ops in the future.
Oron Port
@soronpo
@fthomas can you please issue a new release? I fixed an annoying scalac bug via workaround.
Frank S. Thomas
@fthomas
@soronpo Done! 0.4.1 should be on Maven Central soon
Oron Port
@soronpo
Thanks!
Balázs Kossovics
@kosii
Hey! Now that scala 2.13.1 is out, are we still supposed to use typelevel scala?
Oron Port
@soronpo
First, it's actually worked in regular Scala as well, but required extra syntx to express literal types. But now with 2.13.x you can use freely without any special flags hassle.
Balázs Kossovics
@kosii
Cool! I'm just playing around with singleton-ops, cool stuff, but I was wondering, if something like this was possible?
import singleton.ops.{+, ==, Require, XInt}

sealed trait StaticLengthList[L <: XInt]

object StaticLengthList {
  case object Nil extends StaticLengthList[0]

  //Error:(12, 82) type arguments [L + 1] do not conform to trait StaticLengthList's type parameter bounds [L <: singleton.ops.XInt]
  //  final case class Cons[L <: XInt](head: Int, tail: StaticLengthList[L]) extends StaticLengthList[L + 1] {}
  final case class Cons[L <: XInt](head: Int, tail: StaticLengthList[L]) extends StaticLengthList[L + 1] {}

  final case class Cons2[L <: XInt, T <: XInt](head: Int, tail: StaticLengthList[L])(implicit p : Require[L+1 == T]) extends StaticLengthList[T] {}

  //Error:(16, 38) Literal operation has failed.
  //  val myList = StaticLengthList.Cons2(1, StaticLengthList.Nil)
  val myList = StaticLengthList.Cons2(1, StaticLengthList.Nil)
}
Balázs Kossovics
@kosii
oh, actually Cons2[0, 1] works
Oron Port
@soronpo
@kosii
I suggest you remove the implicit from the case class, make the unsafe constructor private and create a public apply method that does the implicit checks.
Oron Port
@soronpo
@fthomas can you please issue a release for 0.4.2? BTW, I don't know how complicated it is to setup for bintray, but the sbt-ci-release plugins for Sonatype is fairly easy to setup so just a push of a tag will issue a release.
Frank S. Thomas
@fthomas
@soronpo Let's set up sbt-ci-release with Sonatype and get rid of Bintray. I'm already using it in a couple of other projects and I'm loving it
Frank S. Thomas
@fthomas
sbt-ci-release is set up now. @soronpo you should be able to release 0.4.2 yourself by running ./scripts/release.sh 0.4.2
Note that the release script does not update the version number in the README
Oron Port
@soronpo
@fthomas I was meaning to mention this to you
Is it possible to add support for Scala Steward to update a readme of a project once its final binaries are available?
Oron Port
@soronpo
@/all I recommend v0.5.0 https://github.com/fthomas/singleton-ops/releases/tag/v0.5.0
It can potentially save ~20% in compilation time for Scala 2.13.x users (compared to previous versions). Other Scalac versions also get performance bump.
Peng Cheng
@tribbloid
Sorry, is there an easy way to summon value from computed type?
Like in shapeless:
    type T1 = W.`3`.T

    val v1 = implicitly[Witness.Aux[T1]]
    assert(v1 == 3)
the same trick can't deceive the compiler:
    type T2 = T1 + W.`4`.T

    val v2 = implicitly[Witness.Aux[T2]]
    assert(v2 == 7)
could not find implicit value for parameter e: shapeless.Witness.Aux[T2]
one error found
Peng Cheng
@tribbloid
ok found it, much easier than I thought:
    val v2 = implicitly[T2]
    assert(v2.value == 7)
Oron Port
@soronpo
Hi all! After #149 lands, look at the cool stuff you can do. https://twitter.com/soronpo/status/1275014596034809856
Oron Port
@soronpo
If someone is using IntelliJ and is looking for a nice way to contribute, it would be nice if we had a dedicated extension to the IntelliJ scala plugin for singleton-ops.
https://github.com/JetBrains/intellij-scala/wiki/Library-Extensions
This will allow us to get proper error markings within the editor before we even need to compile.
Oron Port
@soronpo
@fthomas Do you have an idea why the CI isn't running for #157 ?
Frank S. Thomas
@fthomas
I had similar problems with other projects that still used travis-ci.org. I just migrated it to https://travis-ci.com/github/fthomas/singleton-ops. If you push something now, it should trigger a new build
Oron Port
@soronpo
Yeah, working now. Thanks.