haskell / haskell/cabal

ProgramDb should be transparently lazy, or not lazy at all

Open
#3,250 5 comments 0 reactions 0 assignees View on GitHub
Cabal: other type: refactor
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

Why does the type signature of `requireProgram` return a `ProgramDb`?

```
requireProgram :: Verbosity -> Program -> ProgramDb
-> IO (ConfiguredProgram, ProgramDb)
```

The answer is, if a program was previously not configured, and `requireProgram` configures it, then it is now recorded as a configured program in the new ProgramDb.

Sounds good, right? No! Grep Cabal's source code and you'll see plenty of places where people `requireProgram` and ignore the returned `ProgramDb`. This just seems like a work around the fact that `ProgramDb` is not a mutable data structure. (It's convenient for this to be pure since we serialize it.) We should try to do something better here! I think some sort of mutable variant of `ProgramDb` which automatically "fixes itself up" would be better,

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.