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

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

Methods

showsPrec :: Int -> PlanJson -> ShowS

show :: PlanJson -> String

showList :: [PlanJson] -> ShowS

FromJSON PlanJson Source # 
Instance details

Defined in Cabal.Plan

Methods

parseJSON :: Value -> Parser PlanJson

parseJSONList :: Value -> Parser [PlanJson]

data Unit Source #

Represents a build-plan unit uniquely identified by its UnitId

Constructors

Unit 

Fields

  • uId :: !UnitId

    Unit ID uniquely identifying a Unit in install plan

  • uPId :: !PkgId

    Package name and version (not necessarily unique within plan)

  • uType :: !UnitType

    Describes type of build item, see UnitType

  • uSha256 :: !(Maybe Sha256)

    SHA256 source tarball checksum (as used by e.g. hackage-security)

  • uComps :: !(Map CompName CompInfo)

    Components identified by UnitId

    When cabal needs to fall back to legacy-mode (currently for custom build-types or obsolete cabal-version values), uComps may contain more than one element.

  • uFlags :: !(Map FlagName Bool)

    cabal flag settings (not available for UnitTypeBuiltin)

  • uDistDir :: !(Maybe FilePath)

    In-place dist-dir (if available)

    Since: 0.3.0.0

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

Methods

parseJSON :: Value -> Parser Unit

parseJSONList :: Value -> Parser [Unit]

data CompName Source #

Component name inside a build-plan unit

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

Constructors

CompNameLib 
CompNameSubLib !Text 
CompNameFLib !Text

Since: 0.3.0.0

CompNameExe !Text 
CompNameTest !Text 
CompNameBench !Text 
CompNameSetup 
Instances
Eq CompName Source # 
Instance details

Defined in Cabal.Plan

Methods

(==) :: CompName -> CompName -> Bool

(/=) :: CompName -> CompName -> Bool

Ord CompName Source # 
Instance details

Defined in Cabal.Plan

Methods

compare :: CompName -> CompName -> Ordering

(<) :: CompName -> CompName -> Bool

(<=) :: CompName -> CompName -> Bool

(>) :: CompName -> CompName -> Bool

(>=) :: CompName -> CompName -> Bool

max :: CompName -> CompName -> CompName

min :: CompName -> CompName -> CompName

Show CompName Source # 
Instance details

Defined in Cabal.Plan

Methods

showsPrec :: Int -> CompName -> ShowS

show :: CompName -> String

showList :: [CompName] -> ShowS

FromJSON CompName Source # 
Instance details

Defined in Cabal.Plan

Methods

parseJSON :: Value -> Parser CompName

parseJSONList :: Value -> Parser [CompName]

FromJSONKey CompName Source # 
Instance details

Defined in Cabal.Plan

Methods

fromJSONKey :: FromJSONKeyFunction CompName

fromJSONKeyList :: FromJSONKeyFunction [CompName]

ToJSON CompName Source # 
Instance details

Defined in Cabal.Plan

Methods

toJSON :: CompName -> Value

toEncoding :: CompName -> Encoding

toJSONList :: [CompName] -> Value

toEncodingList :: [CompName] -> Encoding

ToJSONKey CompName Source # 
Instance details

Defined in Cabal.Plan

Methods

toJSONKey :: ToJSONKeyFunction CompName

toJSONKeyList :: ToJSONKeyFunction [CompName]

dispCompName :: CompName -> Text Source #

Pretty print CompName

data CompInfo Source #

Describes component-specific information inside a Unit

Constructors

CompInfo 

Fields

Instances
Show CompInfo Source # 
Instance details

Defined in Cabal.Plan

Methods

showsPrec :: Int -> CompInfo -> ShowS

show :: CompInfo -> String

showList :: [CompInfo] -> ShowS

FromJSON CompInfo Source # 
Instance details

Defined in Cabal.Plan

Methods

parseJSON :: Value -> Parser CompInfo

parseJSONList :: Value -> Parser [CompInfo]

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

Methods

(==) :: UnitType -> UnitType -> Bool

(/=) :: UnitType -> UnitType -> Bool

Show UnitType Source # 
Instance details

Defined in Cabal.Plan

Methods

showsPrec :: Int -> UnitType -> ShowS

show :: UnitType -> String

showList :: [UnitType] -> ShowS

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

FromJSON Ver Source # 
Instance details

Defined in Cabal.Plan

Methods

parseJSON :: Value -> Parser Ver

parseJSONList :: Value -> Parser [Ver]

ToJSON Ver Source # 
Instance details

Defined in Cabal.Plan

Methods

toJSON :: Ver -> Value

toEncoding :: Ver -> Encoding

toJSONList :: [Ver] -> Value

toEncodingList :: [Ver] -> Encoding

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

Methods

compare :: PkgName -> PkgName -> Ordering

(<) :: PkgName -> PkgName -> Bool

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

(>) :: PkgName -> PkgName -> Bool

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

max :: PkgName -> PkgName -> PkgName

min :: PkgName -> PkgName -> PkgName

Show PkgName Source # 
Instance details

Defined in Cabal.Plan

Methods

showsPrec :: Int -> PkgName -> ShowS

show :: PkgName -> String

showList :: [PkgName] -> ShowS

FromJSON PkgName Source # 
Instance details

Defined in Cabal.Plan

Methods

parseJSON :: Value -> Parser PkgName

parseJSONList :: Value -> Parser [PkgName]

FromJSONKey PkgName Source # 
Instance details

Defined in Cabal.Plan

Methods

fromJSONKey :: FromJSONKeyFunction PkgName

fromJSONKeyList :: FromJSONKeyFunction [PkgName]

ToJSON PkgName Source # 
Instance details

Defined in Cabal.Plan

Methods

toJSON :: PkgName -> Value

toEncoding :: PkgName -> Encoding

toJSONList :: [PkgName] -> Value

toEncodingList :: [PkgName] -> Encoding

ToJSONKey PkgName Source # 
Instance details

Defined in Cabal.Plan

Methods

toJSONKey :: ToJSONKeyFunction PkgName

toJSONKeyList :: ToJSONKeyFunction [PkgName]

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

FromJSON PkgId Source # 
Instance details

Defined in Cabal.Plan

Methods

parseJSON :: Value -> Parser PkgId

parseJSONList :: Value -> Parser [PkgId]

FromJSONKey PkgId Source # 
Instance details

Defined in Cabal.Plan

Methods

fromJSONKey :: FromJSONKeyFunction PkgId

fromJSONKeyList :: FromJSONKeyFunction [PkgId]

ToJSON PkgId Source # 
Instance details

Defined in Cabal.Plan

Methods

toJSON :: PkgId -> Value

toEncoding :: PkgId -> Encoding

toJSONList :: [PkgId] -> Value

toEncodingList :: [PkgId] -> Encoding

ToJSONKey PkgId Source # 
Instance details

Defined in Cabal.Plan

Methods

toJSONKey :: ToJSONKeyFunction PkgId

toJSONKeyList :: ToJSONKeyFunction [PkgId]

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

Methods

compare :: UnitId -> UnitId -> Ordering

(<) :: UnitId -> UnitId -> Bool

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

(>) :: UnitId -> UnitId -> Bool

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

max :: UnitId -> UnitId -> UnitId

min :: UnitId -> UnitId -> UnitId

Show UnitId Source # 
Instance details

Defined in Cabal.Plan

Methods

showsPrec :: Int -> UnitId -> ShowS

show :: UnitId -> String

showList :: [UnitId] -> ShowS

FromJSON UnitId Source # 
Instance details

Defined in Cabal.Plan

Methods

parseJSON :: Value -> Parser UnitId

parseJSONList :: Value -> Parser [UnitId]

FromJSONKey UnitId Source # 
Instance details

Defined in Cabal.Plan

Methods

fromJSONKey :: FromJSONKeyFunction UnitId

fromJSONKeyList :: FromJSONKeyFunction [UnitId]

ToJSON UnitId Source # 
Instance details

Defined in Cabal.Plan

Methods

toJSON :: UnitId -> Value

toEncoding :: UnitId -> Encoding

toJSONList :: [UnitId] -> Value

toEncodingList :: [UnitId] -> Encoding

ToJSONKey UnitId Source # 
Instance details

Defined in Cabal.Plan

Methods

toJSONKey :: ToJSONKeyFunction UnitId

toJSONKeyList :: ToJSONKeyFunction [UnitId]

newtype FlagName Source #

Equivalent to Cabal's Distribution.PackageDescription.FlagName

Since: 0.3.0.0

Constructors

FlagName Text 
Instances
Eq FlagName Source # 
Instance details

Defined in Cabal.Plan

Methods

(==) :: FlagName -> FlagName -> Bool

(/=) :: FlagName -> FlagName -> Bool

Ord FlagName Source # 
Instance details

Defined in Cabal.Plan

Methods

compare :: FlagName -> FlagName -> Ordering

(<) :: FlagName -> FlagName -> Bool

(<=) :: FlagName -> FlagName -> Bool

(>) :: FlagName -> FlagName -> Bool

(>=) :: FlagName -> FlagName -> Bool

max :: FlagName -> FlagName -> FlagName

min :: FlagName -> FlagName -> FlagName

Show FlagName Source # 
Instance details

Defined in Cabal.Plan

Methods

showsPrec :: Int -> FlagName -> ShowS

show :: FlagName -> String

showList :: [FlagName] -> ShowS

FromJSON FlagName Source # 
Instance details

Defined in Cabal.Plan

Methods

parseJSON :: Value -> Parser FlagName

parseJSONList :: Value -> Parser [FlagName]

FromJSONKey FlagName Source # 
Instance details

Defined in Cabal.Plan

Methods

fromJSONKey :: FromJSONKeyFunction FlagName

fromJSONKeyList :: FromJSONKeyFunction [FlagName]

ToJSON FlagName Source # 
Instance details

Defined in Cabal.Plan

Methods

toJSON :: FlagName -> Value

toEncoding :: FlagName -> Encoding

toJSONList :: [FlagName] -> Value

toEncodingList :: [FlagName] -> Encoding

ToJSONKey FlagName Source # 
Instance details

Defined in Cabal.Plan

Methods

toJSONKey :: ToJSONKeyFunction FlagName

toJSONKeyList :: ToJSONKeyFunction [FlagName]

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

Methods

compare :: Sha256 -> Sha256 -> Ordering

(<) :: Sha256 -> Sha256 -> Bool

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

(>) :: Sha256 -> Sha256 -> Bool

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

max :: Sha256 -> Sha256 -> Sha256

min :: Sha256 -> Sha256 -> Sha256

Show Sha256 Source # 
Instance details

Defined in Cabal.Plan

Methods

showsPrec :: Int -> Sha256 -> ShowS

show :: Sha256 -> String

showList :: [Sha256] -> ShowS

FromJSON Sha256 Source # 
Instance details

Defined in Cabal.Plan

Methods

parseJSON :: Value -> Parser Sha256

parseJSONList :: Value -> Parser [Sha256]

ToJSON Sha256 Source # 
Instance details

Defined in Cabal.Plan

Methods

toJSON :: Sha256 -> Value

toEncoding :: Sha256 -> Encoding

toJSONList :: [Sha256] -> Value

toEncodingList :: [Sha256] -> Encoding

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

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.

Instances
Eq SearchPlanJson Source # 
Instance details

Defined in Cabal.Plan

Read SearchPlanJson Source # 
Instance details

Defined in Cabal.Plan

Methods

readsPrec :: Int -> ReadS SearchPlanJson

readList :: ReadS [SearchPlanJson]

readPrec :: ReadPrec SearchPlanJson

readListPrec :: ReadPrec [SearchPlanJson]

Show SearchPlanJson Source # 
Instance details

Defined in Cabal.Plan

Methods

showsPrec :: Int -> SearchPlanJson -> ShowS

show :: SearchPlanJson -> String

showList :: [SearchPlanJson] -> ShowS

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.