plan.json documentation

Oleg Grenrus oleg.grenrus at iki.fi
Fri Mar 19 20:36:36 UTC 2021


A short answer: Look how cabal-docspec is implemented. It does do what
you want (i.e. finds all source files) to do its job too.

A slightly longer version:
- cabal-plan library parses plan.json, its types tell you what is there [1]
- plan doesn't include location of .cabal files directly, but it has
PkgLoc. From there you can find .cabal files
- in cabal-docspec (and cabal-hie) for that matter, I simplify GPD parts
using flags information in plan.json to figure out exactly which modules
are in play
    - this part is too complicated, can probably be done simpler with
finalizePD [2]
- cabal-docspec uses utilities in cabal-extras repository to figure out
GHC information for the previous step.

It's not simple, you need to combine parts, but all pieces are there.

- Oleg


[1]:
https://hackage.haskell.org/package/cabal-plan-0.7.2.0/docs/Cabal-Plan.html
[2]:
https://hackage.haskell.org/package/Cabal-3.4.0.0/docs/Distribution-PackageDescription-Configuration.html#v:finalizePD

On 19.3.2021 22.20, Nicolas Frisby wrote:
> Hi all. Without show-build-info yet and without a cabal-install
> library, a hobby project relies on parsing plan.json to access eg the
> list of .cabal files and their flags as configured during the most
> recent cabal-install invocation.
>
> I haven't found much documentation about plan.json. I'm particularly
> curious what are its current semantics and intended use, and if these
> are intended to remain stable going forward.
>
> Some example specific questions:
>
>   * Would show-build-info supplant plan.json? If so, would there be a
> deprecation delay?
>
>   * The docs say "A JSON serialization of the computed install plan
> intended for integrating cabal with external tooling." It seems likely
> that answering my questions will involve explaining what an "install
> plan" is. (I'm unfortunately unfamiliar with Cabal internals, and
> ReadTheDocs search doesn't seem to support phrases as queries.)
>
>   * What determines which packages have entries in the plan.json file
> after a particular cabal-install invocation? Will it always include
> all local .cabal files? (🤞)
>
>   * Is there enough information in the plan.json file in order to map
> an entry there for source repository package to the corresponding path
> under the builddir's `src` directory? There seems to be some sort of
> hash involved in that path and I haven't figured what its inputs are
> and whether the plan.json file includes them all.
>
> Thank you for your time. -Nick
>
> PS - My hobby project driving this question is based on wanting to
> parse all local source files without having to typecheck/build any of
> them (ideally nor their non-local dependencies). I need each source
> file path and corresponding language extensions etc in order to invoke
> the parser. (hie-bios doesn't suffice because its solution to this
> problem involves building dependencies, possibly including local
> packages.)
>
> If you see a more direct path that doesn't involve plan.json, please
> say so. Thanks again!
>
> _______________________________________________
> cabal-devel mailing list
> cabal-devel at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/cabal-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/cabal-devel/attachments/20210319/166d7161/attachment.html>


More information about the cabal-devel mailing list