Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 22 17:57
    Travis milessabin/shapeless (shapeless-3) passed (2604)
  • Aug 22 17:54

    milessabin on shapeless-3

    Typeable macro cleanups. implicit match -> given match. Bumped Dotty version. and 1 more (compare)

  • Aug 20 14:20
    alexandru added as member
  • Aug 15 16:15
    milessabin commented #901
  • Aug 15 15:08
    borissmidt commented #901
  • Aug 15 15:06
    borissmidt closed #901
  • Aug 12 10:53
    Travis milessabin/shapeless (master) passed (2603)
  • Aug 12 10:30

    milessabin on master

    Added missing @Test annotation. (compare)

  • Aug 11 16:29
    borissmidt commented #901
  • Aug 11 12:03
    Travis milessabin/shapeless (master) passed (2602)
  • Aug 11 11:42
    milessabin commented #901
  • Aug 11 11:39

    milessabin on master

    Update slf4j-nop to 1.7.28 Merge pull request #914 from sc… (compare)

  • Aug 11 11:39
    milessabin closed #914
  • Aug 11 11:39
    milessabin commented #914
  • Aug 10 13:28
    codecov-io commented #914
  • Aug 10 13:27
    codecov-io commented #914
  • Aug 10 13:27
  • Aug 10 13:02
    scala-steward opened #914
  • Aug 09 16:41
    milessabin closed #913
  • Aug 09 16:41
    milessabin commented #913
Zsolt Donca
@zsolt-donca
@SystemFw you were right, that case was the issue; changing it to EnumCase[H] made my code work
it seems that there was no Generic instance for FieldType[K, H] but there is for H
thanks for your help!
Fabio Labella
@SystemFw
:+1:
Luca Filipponi
@LFilips
Hello! I've started playing a bit with shapeless and i've a newbie question. I've notice that intelliJ wrongly shows an error about a missing implicit, but the actually works and compiles using sbt. Is there any config or plugin that i have to do? What do you guys use?
Oh i've just fixed the issue, changing this "Generic[A] { type Repr = R }" to this: "gen: Generic.Aux[A, R]"
i guess intellij has some limitations, because the error was not when compiling but in the UI
JoeCordingley
@JoeCordingley
Hi I was running through the type astronauts book, and I came to a section involving narrow and 42.narrow just blows up the compiler.
I would post some of the trace but it's massive, I don't know what the important part is.
JoeCordingley
@JoeCordingley
the versions are:
shapeless: 2.3.3
scala: 2.12.8
sbt: 1.2.8
java: AdoptOpenJDK 11.0.4+11
I have a repo with the smallest example here: https://github.com/JoeCordingley/shapelessnarrow/blob/master/src/main/scala/Narrow.scala
JoeCordingley
@JoeCordingley
Ah noticed this: milessabin/shapeless#674
so no var's allowed with narrow then?
Teodor Dimov
@teodimoff
i think narrow needs "stable identifier" eg. a val . Or at least var should widen the type not crash. Why do you need var with a narrow?
JoeCordingley
@JoeCordingley
I don't it's just the example in the book.
Teodor Dimov
@teodimoff
oh... gotcha
JoeCordingley
@JoeCordingley
It uses it to show that you can't then put x = x +1
Teodor Dimov
@teodimoff
it only crashes in the repl tho..
JoeCordingley
@JoeCordingley
No it crashes on compile
JoeCordingley
@JoeCordingley
It's not important to me, as it would be a strange thing to do anyway. But it could be worth changing the book perhaps?
Teodor Dimov
@teodimoff
if it crashes its better to be the other way around... we fix it...
JoeCordingley
@JoeCordingley
I wondered how high a priority it would be considering there is no rational reason to want a singleton-type as a var.
Teodor Dimov
@teodimoff
i believe its not a top priority but more people will try it after they see it in the book i guess..
Sait Sami Kocataş
@Deliganli
hi everyone
I am trying the RowEncoder below to enforce for each type have CellEncoder. I think it can be done by providing tuple methods for every possibility, although I am not sure how to do that as well
Is there some way to do that?
trait CellEncoder[T] {
  def encode(field: T): String
}

trait RowEncoder[T] {
  def encode(model: T)(implicit ???): String
}

object Writer {

  def write[F[_]: Sync: ContextShift, T: RowEncoder](
    file: os.Path,
    blocker: Blocker
  )(implicit lg: LabelledGeneric.Aux[T, HNil]): Pipe[F, T, Unit] = ???
}
Miles Sabin
@milessabin
@JoeCordingley @teodimoff whether or not it's a good example it certainly shouldn't crash the compiler.
I think this might be fixed in 2.13.x ... would you mind checking and seeing whether it is or not?
Teodor Dimov
@teodimoff
confirmed it still crashes in repl for 2.13

java.lang.AssertionError: assertion failed: 
  mkAttributedQualifier(Unit, <none>)
     while compiling: <console>
        during phase: fields
     library version: version 2.13.0
    compiler version: version 2.13.0

  last tree to typer: Ident(x$1)
       tree position: line 1 of <console>
            tree tpe: Int(42)
              symbol: value x_=
   symbol definition: x$1: Int(42) (a TermSymbol)
      symbol package: $line7
       symbol owners: value x_= -> variable x -> object $iw -> object $iw -> object $iw -> object $iw -> object $iw -> object $iw -> object $read
           call site: constructor $iw in package $line7

== Source file context for tree position ==

     1 var x = 42.narrow
     2 
        at scala.reflect.internal.SymbolTable.throwAssertionError(SymbolTable.scala:170)
        at scala.reflect.internal.TreeGen.mkAttributedQualifier(TreeGen.scala:98)
        at scala.reflect.internal.TreeGen.mkAttributedQualifier(TreeGen.scala:74)
        at scala.tools.nsc.transform.Fields$FieldsTransformer.$anonfun$transform$1(Fields.scala:754)
        at scala.reflect.internal.Trees.deriveDefDef(Trees.scala:1950)
        at scala.reflect.internal.Trees.deriveDefDef$(Trees.scala:1948)
        at scala.reflect.internal.SymbolTable.deriveDefDef(SymbolTable.scala:28)
        at scala.tools.nsc.transform.Fields$FieldsTransformer.transform(Fields.scala:754)
        at scala.tools.nsc.transform.Fields$FieldsTransformer.transformTermsAtExprOwner(Fields.scala:795)
        at scala.tools.nsc.transform.Fields$FieldsTransformer.$anonfun$transformStats$3(Fields.scala:808)
        at scala.tools.nsc.transform.Fields$FieldsTransformer.transformStats(Fields.scala:808)
        at scala.tools.nsc.transform.Fields$FieldsTransformer.transformStats(Fields.scala:552)
        at scala.reflect.internal.Trees$Template.transform(Trees.scala:515)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.$anonfun$transform$1(TypingTransformers.scala:47)
        at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:2625)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:37)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:32)
        at scala.tools.nsc.transform.Fields$FieldsTransformer.transform(Fields.scala:787)
        at scala.tools.nsc.transform.Fields$FieldsTransformer.transform(Fields.scala:552)
        at scala.reflect.api.Trees$Transformer.transformTemplate(Trees.scala:2587)
        at scala.reflect.internal.Trees$ClassDef.$anonfun$transform$2(Trees.scala:333)
        at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:2625)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:37)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:32)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:24)
        at scala.reflect.internal.Trees$ClassDef.transform(Trees.scala:332)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.transform(TypingTransformers.scala:51)
        at scala.tools.nsc.transform.Fields$FieldsTransformer.transform(Fields.scala:778)
        at scala.tools.nsc.transform.Fields$FieldsTransformer.transformTermsAtExprOwner(Fields.scala:795)
        at scala.tools.nsc.transform.Fields$FieldsTransformer.$anonfun$transformStats$3(Fields.scala:808)
        at scala.tools.nsc.transform.Fields$FieldsTransformer.transformStats(Fields.scala:808)
        at scala.tools.nsc.transform.Fields$FieldsTransformer.transformStats(Fields.scala:552)
        at scala.reflect.internal.Trees$Template.transform(Trees.scala:515)
        at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.$anonfun$transform$1(TypingTransformers.scala:47)
        at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:2625)
...
Zsolt Donca
@zsolt-donca
, X
Arulselvan Madhavan
@ArulselvanMadhavan

Hello,
I'm trying out this example from the shapeless repo - https://github.com/milessabin/shapeless/blob/master/examples/src/main/scala/shapeless/examples/caseclassmerge.scala

case class Foo(i: Int, s: String, b: Boolean)
case class Bar(b: Boolean, s: String)

val foo = Foo(23, "foo", true)
val bar = Bar(false, "bar")

I'm not able to understand why this one works

CaseClassMerge[Foo, Bar] // Works
CaseClassMerge[Bar, Foo] // Doesn't work

Especially when there is a

Merger[HNil, R <: HList]

instance defined here - http://bit.ly/2Zb7bN6

Miles Sabin
@milessabin
CaseClassMerge[A, B] requires that the fields of B are present in A. That's true in your first example, but not the second.
Arulselvan Madhavan
@ArulselvanMadhavan
@milessabin Thanks! Can you point me to the place in Merger instance definitions where this requirement is imposed?
http://bit.ly/2NtwrqX
Arulselvan Madhavan
@ArulselvanMadhavan
@SystemFw Thanks! If Merger[HList Of Bar, HList of Foo] was called, then the code seems to indicate that Remover will be called on Foo for all elements of Bar, right?
But from what your saying, it seems like Remover will be called on Bar for all elements of Foo.
Arulselvan Madhavan
@ArulselvanMadhavan
implicit def hlistMerger2[K, V, T <: HList, M <: HList, MT <: HList]
      (implicit
        rm: Remover.Aux[M, K, (V, MT)],
        mt: Merger[T, MT]
      )
When the compiler tries to find an instance for Merger[Bar, Foo], will it try to find Remover.Aux[Foo, K, (V, MT)] or Remover.Aux[Bar, K, (V, MT) ?
Fabio Labella
@SystemFw
you always need to look at return type as well. Implicit chain form logical relations, not functions
anyway it's Remover[Foo, K, (V, MT)]
M is the second type parameter in the returned Aux type
Arulselvan Madhavan
@ArulselvanMadhavan
Great! That aligns with my understanding.
So, why is the compiler complaining when all fields of Bar are present in Remover.Aux[Foo, K, (V, MT)] ?
Fields of HList of Bar - FieldType[b, Boolean] :: FieldType[s, String] :: HNil
Remover.Aux[Foo, K, (V, MT)) when called on all of the above fields should work, right?
Fabio Labella
@SystemFw
look at the return type as well
): Aux[FieldType[K, V] :: T, M, FieldType[K, V] :: mt.Out]
in particular :: mt.Out
you get FieldType("b", Boolean) :: FieldType("s", String) :: Merge[HNil, ("i", Int) :: HNil).Out
which then goes into the HNil instance, which just returns the second type, so the final return type is
("b", Boolean) :: ("s", String) :: ("i", Int) :: HNil (not actual tuples, just to give the idea)
and in caseclassmerge you have
merger: Merger.Aux[RT, RU, RT] as a requirement
Fabio Labella
@SystemFw
which is not true anymore (note how the first argument of that Merger.Aux is required to be the same as the third)
Arulselvan Madhavan
@ArulselvanMadhavan
Ahhhh. Got it! Finally. Thanks @SystemFw! You're awesome. I was stuck on this for a while...
Fabio Labella
@SystemFw
I have to say it was slightly tricky