Skip to content

Source-location aware parser for package descriptions #1127

Open

Description

@dag

It would be nice if Cabal included a parser for .cabal files that remembers line and column numbers for parsed entities. This could then be used by tools like packdeps to give the source location for an outdated dependency, and in turn used in text editors to annotate lines with information from packdeps when editing a .cabal file.

More broadly, it would be nice to have an exact-printer for the relevant AST, to make it possible to write tools that process .cabal files programmatically without messing up their formatting.

Activity

  1. UnkindPartition commented on Nov 21, 2012

    @UnkindPartition
    Contributor

    This (an exact parser/printer) is something I would also like to see.

    I may work on it eventually, but it's not high on my priority list.

  2. 23Skidoo commented on Nov 23, 2012

    @23Skidoo
    Member

    It would be also nice to have the same for config files.

  3. dcoutts commented on Nov 12, 2013

    @dcoutts
    Contributor

    I have a new parser (for .cabal files and config files). The only problem is it needs parsec which currently we cannot depend on because it causes problems for GHC. There is however a plan to get GHC to not depend on Cabal, or rather have the ghc lib not depend on Cabal, only ghc-pkg & the build system. This may allow us to depend on parsec and so we could have a fast and nice new parser.

  4. dag commented on Nov 12, 2013

    @dag
    Author

    A silly thought: is ReadP too weak for this?

  5. dcoutts commented on Nov 12, 2013

    @dcoutts
    Contributor

    ReadP is what we use now. It's terrible. It has no error reporting and no source locations. It's also slow.

  6. byorgey commented on Nov 13, 2013

    @byorgey
    Member

    @dcoutts: Exciting! (A patient sort of excitement.)

  7. erikd commented on Dec 10, 2014

    @erikd
    Member

    I understand why we can't currently use Parsec for tthis, but would it be possible to use alex and happy? Obviously not as elegant as Parsec but probably better than ReadP.

  8. modified the milestones: , on Apr 23, 2015
  9. modified the milestones: Cabal 1.24, on Feb 21, 2016
  10. modified the milestone: Cabal 2.0 on Sep 6, 2016
  11. ezyang commented on Feb 6, 2017

    @ezyang
    Contributor

    @phadej has been working on a Parsec parser which will make this easier, but if we decide to modify GPD to store this information that is a fairly major breaking change. One possibility is to store the data out of line in a data structure of its own (similar to how API annotations in GHC work.)

    CC commercialhaskell/stackage#871
    CC @rvion

  12. ulysses4ever commented on Jun 10, 2022

    @ulysses4ever
    Collaborator

    I wonder how this is related to #7544 (if anyhow). Maybe it's superceded by #7544?..

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