Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 09:18
    GusevTimofey starred mpilquist/simulacrum
  • Jan 29 2019 12:01
    mriceron starred mpilquist/simulacrum
  • Jan 25 2019 15:35
    shuttj starred mpilquist/simulacrum
  • Jan 19 2019 20:51
    driuzz commented #124
  • Jan 19 2019 17:54

    mpilquist on master

    Updated README for 0.15 release (compare)

  • Jan 19 2019 16:03

    mpilquist on v0.15.0

    (compare)

  • Jan 19 2019 16:03

    mpilquist on master

    Setting version to 0.15.0 Setting version to 0.15.1-SNAPS… (compare)

  • Jan 19 2019 15:16

    mpilquist on master

    Update scalatest to 3.0.6-SNAP6 Merge pull request #125 from sc… (compare)

  • Jan 19 2019 15:16
    mpilquist closed #125
  • Jan 19 2019 15:15

    mpilquist on master

    Update sbt-release to 1.0.11 Merge pull request #123 from sc… (compare)

  • Jan 19 2019 15:15
    mpilquist closed #123
  • Jan 19 2019 15:15

    mpilquist on master

    Add support for DocDef Add support for DocDef - test Disabled ScalaDoc generation on… and 2 more (compare)

  • Jan 19 2019 15:15
    mpilquist closed #124
  • Jan 19 2019 15:10
    mpilquist commented #124
  • Jan 19 2019 15:10
    mpilquist synchronize #124
  • Jan 19 2019 15:09
    mpilquist synchronize #124
  • Jan 19 2019 04:34
    wangpengwen starred mpilquist/simulacrum
  • Jan 18 2019 13:57
    scala-steward synchronize #125
  • Jan 18 2019 13:57
    scala-steward synchronize #123
  • Jan 18 2019 12:44

    mpilquist on master

    Future proof subtype evidence … Merge pull request #126 from jo… (compare)

Luciano
@lJoublanc
Ok - thank you for your help, I will raise a bug.
Sorry I can see now it has nothing to do with simulacrum. Wish I could learn to minimize problems as quickly as you've done!
Michael Pilquist
@mpilquist
scala> trait Ev[F[_]]
defined trait Ev

scala> object Foo { def apply[A <: Int] = 0; def apply[F[_]: Ev] = false }
defined object Foo

scala> Foo[3]
           ^
       error: 3 takes no type parameters, expected: one
That version is a bit more concise
The error only arises when one of the members has a higher kinded type param
Luciano
@lJoublanc
Thanks. I've got a couple of similar other probs which I will try to minimize; I see from this that there are issues with 2.13 still ...
Michael Pilquist
@mpilquist
@milessabin fyi ^^
Luciano
@lJoublanc
ty. I thought it was just my abysmal coding :laughing:
Miles Sabin
@milessabin
It looks like an overloading issue more than anything else ... could someone create an issue for it in scala/scala?
Michael Pilquist
@mpilquist
@lJoublanc Indeed, after a closer look, this is reproducible on 2.12 without singleton types. Like Miles said, it appears to be an overload resolution issue
Luciano
@lJoublanc
I will; I've also got something weird with
varargs and inference. I have a constructor where, if I pass it a single variable, it works, but if I pass it multiple variables, it fails. The bound is also [_ <: Int] and uses value types.
Will write up both of those today.
Michael Pilquist
@mpilquist
Do you mean singleton types?
Luciano
@lJoublanc
yes, sorry
Michael Pilquist
@mpilquist
Hm, that works for me:
scala> def foo[A <: Int](as: A*) = as.size
foo: [A <: Int](as: A*)Int

scala> foo[3](3, 3, 3)
res2: Int = 3
Luciano
@lJoublanc
So I have a Builder[N <: Int] { def apply[T,B](xs: T*)(implicit F: F.Aux[T,B]) : G[N,T,B] }
It is really strange, that it works with one param, but not more than one.
I've got it in my gitlab repo now. Will put some examples together today.
Michael Pilquist
@mpilquist
Here’s the previous issue on 2.12/2.13 w/o singleton types:
scala> object Foo {
     |   def apply[A]: Int = 0
     |   def apply[F[_]](implicit x: Int): Boolean = true
     | }
defined object Foo

scala> Foo[Int]
           ^
       error: Int takes no type parameters, expected: one
Luciano
@lJoublanc
Thanks for your help the other day. I've raised this and another compiler bug.

On a wholly separate issue, are there any quirks with doc generation and simulacrum? Do I need to adjust my build file somehow? I'm seeing the following when running sbt doc, although the source compiles fine.

[error] /home/luciano/src/spire-matrix/blas/src/main/scala/spire/blas/implicits.scala:11:58: type ToVectorOps is not a member of object spire.blas.dense.Vector
[error] package object implicits extends spire.blas.dense.Vector.ToVectorOps {
[error] ^
[info] No documentation generated with unsuccessful compiler run

The 'missing' member is of course not in the source file, but is generated by simulacrum. The file in question is on gitlab.

Luciano
@lJoublanc
Ah it's a known issue #82
And there is a link at the bottom to cats where this is broken for 2.13-M4, workaround is to disable doc :+1:
Peter Mortier
@kwark
I’m trying to get simulacrum to generate a typeclass for the following :
Unfortunately it fails with:
[error] /Users/peter/dev/cats-selective/core/src/main/scala/cats/Foo.scala:5:2: type mismatch;
[error]  found   : ff.type (with underlying type F[A => C])
[error]  required: F[A => B]
[error] @typeclass trait Foo[F[_]] {
[error]  ^
[error] one error found
import simulacrum.typeclass

@typeclass trait Foo[F[_]] {

  def select[A, B](fab: F[Either[A, B]])(ff: F[A => B]): F[B]

}
Luciano
@lJoublanc
I think your first argument to select must be f[a]. Try changing your F[_] to an F[_,_] so your instance is a Foo[Either] rather than Foo[Either[A,B]] if possible @kwark
Luciano
@lJoublanc
Hey @mpilquist I just watched your talk "from simulacrum to typeclassic".
Is it still the case that one has to chose between simulacrum and machinist? e.g. in cats I can see Monad annotated with @typeclass but can't see Binops anywhere. By contrast, spire, which extends cats-kernel does use it. Is there some rule as to when/how these are used?
Also looks like there's not been much activity in the typeclassic repo. I guess all this stuff will be taken care of in dotty?
Michael Pilquist
@mpilquist
Yeah that’s still true. In practice, escape analysis seems to handle the performance concerns in most cases
Jakub Kozłowski
@kubukoz
Hi, is it safe to scope simulacrum as a compile-only dependency?
Michael Pilquist
@mpilquist
Yeah, take a look at cats-build
There’s a trick to keep Intellij happy
Jakub Kozłowski
@kubukoz
of course, intellij...
Jasper Moeys
@Jasper-M
My trick to keep myself happy is not using Intellij
Wojciech Daniło
@wdanilo
Hi guys! I'm trying to convert the following code to simulacrum. Using "Haskell language", what I need here is just a superclass constraints when solving typeclass instances. Can we express something like that in Simulacrum?
  import shapeless.Lazy

  sealed trait AST[T]
  case class Var[T](s: String) extends AST[T]
  case class App[T](a: T, i: Int, b: T) extends AST[T]

  case class Fix[F[_]](unfix: F[Fix[F]])

  trait HasSpan[T] {
    def span(t: T): Int
  }
  object HasSpan {
    implicit def astSpan[T](implicit ev: Lazy[HasSpan[T]]): HasSpan[AST[T]] = new HasSpan[AST[T]] {
      def span(t: AST[T]) = t match {
        case Var(s) => s.length
        case App(a, i, b) => ev.value.span(a) + i + ev.value.span(b)
      }
    }

    implicit def inductive[F[_]](implicit ev: Lazy[HasSpan[F[Fix[F]]]]): HasSpan[Fix[F]] = new HasSpan[Fix[F]] {
      def span(f: Fix[F]) = ev.value.span(f.unfix)
    }
  }
  def test: Fix[AST] = Fix(Var("x"))

  def a = implicitly[HasSpan[Fix[AST]]].span(test)
Of course, the typeclass definition is straightforward, the problem is how to implement the instances, especially the instance for (using Haskell syntax) HasSpan F => HasSpan (Fix F)
@typeclass trait HasSpan[A] {
  def span(a: A): Int
}
Jakub Kozłowski
@kubukoz
I think that's what we do in instances indeed and the way to do it is just like you showed
simulacrum won't help much
Wojciech Daniło
@wdanilo
@kubukoz thanks Jakub! From a Haskellers perspective thats terrible, but ok, lets live with that :D
Jakub Kozłowski
@kubukoz
well you don't need Lazy on 2.13...
Peter Mortier
@kwark
......... NBN H. .jg nuuuuu h....u..iiiiiiiiiiiii y..
Jasper Moeys
@Jasper-M
Cat on the keyboard?
Lef Ioannidis
@elefthei
Any ideas why "import simulacrum" is failing with "not found: object simulacrum" in IntelliJ compilation? InltelliJ syntax indicates it finds the library and does auto-complete
simulacrum-0.10 unfortunately so this is before "macro-paradise" was a dependency, I think it needs no compiler plugin support?
Jasper Moeys
@Jasper-M
@elefthei just to be clear, is import simulacrum the complete line of code? Cause an import statement that doesn't include at least one . is not legal syntax, so that might be the problem then.
Lef Ioannidis
@elefthei
@Jasper-M appologies, it is import simulacrum._
Dominic Egger
@GrafBlutwurst

Good Morning. I have a bit of a build issue suddenly. I get typeclass annotation should have been removed by simulacrum but was not both on:

scala 2.12.8 with macro paradise
scala 2.13.0 with "-Ymacro-annotations"