Skip to content

cabal format is not listed in --help message #2460

Open

Description

@osa1

Any ideas why this command is hidden? I recently discovered this and I think it's very useful.

Activity

  1. 23Skidoo commented on Mar 9, 2015

    @23Skidoo
    Member

    There are some bugs, e.g. #2353.

  2. added this to the milestone on Apr 25, 2015
  3. modified the milestones: cabal-install 1.24, on Feb 21, 2016
  4. 23Skidoo commented on Apr 23, 2016

    @23Skidoo
    Member

    Fixing this is trivial, but we'll need to fix #2661 and #2681 first before making this feature public. See discussion in #2607, specifically #2607 (comment).

  5. modified the milestone: cabal-install 2.0 on Sep 6, 2016
  6. gbaz commented on Mar 17, 2018

    @gbaz
    Collaborator

    It looks like both the referenced bugs were fixed. Are there any further blockers?

  7. gbaz commented on Mar 17, 2018

    @gbaz
    Collaborator

    Here's a script I bodged together from the one in the other ticket, but updated for the latest cabal.

    module Main (main) where
    
    import Control.Monad
    import Control.Applicative
    import Distribution.Verbosity
    import Distribution.Client.IndexUtils
    import qualified Distribution.PackageDescription.Parsec as PackageDesc.Parse
    import Distribution.PackageDescription.PrettyPrint
    import Distribution.ParseUtils
    import qualified Data.ByteString.Char8 as BS
    import Data.List
    
    check :: FilePath -> IO ()
    check cabal = do
      print cabal
      cabalfile <- BS.readFile cabal
      let desc1 = parsePackageDescription  cabalfile
      case desc1 of
        Nothing -> print "failparse"
        Just desc -> do
          let desc' = parsePackageDescription $ BS.pack (showGenericPackageDescription desc)
          when (Just desc /= desc') $ do
            print $  Just desc
            print $  desc'
            fail cabal
    
    parsePackageDescription content = either (const Nothing) Just $ snd $ PackageDesc.Parse.runParseResult $ PackageDesc.Parse.parseGenericPackageDescription $ content
    
    myFilter x  = not $ "lambdaBase" `isInfixOf` x || "wiringPi" `isInfixOf` x || "constrained-monads" `isInfixOf` x
    
    main :: IO ()
    main = do
      -- Generate listing with
      -- find . -type f -name '*.cabal' > cabal-files
      cabalFiles <- Prelude.filter myFilter . Prelude.lines <$> Prelude.readFile "cabal-files"
      mapM_ check cabalFiles
    

    The errors it seems to run into are all about round-trips with character encodings.

    E.g. in the original you have something like copyright = "2016 Donnacha Ois\237n Kidney", and in the processed file you have copyright = "2016 Donnacha Ois\65533 Kidney"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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