typelevel / typelevel/cats

alleycats - no default instance for Empty[Option[T]]

Open
#3,617 2 comments 0 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

There is no default instance for Empty[Option[T]] if T has no Monoid. But there is one for collections.
Would it make sense to add an Empty[Option[T]] instance that behaves like the collection default ones?

  import alleycats.Empty
  import cats.implicits._
  import java.time.LocalDateTime

  implicit val dtEmtpy = Empty(new LocalDateTime(0))

  // works fine
  Empty[List[LocalDateTime]]
  Empty[Set[LocalDateTime]]
  Empty[Stream[LocalDateTime]]

  // doesn't work by default
  Empty[Option[LocalDateTime]]

EDIT: rewrite the example with a type that has no Monoid.

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 locating the existing alleycats.Empty instances for collections and the current handling of Option. Check how the instance should behave when the contained type has no Monoid, then add focused coverage showing the intended Empty[Option[T]] behavior for such a type.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.