These are chat archives for typelevel/general

4th
Mar 2016
Adelbert Chang
@adelbertc
Mar 04 2016 05:29
Are Typelevel incubator projects allowed to move their repos to the Typelevel GitHub org?
Rob Norris
@tpolecat
Mar 04 2016 05:34
I don't think anything should be under org.typelevel … it implies a level of quality/support/etc. that the organization as a whole is not prepared to guarantee ... it's still an independent project.
Obviously that boat has sailed but that's my 2¢.
Pascal Voitot
@mandubian
Mar 04 2016 08:52
seems logical
Michael Pilquist
@mpilquist
Mar 04 2016 14:36
Woke up with a nasty cold, so I won’t be seeing you all at NEScala :(
Adelbert Chang
@adelbertc
Mar 04 2016 14:42
@mpilquist booo
feel better
Greg Pfeil
@sellout
Mar 04 2016 14:55
@mpilquist Hoping you improve fast enough to make it to the unconference 😷
Michael Pilquist
@mpilquist
Mar 04 2016 14:57
Thanks :)
Live stream is working nicely
Adelbert Chang
@adelbertc
Mar 04 2016 15:02
awesome, good to hear
i need more scalaz-streams/fs2 in my life
Erik LaBianca
@easel
Mar 04 2016 15:32
Is the nescala live stream publicly available?
Erik LaBianca
@easel
Mar 04 2016 15:32
Sweet, thanks!
Julien Truffaut
@julien-truffaut
Mar 04 2016 15:35
awesome
Michael Pilquist
@mpilquist
Mar 04 2016 15:36
can't see the slides on the live stream, but it sounds like they are trying to come up with a solution to that
i think the live stream is just a tap in to the video recording of the presenter, which will be used to generate the videos, so they can't just pan the camera over to slides
Julien Truffaut
@julien-truffaut
Mar 04 2016 15:37
it is a bit difficult to follow without slides
Erik LaBianca
@easel
Mar 04 2016 15:39
Yeah, they need to get the presenters to connect up to webex and share their screen.
Erik Osheim
@non
Mar 04 2016 17:18
hey folks
i'm taking a stab at some work that's necessary for typeclassic
and trying to get past this one issue -- does anyone have an idea how to recover an annotation from within a def-macro?
for example:
implicit class QuxOps[A](a: A)(implicit ev: Semigroup[A]) {
  @op(proto = "xyz") def qux(a: A): A = macro ...
}
Dale Wijnand
@dwijnand
Mar 04 2016 17:19
never seen anyone do that.. I assume one can't
Erik Osheim
@non
Mar 04 2016 17:20
yeah i'm worried about that -- obviously a macro annotation can rewrite the whole class
Michael Pilquist
@mpilquist
Mar 04 2016 17:20
hm, why couldn't you grab the prefix, traverse back to the decl, and pull annotations?
using traversals like the ones i use here:
    "strip simulacrum annotations" in {
      import scala.reflect.runtime.universe._
      val tpe = weakTypeTag[Semigroup[Int]].tpe
      tpe.typeSymbol.asClass.annotations shouldBe Nil
      tpe.decl(TermName("append")).asMethod.annotations shouldBe Nil
    }
Erik Osheim
@non
Mar 04 2016 17:21
aha! yes... i think that would work
giving it a shot now
well -- it seems like it's a more complicated picture. in a def-macro i have trees/exprs but i'm not sure how i'll be able to find a type (tpe) since i don't have a WeakTypeTag available for QuxOps
(i'm also really rusty so maybe i'm just missing something)
Erik Osheim
@non
Mar 04 2016 17:28
i.e. if i start with c.macroApplication i get a Tree that is something like:
Select(Apply(Apply(TypeApply(Select(Ident(typeclassic.Example), TermName("TestOps")), List(TypeTree())), List(Literal(Constant(333)))), List(Select(Select(This(TypeName("math")), scala.math.Ordering), scala.math.Ordering.Int))), TermName("foo"))
Michael Pilquist
@mpilquist
Mar 04 2016 17:31
i thought you could get a tpe for a tree in a def macro?
tree.tpe
Erik Osheim
@non
Mar 04 2016 17:34
you're right! c.prefix.tree.tpe works
Michael Pilquist
@mpilquist
Mar 04 2016 17:34
macro api hurts my brain honestly
Michael Pilquist
@mpilquist
Mar 04 2016 18:02

here's a fun one:

val filteredAnnotations = mods.annotations.filter { ann =>
  val typed = c.typecheck(ann)
  !(typed.tpe =:= typeOf[op] || typed.tpe =:= typeOf[noop])
}

if op and noop are annotated with @compileTimeOnly, the use of typeOf[op] and typeOf[noop] fails compilation

Paul Horn
@knutwalker
Mar 04 2016 18:05
how about?
def quxImpl(c: blackbox.Context)(a: c.Tree): c.Tree = {
    import c.universe._
    val opTpe = typeOf[op]
    val m = c.macroApplication.symbol.asMethod
    val opValue = m.annotations.flatMap {
      case x if x.tree.tpe =:= opTpe =>
        x.tree.children.tail.collect {
          case Literal(Constant(opValue: String)) => opValue
        }
      case _ => Nil
    }.headOption
    // opValue == Some("xyz")
    a
  }
Michael Pilquist
@mpilquist
Mar 04 2016 18:18
here's how i worked around that: mpilquist/simulacrum@4265ec0
pattern matching on a type symbol's full name
Miles Sabin
@milessabin
Mar 04 2016 19:13
@mpilquist I hope your cold isn't my doing :-(
Michael Pilquist
@mpilquist
Mar 04 2016 19:13
no, i'm sure it is my son's :)
som-snytt
@som-snytt
Mar 04 2016 20:30
@mpilquist I just wandered into the stringlevel gitter. The first thing one sees in your linked diff is that you worked around it by removing -Xfatal-warnings.
Too bad there isn't -Yreally-annoying-warnings where it's not fatal but annoying enough that they are mitigated quickly.
Michael Pilquist
@mpilquist
Mar 04 2016 20:31
:) yeah, I need to use an unused import in order for one of the "shouldNot compile" clauses to successfully fail to compile
Miles Sabin
@milessabin
Mar 04 2016 20:40
stringlevel?
Erik Osheim
@non
Mar 04 2016 21:02
got it working!!
from this:
  implicit class TestOps[A](a: A)(implicit ev: Ordering[A]) {
    @op(proto = "$y.compare($x, $z)") def <=>(x1: A): Int = macro OpsMacros.op10
  }
i was able to create:
val res0 = Example.TestOps(333) <=> 444 compiled as math.this.Ordering.Int.compare(333, 444)
Dale Wijnand
@dwijnand
Mar 04 2016 21:06
commit push or get out :P
Michael Pilquist
@mpilquist
Mar 04 2016 21:54
@non nice!
Ghost
@ghost~540393fe163965c9bc2018ce
Mar 04 2016 22:50
a few of you have asked why I always hammer on about using Apache 2.0 over BSD or MIT, now I finally got a soapbox ... https://twitter.com/fommil/status/705846811454529536
it would be good if Typelevel had recommended licences to choose from
basically: if you want permissive => Apache 2.0. If you want copyleft => LGPL.
Dale Wijnand
@dwijnand
Mar 04 2016 23:21
really good talk, the video helped understand a lot more, but you still glossed over things like GPL vs LGPL, I find (ie. I'd have asked you had I been there)
Ghost
@ghost~540393fe163965c9bc2018ce
Mar 04 2016 23:22
yeah, I also had a scala implementation of the Creative Commons licences as a sealed trait that I had to drop too :smile: I already went over by 5 minutes
sealed trait Shareable
case object Share extends Shareable
case object NoDerivatives extends Shareable
case object ShareAlike extends Shareable
case class CreativeCommons(
  share: Shareable = Share,
  noCommercial: Boolean = false
) {
  def isLibre = share != NoDerivatives && !noCommercial
  def isCopyleft = isLibre && share == ShareAlike
}
> val thisTalk = CreativeCommons(NoDerivatives, noCommercial = true)
> thisTalk.isLibre
> res0: Boolean = false
then equivalent for > val `ensime.org` = CreativeCommons(ShareAlike)
Adelbert Chang
@adelbertc
Mar 04 2016 23:34
hah nice
Ghost
@ghost~540393fe163965c9bc2018ce
Mar 04 2016 23:36
@dwijnand well, obviously, you should have been there! :grinning: