ormolu-0.7.2.0: A formatter for Haskell source code

Safe Haskell | Safe-Inferred
Language | GHC2021

Ormolu.Utils.Cabal

Synopsis

- data CabalSearchResult
  - = CabalNotFound
  - | CabalDidNotMention CabalInfo
  - | CabalFound CabalInfo
- data CabalInfo = CabalInfo {
  - ciPackageName :: !PackageName
  - ciDynOpts :: ![DynOption]
  - ciDependencies :: !(Set PackageName)
  - ciCabalFilePath :: !FilePath
  }
- data Extension
  - = EnableExtension KnownExtension
  - | DisableExtension KnownExtension
  - | UnknownExtension String
- getCabalInfoForSourceFile :: MonadIO m => FilePath -> m CabalSearchResult
- findCabalFile :: MonadIO m => FilePath -> m (Maybe FilePath)
- parseCabalInfo :: MonadIO m => FilePath -> FilePath -> m (Bool, CabalInfo)

# Documentation

data CabalSearchResult Source #

The result of searching for a `.cabal` file.

Since: 0.5.3.0

Constructors

CabalNotFound | Cabal file could not be found
CabalDidNotMention CabalInfo | Cabal file was found, but it did not mention the source file in question
CabalFound CabalInfo | Cabal file was found and it mentions the source file in question

#### Instances

Instances details

Show CabalSearchResult Source # |
Instance details Defined in Ormolu.Utils.Cabal Methods showsPrec :: Int -> CabalSearchResult -> ShowS Source # show :: CabalSearchResult -> String Source # showList :: [CabalSearchResult] -> ShowS Source #
Eq CabalSearchResult Source # |
Instance details Defined in Ormolu.Utils.Cabal Methods (==) :: CabalSearchResult -> CabalSearchResult -> Bool Source # (/=) :: CabalSearchResult -> CabalSearchResult -> Bool Source #

data CabalInfo Source #

Cabal information of interest to Ormolu.

Constructors

CabalInfo |

Fields

- ciPackageName :: !PackageName

  Package name

- ciDynOpts :: ![DynOption]

  Extension and language settings in the form of `DynOption`s

- ciDependencies :: !(Set PackageName)

  Direct dependencies

- ciCabalFilePath :: !FilePath

  Absolute path to the cabal file

#### Instances

Instances details

Show CabalInfo Source # |
Instance details Defined in Ormolu.Utils.Cabal Methods showsPrec :: Int -> CabalInfo -> ShowS Source # show :: CabalInfo -> String Source # showList :: [CabalInfo] -> ShowS Source #
Eq CabalInfo Source # |
Instance details Defined in Ormolu.Utils.Cabal Methods (==) :: CabalInfo -> CabalInfo -> Bool Source # (/=) :: CabalInfo -> CabalInfo -> Bool Source #

data Extension Source #

This represents language extensions beyond a base `Language` definition (such as `Haskell98`) that are supported by some implementations, usually in some special mode.

Where applicable, references are given to an implementation's official documentation.

Constructors

EnableExtension KnownExtension | Enable a known extension
DisableExtension KnownExtension | Disable a known extension
UnknownExtension String | An unknown extension, identified by the name of its `LANGUAGE` pragma.

#### Instances

Instances details

Parsec Extension |
Instance details Defined in Language.Haskell.Extension Methods parsec :: CabalParsing m => m Extension Source #
Pretty Extension |
Instance details Defined in Language.Haskell.Extension Methods pretty :: Extension -> Doc Source # prettyVersioned :: CabalSpecVersion -> Extension -> Doc Source #
Structured Extension |
Instance details Defined in Language.Haskell.Extension Methods structure :: Proxy Extension -> Structure Source # structureHash' :: Tagged Extension MD5
Data Extension |

Instance details

Defined in Language.Haskell.Extension

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Extension -> c Extension Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Extension Source #

toConstr :: Extension -> Constr Source #

dataTypeOf :: Extension -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Extension) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Extension) Source #

gmapT :: (forall b. Data b => b -> b) -> Extension -> Extension Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Extension -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Extension -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Extension -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Extension -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Extension -> m Extension Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Extension -> m Extension Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Extension -> m Extension Source #

Generic Extension |
Instance details Defined in Language.Haskell.Extension Associated Types type Rep Extension :: Type -> Type Source # Methods from :: Extension -> Rep Extension x Source # to :: Rep Extension x -> Extension Source #
Read Extension |
Instance details Defined in Language.Haskell.Extension Methods readsPrec :: Int -> ReadS Extension Source # readList :: ReadS [Extension] Source # readPrec :: ReadPrec Extension Source # readListPrec :: ReadPrec [Extension] Source #
Show Extension |
Instance details Defined in Language.Haskell.Extension Methods showsPrec :: Int -> Extension -> ShowS Source # show :: Extension -> String Source # showList :: [Extension] -> ShowS Source #
Binary Extension |
Instance details Defined in Language.Haskell.Extension Methods put :: Extension -> Put Source # get :: Get Extension Source # putList :: [Extension] -> Put Source #
NFData Extension |
Instance details Defined in Language.Haskell.Extension Methods rnf :: Extension -> () Source #
Eq Extension |
Instance details Defined in Language.Haskell.Extension Methods (==) :: Extension -> Extension -> Bool Source # (/=) :: Extension -> Extension -> Bool Source #
Ord Extension |

Instance details

Defined in Language.Haskell.Extension

Methods

compare :: Extension -> Extension -> Ordering Source #

(<) :: Extension -> Extension -> Bool Source #

(<=) :: Extension -> Extension -> Bool Source #

(>) :: Extension -> Extension -> Bool Source #

(>=) :: Extension -> Extension -> Bool Source #

max :: Extension -> Extension -> Extension Source #

min :: Extension -> Extension -> Extension Source #

type Rep Extension |

Instance details

Defined in Language.Haskell.Extension

type Rep Extension = D1 ('MetaData "Extension" "Language.Haskell.Extension" "Cabal-syntax-3.10.3.0" 'False) (C1 ('MetaCons "EnableExtension" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 KnownExtension)) :+: (C1 ('MetaCons "DisableExtension" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 KnownExtension)) :+: C1 ('MetaCons "UnknownExtension" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))))

getCabalInfoForSourceFile Source #

Arguments

:: MonadIO m |
=> FilePath | Haskell source file
-> m CabalSearchResult | Extracted cabal info, if any

Locate a `.cabal` file corresponding to the given Haskell source file and obtain `CabalInfo` from it.

findCabalFile Source #

Arguments

:: MonadIO m |
=> FilePath | Path to a Haskell source file in a project with a `.cabal` file
-> m (Maybe FilePath) | Absolute path to the `.cabal` file, if available

Find the path to an appropriate `.cabal` file for a Haskell source file, if available.

parseCabalInfo Source #

Arguments

:: MonadIO m |
=> FilePath | Location of the .cabal file
-> FilePath | Location of the source file we are formatting
-> m (Bool, CabalInfo) | Indication if the source file was mentioned in the Cabal file and the extracted `CabalInfo`

Parse `CabalInfo` from a `.cabal` file at the given `FilePath`.