Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 05 2020 09:16
    propensive closed #113
  • Nov 05 2020 09:16
    propensive closed #113
  • Nov 05 2020 09:04
    propensive labeled #271
  • Nov 05 2020 09:04
    propensive labeled #271
  • Nov 05 2020 07:44
    propensive commented #271
  • Nov 05 2020 07:44
    propensive commented #271
  • Nov 04 2020 21:01
    joroKr21 commented #271
  • Nov 04 2020 21:01
    joroKr21 commented #271
  • Nov 04 2020 20:36
    xela85 commented #271
  • Nov 04 2020 20:36
    xela85 commented #271
  • Nov 04 2020 03:42
    joroKr21 commented #271
  • Nov 04 2020 03:42
    joroKr21 commented #271
  • Nov 03 2020 20:36
    xela85 opened #271
  • Nov 03 2020 20:36
    xela85 opened #271
  • Oct 16 2020 00:25
    lemastero commented #29
  • Oct 16 2020 00:25
    lemastero commented #29
  • Sep 28 2020 17:41
    lemastero commented #172
  • Sep 28 2020 17:41
    lemastero commented #172
  • Sep 27 2020 14:44
    vigoo opened #270
  • Sep 27 2020 14:44
    vigoo opened #270
Ernie Makris
@emakris_twitter

@propensive:matrix.org I end up having to define

  implicit def strDecode: RelGraphDecoder[String]              = null
  implicit def longDecode: RelGraphDecoder[Long]               = null

otherwise I get compile errors like:
magnolia: could not find RelGraphDecoder.Typeclass for type String

I guess for regular members of each case class, I wanted to serialize in values from from an unstructured map, but somehow, the typeclasses for types like String and Long are being summoned
Ernie Makris
@emakris_twitter
I basically wanted to stop the derivation at one level. I don’t know if I’m making sense :)
propensive#4225
@_discord_547426086179307521:t2bot.io
[m]
@emakris_twitter I might need a bit more information... 😉 The error message isn't surprising to me, assuming you're deriving a RelGraphDecoder for a case class that has a String or Long as one of its fields (either directly, or by means of another case class). And Magnolia can't construct the CaseClass instance with Param instances for each field unless it can find those implicit instances you've just defined.
Now it might be that you know you're not going to use them at runtime, in which case they're "boring" and null is one way to represent that. (There may be better ways...)
And that's fine, but usually the implementation of a combine method would use the typeclass instances of its parameters (at runtime too), so they're necessary.
GitHub#0000
@_discord_773834507748114432_=47it=48ub:t2bot.io
[m]
[magnolia:scala3] 14 new commits
propensive/magnolia@fdb313e Draft for scala 3 - maphi
propensive/magnolia@8b48345 Some further work on support for dotty - KacperFKorban
propensive/magnolia@2de6461 Interface for Scala3 changes - KacperFKorban
propensive/magnolia@9b61ea9 bump sbt-dotty version - KacperFKorban
propensive/magnolia@66b94dd bring back scala2 sources - KacperFKorban
Ernie Makris
@emakris_twitter
thank you for the explanation, thats exactly what I was encountering. I did the null trick but I didn’t know why I had to do it.
propensive#4225
@_discord_547426086179307521:t2bot.io
[m]
No problem! Don't hesitate to ask if you need anything else. 🙂
GitHub#0000
@_discord_773834507748114432_=47it=48ub:t2bot.io
[m]
propensive/magnolia@0ae9b9f
propensive/magnolia@0ae9b9f Docs and removal of mercator binary - propensive
Tim Pigden
@TimPigden
Hi, in attempting to revive some old blog code of mine I get this error
/home/tim/code/zio-http4s-examples/avro-magnolia/src/main/scala/tsp/avro/AvroReader.scala:40:62
macro implementations cannot have implicit parameters other than WeakTypeTag evidences
implicit def avroReader[T]: AvroReader[T] = macro Magnolia.gen[T]
I think I saw something above about scala-reflect at compile time having something to do with it. But how/where would I do that?
François-Xavier Hibon
@FXHibon
libraryDependencies += “org.scala-lang” % “scala-reflect” % scalaVersion.value
This should solve your problem
Tim Pigden
@TimPigden
@FXHibon thanks!
GitHub#0000
@_discord_773834507748114432_=47it=48ub:t2bot.io
[m]
propensive/magnolia@343d9bd
propensive/magnolia@343d9bd Cleanup on interfaces - propensive
GitHub#0000
@_discord_773834507748114432_=47it=48ub:t2bot.io
[m]
GitHub#0000
@_discord_773834507748114432_=47it=48ub:t2bot.io
[m]
GitHub#0000
@_discord_773834507748114432_=47it=48ub:t2bot.io
[m]
[magnolia:main] 17 new commits
propensive/magnolia@fdb313e Draft for scala 3 - maphi
propensive/magnolia@8b48345 Some further work on support for dotty - KacperFKorban
propensive/magnolia@2de6461 Interface for Scala3 changes - KacperFKorban
propensive/magnolia@9b61ea9 bump sbt-dotty version - KacperFKorban
propensive/magnolia@66b94dd bring back scala2 sources - KacperFKorban
heksesang
@heksenlied:matrix.org
[m]
Now that the Scala 3 implementation is merged, are you planning to do a release soon?
propensive#4225
@_discord_547426086179307521:t2bot.io
[m]
@hekesang Hopefully you saw my response on GitHub, but for anyone else listening, I'm planning a release as soon as possible. The Scala 2 version of Magnolia will stay active in the legacy branch for the foreseeable future. ("Legacy" sounds a bit harsh, but I'm mostly trying to distinguish it from the latest version). Magnolia for Scala 2 isn't in any way "deprecated". 🙂
Stacy Curl
@stacycurl

Hello, I have a question about TypeInfo.

Say I have a type class: Print[A]
And I derived an instance for a generic: (I have a manual instance for primitives, like String)
@deriving(Print)
case class Wrapper[A](value: A)

and then instantiate a value: Wrapper[String](“hello !”)
The type infö is something like TypeInfo(“Wrapper”, List(TypeInfo(“A”, Nil))
I was hoping the typeinfo for Wrapper would be TypeInfo(“Wrapper”, List(TypeInfo(“String”, Nil))

Q1: Is there a way of ‘materialising’ the type info, given the value ?
Q2: (back up plan), Is there a way of seeing that the type of the parameter (“hello”) is the same as the type parameter ?

propensive#4225
@_discord_547426086179307521:t2bot.io
[m]
@deriving is from Sam Halliday's Scalaz-deriving, right?
Stacy Curl
@stacycurl
Yep, but I’m still defining a magnolia macro all the same, it’s just making the call to Print.gen on my companions for me.
propensive#4225
@_discord_547426086179307521:t2bot.io
[m]
Right, yep. I just wanted to check there wasn't something else going on. 😉 I would need to spend a while getting back into Scala 2 Macros to remind myself all the dynamics of how TypeInfos are derived, but IIRC, macros are rather lazy about what they evaluate, so A is probably the best we have at that point. In general, a type-parameterized Wrapper would have A inferred only on its construction, inferred by the type of value, and that would happen only after the macro has generated a tree and exited.
propensive#4225
@_discord_547426086179307521:t2bot.io
[m]
I'm not sure about your implementation, but you might be able to get something to work by adding an implicit parameter (e.g. implicit ev: A =:= SomeType) to the combine and dispatch method definitions. That may prevent the macro-generated from typechecking if it can't find the implicits though.
By the way, combine and dispatch don't have to adhere to a strict interface in the object-oriented sense. They just need to be defined in such a way that the macro-generated calls compile. So extra implicit parameters or type parameters are fine.
stacy.curl#0336
@_discord_337358123394269184:t2bot.io
[m]

Maybe if I say a bit more about what I'm doing it may help. Reify[A] is that actual type class I've defined, not Print[A].

Reify[A].reify(value: A) produces a string that should be the same as the code used to produce value. It's working fine for non generics, and it's fine for case classes where the type parameters can be inferred.

case class FooA
Reify[Foo[String]].reify(Foo(Some("hello")) produces Foo(Some("hello")
but
Reify[Foo[String]].reify(Foo(None: Option[String])) produces Foo(None).

I want the latter cases to produce FooString) and FooString
I'm having a look at the magnolia code, you may be getting back into Scala 2's macros, but I've only ever dabbled with them !
stacy.curl#0336
@_discord_337358123394269184:t2bot.io
[m]
I think TypeName/TypeInfo (it's been renamed, hasn't it ?) won't be the solution, I think it will be something around the params.
If each param had a method to obtain it's generic type, so for
case class FooA
FooString ctx.parameters === Seq(
("a value", "String", "String", ...),
("another value", "String", "A", ...)
)
Then I'll be able to infer that A =:= String and produce the result I want.
heksesang
@heksenlied:matrix.org
[m]
Just noticed the About section of the GitHub repo says East, fast, transparent generic derivation of typeclass instances – probably meant to be Easy, fast, transparent generic derivation of typeclass instances.
stacy.curl#0336
@_discord_337358123394269184:t2bot.io
[m]
I think if CaseParam had a paramTypeName (i.e. just typeNameOf(paramType)) to go along with it's paramType then that would work.
stacy.curl#0336
@_discord_337358123394269184:t2bot.io
[m]

Yes, I forked magnolia and added paramTypeName to Param, and I have solved using that.

From param.typeName I have TypeName(, "A", Nil)
From the typeclass instance for that param I already have
TypeName(
, "String", Nil), so it's easy to associate "A" -> "String", it was also easy to feed that back into the TypeName for the 'root' value. say TypeName(, "Foo", Seq(TypeName(, "A", Nil))) and get
TypeName(, "Foo", Seq(TypeName(, "String", Nil)))
With then allowed me to reify FooString as, erm: "FooString" !

stacy.curl#0336
@_discord_337358123394269184:t2bot.io
[m]
I can put together a PR if you think that addition makes sense.
stacy.curl#0336
@_discord_337358123394269184:t2bot.io
[m]

:point_up: Edit: Yes, I forked magnolia and added paramTypeName to Param, and I have solved using that.

From param.typeName I have TypeName(, "A", Nil)
From the typeclass instance for that param I already have
TypeName(
, "String", Nil), so it's easy to associate "A" -> "String", it was also easy to feed that back into the TypeName for the 'root' value. say TypeName(, "Foo", Seq(TypeName(, "A", Nil))) and get
TypeName(, "Foo", Seq(TypeName(, "String", Nil)))
Which then allowed me to reify FooString as, erm: "FooString" !

stacy.curl#0336
@_discord_337358123394269184:t2bot.io
[m]
Too late, PR raised ! I realise it may get rejected, that's ok.
propensive#4225
@_discord_547426086179307521:t2bot.io
[m]
@heksesang Yes, thank you! Fixed! 🙂
GitHub#0000
@_discord_773834507748114432_=47it=48ub:t2bot.io
[m]
propensive/magnolia@354dbe8
propensive/magnolia@354dbe8 Add TypeName to Param (#283) - stacycurl
propensive#4225
@_discord_547426086179307521:t2bot.io
[m]
stacy.curl (Welcome to Discord!) I just approved and merged your PR. It seems to be quite a safe addition, so thank you!
stacy.curl#0336
@_discord_337358123394269184:t2bot.io
[m]
Wahey, nice one
stacy.curl#0336
@_discord_337358123394269184:t2bot.io
[m]
The build timed out, I don't know if that was due to my change or not.
Why is it you don't have a good way to test performance anymore ? Is CI too variable ?
Would you rerun the action ?
stacy.curl#0336
@_discord_337358123394269184:t2bot.io
[m]
Also what's your take on backwards compatibility, coz my change makes this issue worse: propensive/magnolia#266
I don't mind creating another PR to add default values.
TypeName("unknown", "unknown", Nil) ?
GitHub#0000
@_discord_773834507748114432_=47it=48ub:t2bot.io
[m]
propensive/magnolia@4c5168b
propensive/magnolia@4c5168b Suppress failing test - propensive