0d189ed0

Created Started Cancelled

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

Refuse a primitive no name reaches in a constructor of several fields

A primitive a constructor holds is named by a record field, by a type of its
own, or by nothing at all, and the last leaves a reader counting arguments to
find out which one it is. That is what the style guide means by asking for a
newtype so scalars "cannot be confused positionally", and HsNewtypeNotSynonym
reaches only the half of it written as a synonym.

A constructor's name speaks for one payload, so a constructor of one field
needs nothing: a relayed reason travelling alone has nothing beside it for that
name to be ambiguous between. A constructor of several names the whole of what
it holds and no part of it, so every primitive among them is named nowhere and
two fields a caller has the wrong way round still typecheck. Both fixes are
always available: a newtype, which is what the guide asks for, or record
syntax, which names the fields without asking for a type.

Bool is left to HsNoDomainBool rather than reported here in a second
vocabulary, and a synonym standing in for a newtype stays
HsNewtypeNotSynonym's complaint, which is what keeps it from being a way around
this rule.

The rule reads the declarations a module writes and not the ones it quotes. A
Template Haskell bracket is an expression, so searching for data definitions
finds the constructors inside one, and those are a template: nothing in the
module has such a constructor, nobody passes it an argument, and the newtype a
finding asks for would be asked of a bracket.

Three sites here wanted the types it asks for. The project command's expected
packages are a PackageName, the module command's extensions are an
ExtensionName, and an export list holds an ExportEntry rather than text. Two
more are a position or a path beside a message another library wrote, which is
the residue this shape has, so each says so in an annotation rather than
leaving it invisible.
GitHub