alunduil / alunduil/siren-json.hs

Remove the partial record fields on SubEntity

Aperta
#133 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Haskell
Stelle
3
Fork
1
Merge medio
5h 46m
PR unite (30g)
63

Descrizione

## Summary

Restructure `SubEntity` so `sEntity` and `sRel` are no longer partial selectors, clearing the two `-Wpartial-fields` warnings that #62 surfaced.

## Motivation

`SubEntity` is a sum whose second constructor carries record fields:

```haskell
data SubEntity =
EmbeddedLink Link
| EmbeddedRepresentation
{ sEntity :: Entity
, sRel :: [Text]
}
```

`sEntity` and `sRel` are therefore partial — applying either to an `EmbeddedLink` throws at runtime rather than failing to compile. #62 added `-Wpartial-fields` to the shared warning stanza, and GHC now reports both at `src/Data/SirenJSON.hs:73` and `:74` on every build.

The fix is not a warning suppression: it changes the exported type. That makes it a breaking change, which is why #62 left the warnings visible rather than widening its own scope.

## Scope

Pick a shape and apply it, then update `Data.SirenJSON.Arbitrary` and `Data.SirenJSON.Norm`, both of which pattern-match `EmbeddedRepresentation{..}`:

- Lift the record into its own type, so `SubEntity` becomes `EmbeddedLink Link | EmbeddedRepresentation Representation` and the selectors are total on `Representation`.
- Or drop the field names and match positionally, which clears the warning but loses the accessors consumers may be using.

The first keeps accessor ergonomics and is the likelier choice; the decision belongs in this issue rather than in review.

## Acceptance criteria

- [ ] `cabal build` reports no `-Wpartial-fields` warnings.
- [ ] The test suite passes unchanged in behaviour — the JSON encoding of a sub-entity is unaffected either way.
- [ ] `CHANGELOG.md` records the breaking change under `### Changed` or `### Removed`.

## Additional context

Blocks #69 (1.0.0.0 release) only in the sense that the API commitment should not ship with a known partial selector. If the restructure lands after 1.0.0.0 it costs a major bump, so it is cheaper to decide before the cut.

Surfaced while working #62; see the gotchas in #132.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.