Skip to content

Conflicting ContravariantShow for ZoneOffset #55

Description

@nigredo-tori

It seems my instances for ZoneId and ZoneOffset are slightly broken. When importing io.chrisdavenport.cats.time.instances.all._, I get a conflict when trying to show a ZoneOffset:

scala> show"${ZoneOffset.UTC}"
<console>:22: error: type mismatch;
 found   : java.time.ZoneOffset
 required: cats.Show.Shown
       show"${ZoneOffset.UTC}"
                         ^

This arises because there are two overlapping instances for ContravariantShow[-T]:

scala> Show.Shown.mat(ZoneOffset.UTC)
<console>:22: error: ambiguous implicit values:
 both value zoneidInstances in trait zoneid of type => cats.Show[java.time.ZoneId] with cats.Eq[java.time.ZoneId] with cats.Hash[java.time.ZoneId]
 and value zoneoffsetInstances in trait zoneoffset of type => cats.Show[java.time.ZoneOffset] with cats.Order[java.time.ZoneOffset] with cats.Hash[java.time.ZoneOffset]
 match expected type cats.Show.ContravariantShow[java.time.ZoneOffset]
       Show.Shown.mat(ZoneOffset.UTC)
                     ^

, and the compiler can't choose a better one.

I'm not sure what would be the best course of action here. Removing Show[ZoneOffset] would fix interpolation, however most of generic code I've seen relies directly on Show!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions