haskell / haskell/cabal

readDesc hook is still not plumbed sufficiently

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

Description

Hello @thumphries, you might be interested in this one.

While working on an unrelated refactoring, I realized that the `readDesc` hook is not being plumbed everywhere it needs to be. To make matters worse, I'm not sure what we can do.

The issue is this code in `Cabal/Distribution/PackageDescription/Check.hs`, which checks that the `.cabal` file does not have a byte order mark:

```
checkCabalFileBOM :: Monad m => CheckPackageContentOps m
-> m (Maybe PackageCheck)
checkCabalFileBOM ops = do
epdfile <- findPackageDesc ops
case epdfile of
Left pc -> return $ Just pc
Right pdfile -> (flip check pc . startsWithBOM . fromUTF8) `liftM` (getFileContents ops pdfile)
where pc = PackageDistInexcusable $
pdfile ++ " starts with an Unicode byte order mark (BOM). This may cause problems with older cabal versions."
```

No hooks to be found, so they can't possibly be applied here. To add insult to injury, this function gets invoked when you configure. So whatever you were using `readDesc` for, Cabal is STILL banging on the actual file. (If it even exists!)

@phadej, this is your code. How do you think it should interact with the `readDesc` hook? Should we drop this code? Or maybe add a hook that passes in the unparsed string of the Cabal file?

EDIT: Or maybe we can add the presence of BOM to `GenericPackageDescription` and `PackageDescription`, and then read it off as a pure package check?

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.