Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive derivation not working #424

Open
ahoy-jon opened this issue Sep 12, 2022 · 0 comments
Open

Recursive derivation not working #424

ahoy-jon opened this issue Sep 12, 2022 · 0 comments

Comments

@ahoy-jon
Copy link

probably the same as #401 (not sure)

While working on some examples with @guihardbastien, we can see with this code when the recursion fails: https://scastie.scala-lang.org/ahoy-jon/ijmFz87ESKO2vr6Syf3qRw/13

import language.experimental.macros, magnolia1._


trait Tc[T] 

trait TcObj[T] extends Tc[T]


object ShowDerivation {
  type Typeclass[T] = Tc[T]
  
  
  def join[T](ctx: CaseClass[Tc, T]): TcObj[T] = new TcObj[T] {}

  def split[T](ctx: SealedTrait[Tc, T]): TcObj[T] = new TcObj[T] {}
  

  def gen[T]: Tc[T] = macro Magnolia.gen[T]
  
  def genObj[T]: TcObj[T] = macro Magnolia.gen[T]
}


sealed trait A

case object B extends A

case class C(next:A) extends A


ShowDerivation.gen[B.type] //success

ShowDerivation.genObj[B.type] //success

ShowDerivation.gen[A] //success

//ShowDerivation.genObj[A] //failure

/*
type mismatch;
 found   : Playground.ShowDerivation.Typeclass[Playground.A]
    (which expands to)  Playground.Tc[Playground.A]
 required: Playground.TcObj[Playground.A]
*/


implicit val tca:Tc[A] = null

ShowDerivation.gen[C] //success

ShowDerivation.genObj[C] //success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant