| License | GPL-2.0-or-later |
|---|---|
| Safe Haskell | None |
| Language | Haskell2010 |
Cabal.Plan
Description
Utilities for reading cabal's plan.json file
plan.json are generated when using cabal
Nix-style Local Builds.
Synopsis
- data PlanJson = PlanJson {
- pjCabalVersion :: !Ver
- pjCabalLibVersion :: !Ver
- pjCompilerId :: !PkgId
- pjArch :: !Text
- pjOs :: !Text
- pjUnits :: !(Map UnitId Unit)
- data Unit = Unit {}
- data CompName
- = CompNameLib
- | CompNameSubLib !Text
- | CompNameFLib !Text
- | CompNameExe !Text
- | CompNameTest !Text
- | CompNameBench !Text
- | CompNameSetup
- dispCompName :: CompName -> Text
- dispCompNameTarget :: PkgName -> CompName -> Text
- data CompInfo = CompInfo {}
- data UnitType
- newtype Ver = Ver [Int]
- dispVer :: Ver -> Text
- newtype PkgName = PkgName Text
- data PkgId = PkgId !PkgName !Ver
- dispPkgId :: PkgId -> Text
- newtype UnitId = UnitId Text
- newtype FlagName = FlagName Text
- data Sha256
- dispSha256 :: Sha256 -> Text
- parseSha256 :: Text -> Maybe Sha256
- sha256ToByteString :: Sha256 -> ByteString
- sha256FromByteString :: ByteString -> Maybe Sha256
- data PkgLoc
- = LocalUnpackedPackage !FilePath
- | LocalTarballPackage !FilePath
- | RemoteTarballPackage !URI
- | RepoTarballPackage !Repo
- | RemoteSourceRepoPackage !SourceRepo
- data Repo
- = RepoLocal !FilePath
- | RepoRemote !URI
- | RepoSecure !URI
- | RepoLocalNoIndex !FilePath
- data SourceRepo = SourceRepo {}
- newtype URI = URI Text
- data RepoType
- planJsonIdGraph :: PlanJson -> Map UnitId (Set UnitId)
- planJsonIdRoots :: PlanJson -> Set UnitId
- data SearchPlanJson
- = ProjectRelativeToDir FilePath
- | InBuildDir FilePath
- | ExactPath FilePath
- findAndDecodePlanJson :: SearchPlanJson -> IO PlanJson
- findPlanJson :: SearchPlanJson -> IO FilePath
- findProjectRoot :: FilePath -> IO (Maybe FilePath)
- decodePlanJson :: FilePath -> IO PlanJson
Documentation
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
| FromJSON PlanJson Source # | |
Defined in Cabal.Plan Methods parseJSON :: Value -> Parser PlanJson parseJSONList :: Value -> Parser [PlanJson] omittedField :: Maybe PlanJson | |
| Show PlanJson Source # | |
Represents a build-plan unit uniquely identified by its UnitId
Constructors
| Unit | |
Fields
| |
Instances
| FromJSON Unit Source # | |
Defined in Cabal.Plan Methods parseJSON :: Value -> Parser Unit parseJSONList :: Value -> Parser [Unit] omittedField :: Maybe Unit | |
| Show Unit 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
| FromJSON CompName Source # | |
Defined in Cabal.Plan Methods parseJSON :: Value -> Parser CompName parseJSONList :: Value -> Parser [CompName] omittedField :: Maybe CompName | |
| FromJSONKey CompName Source # | |
Defined in Cabal.Plan | |
| ToJSON CompName Source # | |
Defined in Cabal.Plan Methods toEncoding :: CompName -> Encoding toJSONList :: [CompName] -> Value toEncodingList :: [CompName] -> Encoding | |
| ToJSONKey CompName Source # | |
Defined in Cabal.Plan | |
| Show CompName Source # | |
| Eq CompName Source # | |
| Ord CompName Source # | |
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
Describes component-specific information inside a Unit
Constructors
| CompInfo | |
Instances
| FromJSON CompInfo Source # | |
Defined in Cabal.Plan Methods parseJSON :: Value -> Parser CompInfo parseJSONList :: Value -> Parser [CompInfo] omittedField :: Maybe CompInfo | |
| Show CompInfo 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 |
Basic types
Equivalent to Cabal's Distribution.Package.Version
Constructors
| Ver [Int] |
Instances
| FromJSON Ver Source # | |
Defined in Cabal.Plan Methods parseJSON :: Value -> Parser Ver parseJSONList :: Value -> Parser [Ver] omittedField :: Maybe Ver | |
| ToJSON Ver Source # | |
Defined in Cabal.Plan | |
| Show Ver Source # | |
| Eq Ver Source # | |
| Ord Ver Source # | |
Equivalent to Cabal's Distribution.Package.PackageName
Constructors
| PkgName Text |
Instances
| FromJSON PkgName Source # | |
Defined in Cabal.Plan Methods parseJSON :: Value -> Parser PkgName parseJSONList :: Value -> Parser [PkgName] omittedField :: Maybe PkgName | |
| FromJSONKey PkgName Source # | |
Defined in Cabal.Plan | |
| ToJSON PkgName Source # | |
Defined in Cabal.Plan Methods toEncoding :: PkgName -> Encoding toJSONList :: [PkgName] -> Value toEncodingList :: [PkgName] -> Encoding | |
| ToJSONKey PkgName Source # | |
Defined in Cabal.Plan | |
| Show PkgName Source # | |
| Eq PkgName Source # | |
| Ord PkgName Source # | |
Equivalent to Cabal's Distribution.Package.PackageIdentifier
Instances
| FromJSON PkgId Source # | |
Defined in Cabal.Plan Methods parseJSON :: Value -> Parser PkgId parseJSONList :: Value -> Parser [PkgId] omittedField :: Maybe PkgId | |
| FromJSONKey PkgId Source # | |
Defined in Cabal.Plan | |
| ToJSON PkgId Source # | |
Defined in Cabal.Plan Methods toEncoding :: PkgId -> Encoding toJSONList :: [PkgId] -> Value toEncodingList :: [PkgId] -> Encoding | |
| ToJSONKey PkgId Source # | |
Defined in Cabal.Plan | |
| Show PkgId Source # | |
| Eq PkgId Source # | |
| Ord PkgId Source # | |
Equivalent to Cabal's Distribution.Package.UnitId
Constructors
| UnitId Text |
Instances
| FromJSON UnitId Source # | |
Defined in Cabal.Plan Methods parseJSON :: Value -> Parser UnitId parseJSONList :: Value -> Parser [UnitId] omittedField :: Maybe UnitId | |
| FromJSONKey UnitId Source # | |
Defined in Cabal.Plan | |
| ToJSON UnitId Source # | |
Defined in Cabal.Plan Methods toEncoding :: UnitId -> Encoding toJSONList :: [UnitId] -> Value toEncodingList :: [UnitId] -> Encoding | |
| ToJSONKey UnitId Source # | |
Defined in Cabal.Plan | |
| Show UnitId Source # | |
| Eq UnitId Source # | |
| Ord UnitId Source # | |
Equivalent to Cabal's Distribution.PackageDescription.FlagName
Since: 0.3.0.0
Constructors
| FlagName Text |
Instances
| FromJSON FlagName Source # | |
Defined in Cabal.Plan Methods parseJSON :: Value -> Parser FlagName parseJSONList :: Value -> Parser [FlagName] omittedField :: Maybe FlagName | |
| FromJSONKey FlagName Source # | |
Defined in Cabal.Plan | |
| ToJSON FlagName Source # | |
Defined in Cabal.Plan Methods toEncoding :: FlagName -> Encoding toJSONList :: [FlagName] -> Value toEncodingList :: [FlagName] -> Encoding | |
| ToJSONKey FlagName Source # | |
Defined in Cabal.Plan | |
| Show FlagName Source # | |
| Eq FlagName Source # | |
| Ord FlagName Source # | |
SHA-256
SHA-256 hash
Instances
| FromJSON Sha256 Source # | |
Defined in Cabal.Plan Methods parseJSON :: Value -> Parser Sha256 parseJSONList :: Value -> Parser [Sha256] omittedField :: Maybe Sha256 | |
| ToJSON Sha256 Source # | |
Defined in Cabal.Plan Methods toEncoding :: Sha256 -> Encoding toJSONList :: [Sha256] -> Value toEncodingList :: [Sha256] -> Encoding | |
| Show Sha256 Source # | |
| Eq Sha256 Source # | |
| Ord Sha256 Source # | |
dispSha256 :: Sha256 -> Text Source #
Pretty print Sha256 as base-16.
parseSha256 :: Text -> Maybe Sha256 Source #
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
Equivalent to Cabal's Distribution.Client.Types.PackageLocation
Since: 0.5.0.0
Constructors
| LocalUnpackedPackage !FilePath | |
| LocalTarballPackage !FilePath | |
| RemoteTarballPackage !URI | |
| RepoTarballPackage !Repo | |
| RemoteSourceRepoPackage !SourceRepo |
Equivalent to Cabal's Distribution.Types.SourceRepo
Since: 0.5.0.0
Constructors
| RepoLocal !FilePath | |
| RepoRemote !URI | |
| RepoSecure !URI | |
| RepoLocalNoIndex !FilePath |
data SourceRepo Source #
Equivalent to Cabal's Distribution.Client.Types.Repo
Since: 0.5.0.0
Constructors
| SourceRepo | |
Instances
| FromJSON SourceRepo Source # | |
Defined in Cabal.Plan Methods parseJSON :: Value -> Parser SourceRepo parseJSONList :: Value -> Parser [SourceRepo] omittedField :: Maybe SourceRepo | |
| Show SourceRepo Source # | |
Defined in Cabal.Plan Methods showsPrec :: Int -> SourceRepo -> ShowS show :: SourceRepo -> String showList :: [SourceRepo] -> ShowS | |
| Eq SourceRepo Source # | |
Defined in Cabal.Plan | |
| Ord SourceRepo Source # | |
Defined in Cabal.Plan Methods compare :: SourceRepo -> SourceRepo -> Ordering (<) :: SourceRepo -> SourceRepo -> Bool (<=) :: SourceRepo -> SourceRepo -> Bool (>) :: SourceRepo -> SourceRepo -> Bool (>=) :: SourceRepo -> SourceRepo -> Bool max :: SourceRepo -> SourceRepo -> SourceRepo min :: SourceRepo -> SourceRepo -> SourceRepo | |
Represents an URI (used e.g. by Repo)
Since: 0.5.0.0
Constructors
| URI Text |
Instances
| FromJSON URI Source # | |
Defined in Cabal.Plan Methods parseJSON :: Value -> Parser URI parseJSONList :: Value -> Parser [URI] omittedField :: Maybe URI | |
| FromJSONKey URI Source # | |
Defined in Cabal.Plan | |
| ToJSON URI Source # | |
Defined in Cabal.Plan | |
| ToJSONKey URI Source # | |
Defined in Cabal.Plan | |
| Show URI Source # | |
| Eq URI Source # | |
| Ord URI Source # | |
Equivalent to Cabal's Distribution.Client.SourceRepo.RepoType
Since: 0.5.0.0
Utilities
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. |
| ExactPath FilePath | Exact location of plan.json |
Instances
| Read SearchPlanJson Source # | |
Defined in Cabal.Plan Methods readsPrec :: Int -> ReadS SearchPlanJson readList :: ReadS [SearchPlanJson] readPrec :: ReadPrec SearchPlanJson readListPrec :: ReadPrec [SearchPlanJson] | |
| Show SearchPlanJson Source # | |
Defined in Cabal.Plan Methods showsPrec :: Int -> SearchPlanJson -> ShowS show :: SearchPlanJson -> String showList :: [SearchPlanJson] -> ShowS | |
| Eq SearchPlanJson Source # | |
Defined in Cabal.Plan Methods (==) :: SearchPlanJson -> SearchPlanJson -> Bool (/=) :: SearchPlanJson -> SearchPlanJson -> Bool | |
findAndDecodePlanJson :: SearchPlanJson -> IO PlanJson Source #
Find and decode plan.json.
See findPlanJson and decodePlanJson.
findPlanJson :: SearchPlanJson -> IO FilePath Source #
Find plan.json.
When ProjectRelativeToDir is passed 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.
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.
Since: 0.6.2.0
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.