Skip to content

readDesc hook is still not plumbed sufficiently #3552

@ezyang

Description

@ezyang

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions