Cabal-syntax-3.12.1.0: A library for working with .cabal files

Safe Haskell | Safe-Inferred
Language | Haskell2010

Distribution.Pretty

Contents

- Utilities
- Deprecated

Synopsis

- class Pretty a where
  - pretty :: a -> Doc
  - prettyVersioned :: CabalSpecVersion -> a -> Doc
- prettyShow :: Pretty a => a -> String
- defaultStyle :: Style
- flatStyle :: Style
- showFilePath :: FilePath -> Doc
- showToken :: String -> Doc
- showTokenStr :: String -> String
- showFreeText :: String -> Doc
- showFreeTextV3 :: String -> Doc
- type Separator = [Doc] -> Doc

# Documentation

class Pretty a where Source #

Minimal complete definition

pretty

Methods

pretty :: a -> Doc Source #

prettyVersioned :: CabalSpecVersion -> a -> Doc Source #

#### Instances

Instances details

Pretty OpenModule Source # |
Instance details Defined in Distribution.Backpack Methods pretty :: OpenModule -> Doc Source # prettyVersioned :: CabalSpecVersion -> OpenModule -> Doc Source #
Pretty OpenUnitId Source # |
Instance details Defined in Distribution.Backpack Methods pretty :: OpenUnitId -> Doc Source # prettyVersioned :: CabalSpecVersion -> OpenUnitId -> Doc Source #
Pretty AbiTag Source # |
Instance details Defined in Distribution.Compiler Methods pretty :: AbiTag -> Doc Source # prettyVersioned :: CabalSpecVersion -> AbiTag -> Doc Source #
Pretty CompilerFlavor Source # |
Instance details Defined in Distribution.Compiler Methods pretty :: CompilerFlavor -> Doc Source # prettyVersioned :: CabalSpecVersion -> CompilerFlavor -> Doc Source #
Pretty CompilerId Source # |
Instance details Defined in Distribution.Compiler Methods pretty :: CompilerId -> Doc Source # prettyVersioned :: CabalSpecVersion -> CompilerId -> Doc Source #
Pretty FilePathNT Source # |
Instance details Defined in Distribution.FieldGrammar.Newtypes Methods pretty :: FilePathNT -> Doc Source # prettyVersioned :: CabalSpecVersion -> FilePathNT -> Doc Source #
Pretty SpecLicense Source # |
Instance details Defined in Distribution.FieldGrammar.Newtypes Methods pretty :: SpecLicense -> Doc Source # prettyVersioned :: CabalSpecVersion -> SpecLicense -> Doc Source #
Pretty SpecVersion Source # |
Instance details Defined in Distribution.FieldGrammar.Newtypes Methods pretty :: SpecVersion -> Doc Source # prettyVersioned :: CabalSpecVersion -> SpecVersion -> Doc Source #
Pretty TestedWith Source # |
Instance details Defined in Distribution.FieldGrammar.Newtypes Methods pretty :: TestedWith -> Doc Source # prettyVersioned :: CabalSpecVersion -> TestedWith -> Doc Source #
Pretty Token Source # |
Instance details Defined in Distribution.FieldGrammar.Newtypes Methods pretty :: Token -> Doc Source # prettyVersioned :: CabalSpecVersion -> Token -> Doc Source #
Pretty Token' Source # |
Instance details Defined in Distribution.FieldGrammar.Newtypes Methods pretty :: Token' -> Doc Source # prettyVersioned :: CabalSpecVersion -> Token' -> Doc Source #
Pretty License Source # |
Instance details Defined in Distribution.License Methods pretty :: License -> Doc Source # prettyVersioned :: CabalSpecVersion -> License -> Doc Source #
Pretty ModuleName Source # |
Instance details Defined in Distribution.ModuleName Methods pretty :: ModuleName -> Doc Source # prettyVersioned :: CabalSpecVersion -> ModuleName -> Doc Source #
Pretty CompatFilePath Source # |
Instance details Defined in Distribution.PackageDescription.FieldGrammar Methods pretty :: CompatFilePath -> Doc Source # prettyVersioned :: CabalSpecVersion -> CompatFilePath -> Doc Source #
Pretty CompatLicenseFile Source # |
Instance details Defined in Distribution.PackageDescription.FieldGrammar Methods pretty :: CompatLicenseFile -> Doc Source # prettyVersioned :: CabalSpecVersion -> CompatLicenseFile -> Doc Source #
Pretty License Source # |
Instance details Defined in Distribution.SPDX.License Methods pretty :: License -> Doc Source # prettyVersioned :: CabalSpecVersion -> License -> Doc Source #
Pretty LicenseExceptionId Source # |
Instance details Defined in Distribution.SPDX.LicenseExceptionId Methods pretty :: LicenseExceptionId -> Doc Source # prettyVersioned :: CabalSpecVersion -> LicenseExceptionId -> Doc Source #
Pretty LicenseExpression Source # |
Instance details Defined in Distribution.SPDX.LicenseExpression Methods pretty :: LicenseExpression -> Doc Source # prettyVersioned :: CabalSpecVersion -> LicenseExpression -> Doc Source #
Pretty SimpleLicenseExpression Source # |
Instance details Defined in Distribution.SPDX.LicenseExpression Methods pretty :: SimpleLicenseExpression -> Doc Source # prettyVersioned :: CabalSpecVersion -> SimpleLicenseExpression -> Doc Source #
Pretty LicenseId Source # |
Instance details Defined in Distribution.SPDX.LicenseId Methods pretty :: LicenseId -> Doc Source # prettyVersioned :: CabalSpecVersion -> LicenseId -> Doc Source #
Pretty LicenseRef Source # |
Instance details Defined in Distribution.SPDX.LicenseReference Methods pretty :: LicenseRef -> Doc Source # prettyVersioned :: CabalSpecVersion -> LicenseRef -> Doc Source #
Pretty Arch Source # |
Instance details Defined in Distribution.System Methods pretty :: Arch -> Doc Source # prettyVersioned :: CabalSpecVersion -> Arch -> Doc Source #
Pretty OS Source # |
Instance details Defined in Distribution.System Methods pretty :: OS -> Doc Source # prettyVersioned :: CabalSpecVersion -> OS -> Doc Source #
Pretty Platform Source # |
Instance details Defined in Distribution.System Methods pretty :: Platform -> Doc Source # prettyVersioned :: CabalSpecVersion -> Platform -> Doc Source #
Pretty AbiDependency Source # |
Instance details Defined in Distribution.Types.AbiDependency Methods pretty :: AbiDependency -> Doc Source # prettyVersioned :: CabalSpecVersion -> AbiDependency -> Doc Source #
Pretty AbiHash Source # |
Instance details Defined in Distribution.Types.AbiHash Methods pretty :: AbiHash -> Doc Source # prettyVersioned :: CabalSpecVersion -> AbiHash -> Doc Source #
Pretty BenchmarkType Source # |
Instance details Defined in Distribution.Types.BenchmarkType Methods pretty :: BenchmarkType -> Doc Source # prettyVersioned :: CabalSpecVersion -> BenchmarkType -> Doc Source #
Pretty BuildType Source # |
Instance details Defined in Distribution.Types.BuildType Methods pretty :: BuildType -> Doc Source # prettyVersioned :: CabalSpecVersion -> BuildType -> Doc Source #
Pretty ComponentId Source # |
Instance details Defined in Distribution.Types.ComponentId Methods pretty :: ComponentId -> Doc Source # prettyVersioned :: CabalSpecVersion -> ComponentId -> Doc Source #
Pretty ComponentName Source # |
Instance details Defined in Distribution.Types.ComponentName Methods pretty :: ComponentName -> Doc Source # prettyVersioned :: CabalSpecVersion -> ComponentName -> Doc Source #

Pretty Dependency Source #

    >>> prettyShow $ Dependency (mkPackageName "pkg") anyVersion mainLibSet
    "pkg"

    >>> prettyShow $ Dependency (mkPackageName "pkg") anyVersion $ NES.insert (LSubLibName $ mkUnqualComponentName "sublib") mainLibSet
    "pkg:{pkg, sublib}"

    >>> prettyShow $ Dependency (mkPackageName "pkg") anyVersion $ NES.singleton (LSubLibName $ mkUnqualComponentName "sublib")
    "pkg:sublib"

    >>> prettyShow $ Dependency (mkPackageName "pkg") anyVersion $ NES.insert (LSubLibName $ mkUnqualComponentName "sublib-b") $ NES.singleton (LSubLibName $ mkUnqualComponentName "sublib-a")
    "pkg:{sublib-a, sublib-b}"

Instance details Defined in Distribution.Types.Dependency Methods pretty :: Dependency -> Doc Source # prettyVersioned :: CabalSpecVersion -> Dependency -> Doc Source #
Pretty ExeDependency Source # |
Instance details Defined in Distribution.Types.ExeDependency Methods pretty :: ExeDependency -> Doc Source # prettyVersioned :: CabalSpecVersion -> ExeDependency -> Doc Source #
Pretty ExecutableScope Source # |
Instance details Defined in Distribution.Types.ExecutableScope Methods pretty :: ExecutableScope -> Doc Source # prettyVersioned :: CabalSpecVersion -> ExecutableScope -> Doc Source #
Pretty ExposedModule Source # |
Instance details Defined in Distribution.Types.ExposedModule Methods pretty :: ExposedModule -> Doc Source # prettyVersioned :: CabalSpecVersion -> ExposedModule -> Doc Source #
Pretty FlagAssignment Source # | Since: Cabal-syntax-3.4.0.0
Instance details Defined in Distribution.Types.Flag Methods pretty :: FlagAssignment -> Doc Source # prettyVersioned :: CabalSpecVersion -> FlagAssignment -> Doc Source #
Pretty FlagName Source # |
Instance details Defined in Distribution.Types.Flag Methods pretty :: FlagName -> Doc Source # prettyVersioned :: CabalSpecVersion -> FlagName -> Doc Source #
Pretty LibVersionInfo Source # |
Instance details Defined in Distribution.Types.ForeignLib Methods pretty :: LibVersionInfo -> Doc Source # prettyVersioned :: CabalSpecVersion -> LibVersionInfo -> Doc Source #
Pretty ForeignLibOption Source # |
Instance details Defined in Distribution.Types.ForeignLibOption Methods pretty :: ForeignLibOption -> Doc Source # prettyVersioned :: CabalSpecVersion -> ForeignLibOption -> Doc Source #
Pretty ForeignLibType Source # |
Instance details Defined in Distribution.Types.ForeignLibType Methods pretty :: ForeignLibType -> Doc Source # prettyVersioned :: CabalSpecVersion -> ForeignLibType -> Doc Source #
Pretty IncludeRenaming Source # |
Instance details Defined in Distribution.Types.IncludeRenaming Methods pretty :: IncludeRenaming -> Doc Source # prettyVersioned :: CabalSpecVersion -> IncludeRenaming -> Doc Source #
Pretty LegacyExeDependency Source # |
Instance details Defined in Distribution.Types.LegacyExeDependency Methods pretty :: LegacyExeDependency -> Doc Source # prettyVersioned :: CabalSpecVersion -> LegacyExeDependency -> Doc Source #
Pretty LibraryVisibility Source # |
Instance details Defined in Distribution.Types.LibraryVisibility Methods pretty :: LibraryVisibility -> Doc Source # prettyVersioned :: CabalSpecVersion -> LibraryVisibility -> Doc Source #
Pretty Mixin Source # |
Instance details Defined in Distribution.Types.Mixin Methods pretty :: Mixin -> Doc Source # prettyVersioned :: CabalSpecVersion -> Mixin -> Doc Source #
Pretty Module Source # |
Instance details Defined in Distribution.Types.Module Methods pretty :: Module -> Doc Source # prettyVersioned :: CabalSpecVersion -> Module -> Doc Source #
Pretty ModuleReexport Source # |
Instance details Defined in Distribution.Types.ModuleReexport Methods pretty :: ModuleReexport -> Doc Source # prettyVersioned :: CabalSpecVersion -> ModuleReexport -> Doc Source #
Pretty ModuleRenaming Source # |
Instance details Defined in Distribution.Types.ModuleRenaming Methods pretty :: ModuleRenaming -> Doc Source # prettyVersioned :: CabalSpecVersion -> ModuleRenaming -> Doc Source #

Pretty MungedPackageId Source #

    >>> prettyShow $ MungedPackageId (MungedPackageName "servant" LMainLibName) (mkVersion [1,2,3])
    "servant-1.2.3"

    >>> prettyShow $ MungedPackageId (MungedPackageName "servant" (LSubLibName "lackey")) (mkVersion [0,1,2])
    "z-servant-z-lackey-0.1.2"

Instance details Defined in Distribution.Types.MungedPackageId Methods pretty :: MungedPackageId -> Doc Source # prettyVersioned :: CabalSpecVersion -> MungedPackageId -> Doc Source #

Pretty MungedPackageName Source #

Computes the package name for a library. If this is the public library, it will just be the original package name; otherwise, it will be a munged package name recording the original package name as well as the name of the internal library.

A lot of tooling in the Haskell ecosystem assumes that if something is installed to the package database with the package name `foo`, then it actually is an entry for the (only public) library in package `foo`. With internal packages, this is not necessarily true: a public library as well as arbitrarily many internal libraries may come from the same package. To prevent tools from getting confused in this case, the package name of these internal libraries is munged so that they do not conflict the public library proper. A particular case where this matters is ghc-pkg: if we don't munge the package name, the inplace registration will OVERRIDE a different internal library.

We munge into a reserved namespace, "z-", and encode both the component name and the package name of an internal library using the following format:

compat-pkg-name ::= "z-" package-name "-z-" library-name

where package-name and library-name have "-" ( "z" + ) "-" segments encoded by adding an extra "z".

When we have the public library, the compat-pkg-name is just the package-name, no surprises there!

    >>> prettyShow $ MungedPackageName "servant" LMainLibName
    "servant"

    >>> prettyShow $ MungedPackageName "servant" (LSubLibName "lackey")
    "z-servant-z-lackey"

Instance details Defined in Distribution.Types.MungedPackageName Methods pretty :: MungedPackageName -> Doc Source # prettyVersioned :: CabalSpecVersion -> MungedPackageName -> Doc Source #
Pretty PackageIdentifier Source # |
Instance details Defined in Distribution.Types.PackageId Methods pretty :: PackageIdentifier -> Doc Source # prettyVersioned :: CabalSpecVersion -> PackageIdentifier -> Doc Source #
Pretty PackageName Source # |
Instance details Defined in Distribution.Types.PackageName Methods pretty :: PackageName -> Doc Source # prettyVersioned :: CabalSpecVersion -> PackageName -> Doc Source #
Pretty PackageVersionConstraint Source # |
Instance details Defined in Distribution.Types.PackageVersionConstraint Methods pretty :: PackageVersionConstraint -> Doc Source # prettyVersioned :: CabalSpecVersion -> PackageVersionConstraint -> Doc Source #
Pretty PkgconfigDependency Source # |
Instance details Defined in Distribution.Types.PkgconfigDependency Methods pretty :: PkgconfigDependency -> Doc Source # prettyVersioned :: CabalSpecVersion -> PkgconfigDependency -> Doc Source #
Pretty PkgconfigName Source # |
Instance details Defined in Distribution.Types.PkgconfigName Methods pretty :: PkgconfigName -> Doc Source # prettyVersioned :: CabalSpecVersion -> PkgconfigName -> Doc Source #
Pretty PkgconfigVersion Source # |
Instance details Defined in Distribution.Types.PkgconfigVersion Methods pretty :: PkgconfigVersion -> Doc Source # prettyVersioned :: CabalSpecVersion -> PkgconfigVersion -> Doc Source #
Pretty PkgconfigVersionRange Source # |
Instance details Defined in Distribution.Types.PkgconfigVersionRange Methods pretty :: PkgconfigVersionRange -> Doc Source # prettyVersioned :: CabalSpecVersion -> PkgconfigVersionRange -> Doc Source #
Pretty KnownRepoType Source # |
Instance details Defined in Distribution.Types.SourceRepo Methods pretty :: KnownRepoType -> Doc Source # prettyVersioned :: CabalSpecVersion -> KnownRepoType -> Doc Source #
Pretty RepoKind Source # |
Instance details Defined in Distribution.Types.SourceRepo Methods pretty :: RepoKind -> Doc Source # prettyVersioned :: CabalSpecVersion -> RepoKind -> Doc Source #
Pretty RepoType Source # |
Instance details Defined in Distribution.Types.SourceRepo Methods pretty :: RepoType -> Doc Source # prettyVersioned :: CabalSpecVersion -> RepoType -> Doc Source #
Pretty TestType Source # |
Instance details Defined in Distribution.Types.TestType Methods pretty :: TestType -> Doc Source # prettyVersioned :: CabalSpecVersion -> TestType -> Doc Source #
Pretty DefUnitId Source # |
Instance details Defined in Distribution.Types.UnitId Methods pretty :: DefUnitId -> Doc Source # prettyVersioned :: CabalSpecVersion -> DefUnitId -> Doc Source #
Pretty UnitId Source # | The textual format for `UnitId` coincides with the format GHC accepts for `-package-id`.
Instance details Defined in Distribution.Types.UnitId Methods pretty :: UnitId -> Doc Source # prettyVersioned :: CabalSpecVersion -> UnitId -> Doc Source #
Pretty UnqualComponentName Source # |
Instance details Defined in Distribution.Types.UnqualComponentName Methods pretty :: UnqualComponentName -> Doc Source # prettyVersioned :: CabalSpecVersion -> UnqualComponentName -> Doc Source #
Pretty Version Source # |
Instance details Defined in Distribution.Types.Version Methods pretty :: Version -> Doc Source # prettyVersioned :: CabalSpecVersion -> Version -> Doc Source #

Pretty VersionRange Source #

    >>> fmap pretty (simpleParsec' CabalSpecV1_6 "== 3.2.*" :: Maybe VersionRange)
    Just >=3.2 && <3.3

    >>> fmap (prettyVersioned CabalSpecV1_6) (simpleParsec' CabalSpecV1_6 "== 3.2.*" :: Maybe VersionRange)
    Just ==3.2.*

    >>> fmap pretty (simpleParsec' CabalSpecV1_6 "-any" :: Maybe VersionRange)
    Just >=0

    >>> fmap (prettyVersioned CabalSpecV1_6) (simpleParsec' CabalSpecV1_6 "-any" :: Maybe VersionRange)
    Just >=0

Instance details Defined in Distribution.Types.VersionRange.Internal Methods pretty :: VersionRange -> Doc Source # prettyVersioned :: CabalSpecVersion -> VersionRange -> Doc Source #
Pretty Extension Source # |
Instance details Defined in Language.Haskell.Extension Methods pretty :: Extension -> Doc Source # prettyVersioned :: CabalSpecVersion -> Extension -> Doc Source #
Pretty KnownExtension Source # |
Instance details Defined in Language.Haskell.Extension Methods pretty :: KnownExtension -> Doc Source # prettyVersioned :: CabalSpecVersion -> KnownExtension -> Doc Source #
Pretty Language Source # |
Instance details Defined in Language.Haskell.Extension Methods pretty :: Language -> Doc Source # prettyVersioned :: CabalSpecVersion -> Language -> Doc Source #
Pretty Doc Source # | Since: Cabal-syntax-3.4.0.0
Instance details Defined in Distribution.Pretty Methods pretty :: Doc -> Doc Source # prettyVersioned :: CabalSpecVersion -> Doc -> Doc Source #
Pretty Bool Source # |
Instance details Defined in Distribution.Pretty Methods pretty :: Bool -> Doc Source # prettyVersioned :: CabalSpecVersion -> Bool -> Doc Source #
Pretty Int Source # |
Instance details Defined in Distribution.Pretty Methods pretty :: Int -> Doc Source # prettyVersioned :: CabalSpecVersion -> Int -> Doc Source #
Pretty a => Pretty (MQuoted a) Source # |
Instance details Defined in Distribution.FieldGrammar.Newtypes Methods pretty :: MQuoted a -> Doc Source # prettyVersioned :: CabalSpecVersion -> MQuoted a -> Doc Source #
Pretty a => Pretty (Identity a) Source # |
Instance details Defined in Distribution.Pretty Methods pretty :: Identity a -> Doc Source # prettyVersioned :: CabalSpecVersion -> Identity a -> Doc Source #
Pretty (SymbolicPath from to) Source # |
Instance details Defined in Distribution.Utils.Path Methods pretty :: SymbolicPath from to -> Doc Source # prettyVersioned :: CabalSpecVersion -> SymbolicPath from to -> Doc Source #
(Newtype a b, Sep sep, Pretty b) => Pretty (List sep b a) Source # |
Instance details Defined in Distribution.FieldGrammar.Newtypes Methods pretty :: List sep b a -> Doc Source # prettyVersioned :: CabalSpecVersion -> List sep b a -> Doc Source #
(Newtype a b, Sep sep, Pretty b) => Pretty (NonEmpty' sep b a) Source # |
Instance details Defined in Distribution.FieldGrammar.Newtypes Methods pretty :: NonEmpty' sep b a -> Doc Source # prettyVersioned :: CabalSpecVersion -> NonEmpty' sep b a -> Doc Source #
(Newtype a b, Sep sep, Pretty b) => Pretty (Set' sep b a) Source # |
Instance details Defined in Distribution.FieldGrammar.Newtypes Methods pretty :: Set' sep b a -> Doc Source # prettyVersioned :: CabalSpecVersion -> Set' sep b a -> Doc Source #

prettyShow :: Pretty a => a -> String Source #

defaultStyle :: Style Source #

The default rendering style used in Cabal for console output. It has a fixed page width and adds line breaks automatically.

flatStyle :: Style Source #

A style for rendering all on one line.

# Utilities

showFilePath :: FilePath -> Doc Source #

showToken :: String -> Doc Source #

showTokenStr :: String -> String Source #

showFreeText :: String -> Doc Source #

Pretty-print free-format text, ensuring that it is vertically aligned, and with blank lines replaced by dots for correct re-parsing.

showFreeTextV3 :: String -> Doc Source #

Pretty-print free-format text. Since `cabal-version: 3.0` we don't replace blank lines with dots.

Since: Cabal-syntax-3.0.0.0

# Deprecated

type Separator = [Doc] -> Doc Source #