Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 00:43
    lsrcz starred fthomas/singleton-ops
  • Sep 22 18:58

    fthomas on master

    Update sbt-ci-release to 1.5.9 Merge pull request #214 from sc… (compare)

  • Sep 22 18:58
    fthomas closed #214
  • Sep 22 18:53
    codecov[bot] commented #214
  • Sep 22 18:52
    codecov[bot] commented #214
  • Sep 22 18:52
    codecov[bot] commented #214
  • Sep 22 18:45
    scala-steward opened #214
  • Sep 17 16:19
    alhuelamo starred fthomas/singleton-ops
  • Sep 16 11:54

    fthomas on master

    Update sbt-scoverage to 1.9.0 Merge pull request #213 from sc… (compare)

  • Sep 16 11:54
    fthomas closed #213
  • Sep 16 11:28
    codecov[bot] commented #213
  • Sep 16 11:28
    codecov[bot] commented #213
  • Sep 16 11:26
    codecov[bot] commented #213
  • Sep 16 11:21
    scala-steward opened #213
  • Sep 15 02:51

    soronpo on master

    Update scala-library to 2.12.15 Regenerate workflow with sbt-gi… Merge pull request #212 from sc… (compare)

  • Sep 15 02:51
    soronpo closed #212
  • Sep 14 21:03
    codecov[bot] commented #212
  • Sep 14 21:02
    codecov[bot] commented #212
  • Sep 14 21:01
    codecov[bot] commented #212
  • Sep 14 20:55
    scala-steward opened #212
Soren
@srnb_gitlab
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 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 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 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 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.
3 replies
Oron Port
@soronpo
@fthomas Do you have an idea why the CI isn't running for #157 ?
Frank 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.
Oron Port
@soronpo
Is anyone using the literal operations for Float and Double? I don't feel like there is a justification enough to continue to include them. There will be a while before I find the time to do some required refactoring of the library, but when I do, I'm strongly considering letting them go. Please speak up if you think otherwise.
Peng Cheng
@tribbloid
Hi @soronpo , I'm the maintainer of shapesafe. Do you know how ops.GetType[Sym] can be used in deduction?
asking because:
  type RequireMsgSym[Cond,Msg,Sym] = OpMacro[OpId.Require, Cond, Msg, GetType[Sym]]
I can only use RequireMsg[Cond,Msg to customise compile-time error message, but once I switch to RequireMsgSym it always fall back to default error message "could not find implicit value for ..."
Oron Port
@soronpo
What do you mean by deduction. The Sym version is for providing the trait that gets the custom implicitNotFound error message. However it's already determined automatically quite well so it's there mainly for legacy and just in case something does not work.
Peng Cheng
@tribbloid
@soronpo I see, that explain it, in the unit test the last arg of RequireMsgSym always has an @implicitNotFound annotation
Peng Cheng
@tribbloid
thanks a lot, but is it really obsolete? RequireMsg only accepts a string literal as the message, while @implicitNotFound message supports interpolation from type parameters:
@implicitNotFound(msg = "Cannot prove that ${From} =:= ${To}.")
sealed abstract class =:=[From, To]
Oron Port
@soronpo
The intended Sym is not for that. It's for tge missed class or trait =:= in your example
The custom message is constructed using type string operations.
Peng Cheng
@tribbloid
That's a very convoluted way of constructing compilation error :)
but very flexible. It definitely fits in my case
Peng Cheng
@tribbloid
I'd like to just add one more feature to better support the RequireMsg case: fthomas/singleton-ops#182 Do you think it is a valid point?
Oron Port
@soronpo
I responded on the issue
Peng Cheng
@tribbloid
@soronpo Are you already upgrading to shapeless 3?
Peng Cheng
@tribbloid
Sorry nevermind, just realise shapeless 3 is not backward compatible :-|
Oron Port
@soronpo
I'm experimenting to see if singleton-ops still has merit in Scala3
Oron Port
@soronpo
Created a new dotty PR and opened a discussion on a new SIP, to remove any need for the singleton-ops library in Scala 3:
lampepfl/dotty#13400
Peng Cheng
@tribbloid
@soronpo replied
@soronpo if that conference sounds interesting, I'll try to schmooze out a ticket and mail it to you