86dcb72b

Created Started Cancelled

Ask a newtype's field for unExample rather than a prefix

## What this fixes

`HsPrefixNaming` held every field to starting with the name of its type, which
is the one thing the field of a newtype cannot be called. `unWorkerName` cannot
carry the whole of `WorkerName` in front of it and stay that spelling, so the
rule reported every newtype accessor written the way the ecosystem writes them,
and proposed nothing to write instead. In one repository that was 87 findings
with no fixable form, which was enough to keep the whole rule turned off.

## What it asks for now

A newtype's field is held to exactly `unExample`:

```
The field of the newtype Wrapper called wrapperInner rather than unWrapper.
```

A prefix on a field says which type it belongs to, which is worth saying
because the fields of a data type have to be told apart from one another. A
newtype has exactly one field, so there is nothing to tell it apart from and
the prefix would only repeat what the declaration already says. The name says
the useful thing instead, that applying it undoes the wrapper.

Note that this cuts both ways: a newtype field written `wrapperInner` or
`urlText` was accepted before and is a finding now.

## The shape

`NameRole` gains a third constructor, so the three roles are the three
different things a name is held to: a constructor takes the type's name as
written, a data field takes it with the first letter lowered, and a newtype
field takes one exact spelling. `nameIsRight` is what each is held to, and the
`Validity` instance on `UnprefixedName` asks it rather than asking about
prefixes, so a finding that is not one still cannot be built.

Which role a field gets is decided in `introducedBy`, the only place that can
see `NewTypeCon` against `DataTypeCons`. The field itself is written the same
either way.

## Tests

`good.hs` and `bad.hs` swapped their newtypes: `unWrapper` is good and
`wrapperInner` is bad. `bad.hs` also covers an acronym (`urlText` wants
`unURL`), because an acronym is where a prefix rule is most tempted to make an
exception, and `good.hs` covers a newtype written without a field, which
introduces no field to name.

## This repository

A rule that ships has to hold here, and this one found twelve newtypes written
the old way, so they are renamed with it: `typeHeadText`, `storedPathFile`,
`ruleSetEntries`, `ruleIdText`, `packageNameText`, `moduleKeyText`,
`formatVersionNumber`, `declNameText`, `componentNameText`, `complaintsList`,
`choicesDisabled` and `checkResultFindings`, each to `unX`.

That is why the rule change and the renames are one commit: either alone leaves
`nix flake check` red, since it runs hopinion on hopinion.

## Checked

`cabal build all`, `cabal test hopinion-gen --test-options=--ai-executor` (586
passed) and `nix flake check` all pass.
PR #16