Composite, Option, @@, and TypeTag
Open
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.2k
- Forks
- 379
- Avg merge
- 14m
- Merged PRs (30d)
- 8
Description
I know we talked about this or similar before, but it's still pretty weird to me, so I thought I'd open a ticket:
import scalaz._, doobie.imports._, scala.reflect.runtime.universe.TypeTag
// implicit #1
implicit def taggedMeta[A : Meta, T](implicit tt: TypeTag[A @@ T]): Meta[A @@ T] =
Meta[A].xmap(Tag.apply[A,T], Tag.unwrap[A,T])
// implicit #2
implicit def taggedComposite[A : Composite, T]: Composite[A @@ T] =
Composite[A].xmap(Tag.apply[A,T], Tag.unwrap[A,T])
trait Foo
case class Bar(x: String @@ Foo)
case class Baz(x: Option[String @@ Foo])
implicitly[Atom[String]] // easy
implicitly[Meta[String]] // peasy
implicitly[Composite[String]]
implicitly[Atom[String @@ Foo]] // from implicit #1
implicitly[Meta[String @@ Foo]] // from implicit #1
implicitly[Composite[String @@ Foo]] // from implicit #1
implicitly[Composite[Option[String @@ Foo]]] // from implicit #1
implicitly[Composite[Bar]] // requires implicit #2 (a little confused)
implicitly[Composite[Baz]] // requires implicit #3 (super confused)
locally {
// implicit #3
implicit def taggedStringFoo: Meta[String @@ Foo] = taggedMeta[String,Foo] // already implicit
implicitly[Composite[Baz]] // ok
}
I'm on board with #1 and #2, but with no type args, #3 is awfully boilerplatey. Any suggestions?
Thanks for taking a look!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Scala snippet in the issue and trace implicit resolution for Meta, Composite, Option, @@, and TypeTag. Compare the cases for String @@ Foo, Bar, and Baz, then review the thread for an agreed direction. Done means an accepted design or documented conclusion about reducing the required boilerplate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100