Named and nameless types
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
We have a general principle in software engineering that things shouldn't know their own names. In the the DB case, that means talking about rows without their "surrogate key" with trick's like Persistent's `Entity`.
I think we could benefit from something similar in Cabal. Take for example, components, under the assumption I've finally finished my https://github.com/haskell/cabal/pull/5100 separating GDP from PD :D. We replace
```haskell
data Library = { libraryName = .., ... }
```
with
```haskell
data Library = ...
type NamedLibrary = (UnqualComponent, Library)
```
(or some strictly fancier trick) and so on.
A GDP could have quite invalid structure, so it should stay the same using `NamedLibrary` where `Library` used before, but a PD should ensure that names are not reassigned to components and instead have a `Map UnqualComponent Library` with a convenience for `NamedLibrary`.
This and similar tricks would allow us to enforce a bunch of invariants that are already made true in transformations like GDP -> PD but then only *assumed* with partial code rather than *enforced*.
CC @phadej
Contributor guide
Assessment
This issue has not been assessed yet.