fourmolu-0.17.0.0: A formatter for Haskell source code

Safe Haskell | None
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
  - ciModules :: ![ModuleName]
  }
- 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 #

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

data CabalInfo #

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

- ciModules :: ![ModuleName]

  Local modules

#### Instances

Instances details

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

data Extension #

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 #
Pretty Extension |
Instance details Defined in Language.Haskell.Extension Methods pretty :: Extension -> Doc # prettyVersioned :: CabalSpecVersion -> Extension -> Doc #
Structured Extension |
Instance details Defined in Language.Haskell.Extension Methods structure :: Proxy Extension -> Structure # structureHash' :: Tagged Extension MD5
Binary Extension |
Instance details Defined in Language.Haskell.Extension Methods put :: Extension -> Put # get :: Get Extension # putList :: [Extension] -> Put #
NFData Extension |
Instance details Defined in Language.Haskell.Extension Methods rnf :: Extension -> () #
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 #

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

toConstr :: Extension -> Constr #

dataTypeOf :: Extension -> DataType #

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

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

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

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

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

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

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

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

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

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

Generic Extension |

Instance details

Defined in Language.Haskell.Extension

Associated Types

type Rep Extension |

Instance details

Defined in Language.Haskell.Extension

type Rep Extension = D1 ('MetaData "Extension" "Language.Haskell.Extension" "Cabal-syntax-3.12.0.0-inplace" '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))))

Methods

from :: Extension -> Rep Extension x #

to :: Rep Extension x -> Extension #

Read Extension |
Instance details Defined in Language.Haskell.Extension Methods readsPrec :: Int -> ReadS Extension # readList :: ReadS [Extension] # readPrec :: ReadPrec Extension # readListPrec :: ReadPrec [Extension] #
Show Extension |
Instance details Defined in Language.Haskell.Extension Methods showsPrec :: Int -> Extension -> ShowS # show :: Extension -> String # showList :: [Extension] -> ShowS #
Eq Extension |
Instance details Defined in Language.Haskell.Extension Methods (==) :: Extension -> Extension -> Bool # (/=) :: Extension -> Extension -> Bool #
Ord Extension |
Instance details Defined in Language.Haskell.Extension Methods compare :: Extension -> Extension -> Ordering # (<) :: Extension -> Extension -> Bool # (<=) :: Extension -> Extension -> Bool # (>) :: Extension -> Extension -> Bool # (>=) :: Extension -> Extension -> Bool # max :: Extension -> Extension -> Extension # min :: Extension -> Extension -> Extension #
type Rep Extension |

Instance details

Defined in Language.Haskell.Extension

type Rep Extension = D1 ('MetaData "Extension" "Language.Haskell.Extension" "Cabal-syntax-3.12.0.0-inplace" '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 #

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 #

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 #

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`.