typelevel / typelevel/cats

Obtaining typeTag of NonEmptySet

Open
#2,928 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
5.5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
5

Description

The following:

import scala.reflect.runtime.universe.typeTag
implicit val tag = typeTag[NonEmptySet[Int]]

gives me:

No TypeTag available for cats.data.NonEmptySet[Int]

Apparently this is some sort of an issue with Scala that's been known for some time that "the case classes must be defined top level - they cannot be nested." and there is no workaround for it.

Why then, are NonEmptySet/Map etc. implemented with newTypes while NonEmptyList has an actual implementation and doesn't have the same problem?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the typeTag[NonEmptySet[Int]] example with Scala reflection and compare it with NonEmptyList, NonEmptyMap, and the related newtype implementations. Determine whether the difference is an implementation limitation or an actionable Cats change; done means a documented rationale or a clearly scoped fix is established.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.