Skip to content

(Unnecessary?) overlapping instance for WithStatus #1431

@alpmestan

Description

@alpmestan

An overlapping instance related compilation error brought up by @Taneb on IRC made me wonder about

instance {-# OVERLAPPING #-} MimeRender JSON a => MimeRender JSON (WithStatus _status a) where
  mimeRender contentTypeProxy (WithStatus a) = mimeRender contentTypeProxy a

It just seems giving FromJSON/ToJSON instances to WithStatus would be the better move here, just delegating the JSON encoding/decoding to the wrapped a, since the status is irrelevant as far as JSON encoding is concerned. Some discussion could be held for the other content types where we don't have a "standard encoding/decoding rule", so to speak.

The instance above is at least better than that of a previous servant release where we had the too-general instance MimeRender ctype a => instance MimeRender ctype (WithStatus _status a), which ended up biting @Taneb. But it still feels like the instance mentioned at the beginning could better be done by specifying ToJSON/FromJSON for WithStatus instead, which would allow us to avoid an overlapping instance, which often is an occasion to trigger compilation errors waiting to happen.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions