cabal-plan-0.5.0.0: Library and utiltity for processing cabal's plan.json file

LicenseGPL-2.0-or-later
Safe HaskellNone
LanguageHaskell2010

Cabal.Plan

Contents

Description

Utilities for reading cabal's plan.json file

plan.json are generated when using cabal Nix-style Local Builds.

Synopsis

Documentation

data PlanJson Source #

Represents the information contained in cabal's plan.json file.

This comprises basic information describing the environment as well as the install/build plan computed by cabal.

Constructors

PlanJson 

Fields

Instances
Show PlanJson Source # 
Instance details

Defined in Cabal.Plan

FromJSON PlanJson Source # 
Instance details

Defined in Cabal.Plan

data Unit Source #

Represents a build-plan unit uniquely identified by its UnitId

Constructors

Unit 

Fields

Instances
Show Unit Source # 
Instance details

Defined in Cabal.Plan

Methods

showsPrec :: Int -> Unit -> ShowS #

show :: Unit -> String #

showList :: [Unit] -> ShowS #

FromJSON Unit Source # 
Instance details

Defined in Cabal.Plan

data CompName Source #

Component name inside a build-plan unit

A similiar type exists in Cabal codebase, see Distribution.Simple.LocalBuildInfo.ComponentName

dispCompName :: CompName -> Text Source #

Pretty print CompName in the same syntax that is used in plan.json. Note that this string can not be used as a target-selector on the cabal command-line. See dispCompNameTarget for a target-selector compatible pretty printer.

dispCompNameTarget :: PkgName -> CompName -> Text Source #

Pretty print CompName in cabal's target-selector syntax.

Since: 0.5.0.0

data CompInfo Source #

Describes component-specific information inside a Unit

Constructors

CompInfo 

Fields

Instances
Show CompInfo Source # 
Instance details

Defined in Cabal.Plan

FromJSON CompInfo Source # 
Instance details

Defined in Cabal.Plan

data UnitType Source #

Describes kind of build unit and its provenance

Constructors

UnitTypeBuiltin

Lives in global (non-nix-style) package db

UnitTypeGlobal

Lives in Nix-store cache

UnitTypeLocal

Local package

UnitTypeInplace

Local in-place package

Instances
Eq UnitType Source # 
Instance details

Defined in Cabal.Plan

Show UnitType Source # 
Instance details

Defined in Cabal.Plan

Basic types

newtype Ver Source #

Equivalent to Cabal's Distribution.Package.Version

Constructors

Ver [Int] 
Instances
Eq Ver Source # 
Instance details

Defined in Cabal.Plan

Methods

(==) :: Ver -> Ver -> Bool #

(/=) :: Ver -> Ver -> Bool #

Ord Ver Source # 
Instance details

Defined in Cabal.Plan

Methods

compare :: Ver -> Ver -> Ordering #

(<) :: Ver -> Ver -> Bool #

(<=) :: Ver -> Ver -> Bool #

(>) :: Ver -> Ver -> Bool #

(>=) :: Ver -> Ver -> Bool #

max :: Ver -> Ver -> Ver #

min :: Ver -> Ver -> Ver #

Show Ver Source # 
Instance details

Defined in Cabal.Plan

Methods

showsPrec :: Int -> Ver -> ShowS #

show :: Ver -> String #

showList :: [Ver] -> ShowS #

ToJSON Ver Source # 
Instance details

Defined in Cabal.Plan

FromJSON Ver Source # 
Instance details

Defined in Cabal.Plan

dispVer :: Ver -> Text Source #

Pretty print Ver

newtype PkgName Source #

Equivalent to Cabal's Distribution.Package.PackageName

Constructors

PkgName Text 
Instances
Eq PkgName Source # 
Instance details

Defined in Cabal.Plan

Methods

(==) :: PkgName -> PkgName -> Bool #

(/=) :: PkgName -> PkgName -> Bool #

Ord PkgName Source # 
Instance details

Defined in Cabal.Plan

Show PkgName Source # 
Instance details

Defined in Cabal.Plan

ToJSON PkgName Source # 
Instance details

Defined in Cabal.Plan

ToJSONKey PkgName Source # 
Instance details

Defined in Cabal.Plan

FromJSON PkgName Source # 
Instance details

Defined in Cabal.Plan

FromJSONKey PkgName Source # 
Instance details

Defined in Cabal.Plan

data PkgId Source #

Equivalent to Cabal's Distribution.Package.PackageIdentifier

Constructors

PkgId !PkgName !Ver 
Instances
Eq PkgId Source # 
Instance details

Defined in Cabal.Plan

Methods

(==) :: PkgId -> PkgId -> Bool #

(/=) :: PkgId -> PkgId -> Bool #

Ord PkgId Source # 
Instance details

Defined in Cabal.Plan

Methods

compare :: PkgId -> PkgId -> Ordering #

(<) :: PkgId -> PkgId -> Bool #

(<=) :: PkgId -> PkgId -> Bool #

(>) :: PkgId -> PkgId -> Bool #

(>=) :: PkgId -> PkgId -> Bool #

max :: PkgId -> PkgId -> PkgId #

min :: PkgId -> PkgId -> PkgId #

Show PkgId Source # 
Instance details

Defined in Cabal.Plan

Methods

showsPrec :: Int -> PkgId -> ShowS #

show :: PkgId -> String #

showList :: [PkgId] -> ShowS #

ToJSON PkgId Source # 
Instance details

Defined in Cabal.Plan

ToJSONKey PkgId Source # 
Instance details

Defined in Cabal.Plan

FromJSON PkgId Source # 
Instance details

Defined in Cabal.Plan

FromJSONKey PkgId Source # 
Instance details

Defined in Cabal.Plan

dispPkgId :: PkgId -> Text Source #

Pretty print PkgId

newtype UnitId Source #

Equivalent to Cabal's Distribution.Package.UnitId

Constructors

UnitId Text 
Instances
Eq UnitId Source # 
Instance details

Defined in Cabal.Plan

Methods

(==) :: UnitId -> UnitId -> Bool #

(/=) :: UnitId -> UnitId -> Bool #

Ord UnitId Source # 
Instance details

Defined in Cabal.Plan

Show UnitId Source # 
Instance details

Defined in Cabal.Plan

ToJSON UnitId Source # 
Instance details

Defined in Cabal.Plan

ToJSONKey UnitId Source # 
Instance details

Defined in Cabal.Plan

FromJSON UnitId Source # 
Instance details

Defined in Cabal.Plan

FromJSONKey UnitId Source # 
Instance details

Defined in Cabal.Plan

newtype FlagName Source #

Equivalent to Cabal's Distribution.PackageDescription.FlagName

Since: 0.3.0.0

Constructors

FlagName Text 

SHA-256

data Sha256 Source #

SHA-256 hash

Instances
Eq Sha256 Source # 
Instance details

Defined in Cabal.Plan

Methods

(==) :: Sha256 -> Sha256 -> Bool #

(/=) :: Sha256 -> Sha256 -> Bool #

Ord Sha256 Source # 
Instance details

Defined in Cabal.Plan

Show Sha256 Source # 
Instance details

Defined in Cabal.Plan

ToJSON Sha256 Source # 
Instance details

Defined in Cabal.Plan

FromJSON Sha256 Source # 
Instance details

Defined in Cabal.Plan

dispSha256 :: Sha256 -> Text Source #

Pretty print Sha256 as base-16.

parseSha256 :: Text -> Maybe Sha256 Source #

Parse base-16 encoded Sha256.

Returns Nothing in case of parsing failure.

Since: 0.3.0.0

sha256ToByteString :: Sha256 -> ByteString Source #

Export the Sha256 digest to a 32-byte ByteString.

Since: 0.3.0.0

sha256FromByteString :: ByteString -> Maybe Sha256 Source #

Import the Sha256 digest from a 32-byte ByteString.

Returns Nothing if input ByteString has incorrect length.

Since: 0.3.0.0

PkgLoc

data PkgLoc Source #

Equivalent to Cabal's Distribution.Client.Types.PackageLocation

Since: 0.5.0.0

Instances
Eq PkgLoc Source # 
Instance details

Defined in Cabal.Plan

Methods

(==) :: PkgLoc -> PkgLoc -> Bool #

(/=) :: PkgLoc -> PkgLoc -> Bool #

Ord PkgLoc Source # 
Instance details

Defined in Cabal.Plan

Show PkgLoc Source # 
Instance details

Defined in Cabal.Plan

FromJSON PkgLoc Source # 
Instance details

Defined in Cabal.Plan

data Repo Source #

Equivalent to Cabal's Distribution.Types.SourceRepo

Since: 0.5.0.0

Instances
Eq Repo Source # 
Instance details

Defined in Cabal.Plan

Methods

(==) :: Repo -> Repo -> Bool #

(/=) :: Repo -> Repo -> Bool #

Ord Repo Source # 
Instance details

Defined in Cabal.Plan

Methods

compare :: Repo -> Repo -> Ordering #

(<) :: Repo -> Repo -> Bool #

(<=) :: Repo -> Repo -> Bool #

(>) :: Repo -> Repo -> Bool #

(>=) :: Repo -> Repo -> Bool #

max :: Repo -> Repo -> Repo #

min :: Repo -> Repo -> Repo #

Show Repo Source # 
Instance details

Defined in Cabal.Plan

Methods

showsPrec :: Int -> Repo -> ShowS #

show :: Repo -> String #

showList :: [Repo] -> ShowS #

FromJSON Repo Source # 
Instance details

Defined in Cabal.Plan

data SourceRepo Source #

Equivalent to Cabal's Distribution.Client.Types.Repo

Since: 0.5.0.0

Constructors

SourceRepo 

newtype URI Source #

Represents an URI (used e.g. by Repo)

Since: 0.5.0.0

Constructors

URI Text 
Instances
Eq URI Source # 
Instance details

Defined in Cabal.Plan

Methods

(==) :: URI -> URI -> Bool #

(/=) :: URI -> URI -> Bool #

Ord URI Source # 
Instance details

Defined in Cabal.Plan

Methods

compare :: URI -> URI -> Ordering #

(<) :: URI -> URI -> Bool #

(<=) :: URI -> URI -> Bool #

(>) :: URI -> URI -> Bool #

(>=) :: URI -> URI -> Bool #

max :: URI -> URI -> URI #

min :: URI -> URI -> URI #

Show URI Source # 
Instance details

Defined in Cabal.Plan

Methods

showsPrec :: Int -> URI -> ShowS #

show :: URI -> String #

showList :: [URI] -> ShowS #

ToJSON URI Source # 
Instance details

Defined in Cabal.Plan

ToJSONKey URI Source # 
Instance details

Defined in Cabal.Plan

FromJSON URI Source # 
Instance details

Defined in Cabal.Plan

FromJSONKey URI Source # 
Instance details

Defined in Cabal.Plan

data RepoType Source #

Equivalent to Cabal's Distribution.Client.SourceRepo.RepoType

Since: 0.5.0.0

Instances
Eq RepoType Source # 
Instance details

Defined in Cabal.Plan

Ord RepoType Source # 
Instance details

Defined in Cabal.Plan

Show RepoType Source # 
Instance details

Defined in Cabal.Plan

FromJSON RepoType Source # 
Instance details

Defined in Cabal.Plan

Utilities

planJsonIdGraph :: PlanJson -> Map UnitId (Set UnitId) Source #

Extract directed UnitId dependency graph edges from pjUnits

This graph contains both, library and executable dependencies edges

planJsonIdRoots :: PlanJson -> Set UnitId Source #

Extract UnitId root nodes from dependency graph computed by planJsonIdGraph

Convenience functions

data SearchPlanJson Source #

Where/how to search for the plan.json file.

Constructors

ProjectRelativeToDir FilePath

Find the project root relative to specified directory and look for plan.json there.

InBuildDir FilePath

Look for plan.json in specified build directory.

findAndDecodePlanJson :: SearchPlanJson -> IO PlanJson Source #

Locates the project root for cabal project relative to specified directory.

plan.json is located from either the optional build dir argument, or in the default directory (dist-newstyle) relative to the project root.

The folder assumed to be the project-root is returned as well.

This function determines the project root in a slightly more liberal manner than cabal-install. If no cabal.project is found, cabal-install assumes an implicit cabal.project if the current directory contains any *.cabal files.

This function looks for any *.cabal files in directories above the current one and behaves as if there is an implicit cabal.project in that directory when looking for a plan.json.

Throws IO exceptions on errors.

findProjectRoot :: FilePath -> IO (Maybe FilePath) Source #

Find project root relative to a directory, this emulates cabal's current heuristic, but is slightly more liberal. If no cabal.project is found, cabal-install looks for *.cabal files in the specified directory only. This function also considers *.cabal files in directories higher up in the hierarchy.

decodePlanJson :: FilePath -> IO PlanJson Source #

Decodes plan.json file location provided as FilePath

This is a trivial convenience function so that the caller doesn't have to depend on aeson directly

Throws IO exceptions on errors.