daf97106

Created Started Finished

By: Tom Sydney Kerckhove <syd@cs-syd.eu>

Report Eq and Ord instances that are written out

The standards say Eq and Ord are derived. A written one says which two of
these count as the same, or which of them comes first, in a body that names
the fields it was written against. Add a field and the derived version
accounts for it while the written one goes on answering the older question, so
the type gains a field that equality ignores and sorting cannot see, and every
lookup, every nub, every Map and every test that asserts a whole value
inherits that silence.

Two rules rather than one. HsNoCustomShowRead is one rule over two classes
because Show and Read are an inverse pair, so a repository that has decided to
write one has decided about the round trip that is the reason for the rule.
Eq and Ord do not sit like that. A type that has earned a written Ord, ordered
by a key rather than by its fields in order, has usually not earned a written
Eq, and one id for both would make the suppression that allows the first allow
the second without anyone saying so.

No exception for methods that discard their arguments. That exception is on
Show and Read because an instance printing a constant keeps a secret out of
every log line and has nothing to drift from. Equality that cannot see the
value is not a comparison anyone reaches for on purpose, so the same shape is
reported here, and bad-ignoring-arguments.hs is the case that pins it.

Deriving is deriving however it was asked for, so whether a body was typed out
is originIsWrittenOut in Facts.Instance rather than a copy in each rule: a
stock, newtype, anyclass, via or standalone derivation is all the compiler
writing against the fields. Enumerated rather than matched with a catch-all,
so a further origin has to be answered for at the one site that asks.

Nothing in this repository is reported by either rule.