Cabal: Named and nameless types

Created on 12 Apr 2018  路  8Comments  路  Source: haskell/cabal

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

data Library = { libraryName = .., ... }

with

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

discussion enhancement

Most helpful comment

Probably no

All 8 comments

The idea sounds sensible to me.

Relatedly, I'd like to parse with [(UnqualComponent, CondTree Libray)], and then convert to Map UnqualComponent (CondTree Libray). This mirrors what we could do with my unmerged LibDependency and @fgaz's Dependency, in that that is also grouping by package name.

@Ericson2314 what's status with this. Is this post-3.0 now?

@phadej Yeah I haven't started on it. Should I try to bang it out quick? :D

Probably no

That's what I figured. My only concern for this and a few other things is what the situation wrt breaking changes will be after 3.

We can have breaking changes in the next major release (3.2).

OK great!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tfausak picture tfausak  路  4Comments

nomeata picture nomeata  路  4Comments

menelaos picture menelaos  路  3Comments

phadej picture phadej  路  4Comments

chrissound picture chrissound  路  4Comments