ghc-lib-parser-9.12.2.20250421: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Driver.CmdLine

Description

Command-line parser

This is an abstract command-line parser used by DynFlags.

(c) The University of Glasgow 2005

Synopsis

- processArgs :: Monad m => [Flag m] -> [Located String] -> (FilePath -> EwM m [Located String]) -> m ([Located String], [Err], Warns)
- parseResponseFile :: forall (m :: Type -> Type). MonadIO m => FilePath -> EwM m [Located String]
- data OptKind (m :: Type -> Type)
  - = NoArg (EwM m ())
  - | HasArg (String -> EwM m ())
  - | SepArg (String -> EwM m ())
  - | Prefix (String -> EwM m ())
  - | OptPrefix (String -> EwM m ())
  - | OptIntSuffix (Maybe Int -> EwM m ())
  - | IntSuffix (Int -> EwM m ())
  - | Word64Suffix (Word64 -> EwM m ())
  - | FloatSuffix (Float -> EwM m ())
  - | PassFlag (String -> EwM m ())
  - | AnySuffix (String -> EwM m ())
- data GhcFlagMode
  - = OnlyGhc
  - | OnlyGhci
  - | AllModes
  - | HiddenFlag
- data Flag (m :: Type -> Type) = Flag {
  - flagName :: String
  - flagOptKind :: OptKind m
  - flagGhcMode :: GhcFlagMode
  }
- defFlag :: forall (m :: Type -> Type). String -> OptKind m -> Flag m
- defGhcFlag :: forall (m :: Type -> Type). String -> OptKind m -> Flag m
- defGhciFlag :: forall (m :: Type -> Type). String -> OptKind m -> Flag m
- defHiddenFlag :: forall (m :: Type -> Type). String -> OptKind m -> Flag m
- hoistFlag :: (forall a. m a -> n a) -> Flag m -> Flag n
- errorsToGhcException :: [(String, String)] -> GhcException
- newtype Err = Err {
  - errMsg :: Located String
  }
- type Warn = Located DriverMessage
- warnsToMessages :: DiagOpts -> [Warn] -> Messages DriverMessage
- data EwM (m :: Type -> Type) a
- runEwM :: EwM m a -> m (Errs, Warns, a)
- addErr :: forall (m :: Type -> Type). Monad m => String -> EwM m ()
- addWarn :: forall (m :: Type -> Type). Monad m => String -> EwM m ()
- addFlagWarn :: forall (m :: Type -> Type). Monad m => DriverMessage -> EwM m ()
- getArg :: forall (m :: Type -> Type). Monad m => EwM m String
- getCurLoc :: forall (m :: Type -> Type). Monad m => EwM m SrcSpan
- liftEwM :: Monad m => m a -> EwM m a

# Documentation

processArgs Source #

Arguments

:: Monad m |
=> [Flag m] | cmdline parser spec
-> [Located String] | args
-> (FilePath -> EwM m [Located String]) | response file handler
-> m ([Located String], [Err], Warns) |

parseResponseFile :: forall (m :: Type -> Type). MonadIO m => FilePath -> EwM m [Located String] Source #

Parse a response file into arguments.

data OptKind (m :: Type -> Type) Source #

Constructors

NoArg (EwM m ()) |
HasArg (String -> EwM m ()) |
SepArg (String -> EwM m ()) |
Prefix (String -> EwM m ()) |
OptPrefix (String -> EwM m ()) |
OptIntSuffix (Maybe Int -> EwM m ()) |
IntSuffix (Int -> EwM m ()) |
Word64Suffix (Word64 -> EwM m ()) |
FloatSuffix (Float -> EwM m ()) |
PassFlag (String -> EwM m ()) |
AnySuffix (String -> EwM m ()) |

data GhcFlagMode Source #

GHC flag modes describing when a flag has an effect.

Constructors

OnlyGhc | The flag only affects the non-interactive GHC
OnlyGhci | The flag only affects the interactive GHC
AllModes | The flag affects multiple ghc modes
HiddenFlag | This flag should not be seen in cli completion

data Flag (m :: Type -> Type) Source #

Constructors

Flag |

Fields

- flagName :: String
- flagOptKind :: OptKind m
- flagGhcMode :: GhcFlagMode

defFlag :: forall (m :: Type -> Type). String -> OptKind m -> Flag m Source #

defGhcFlag :: forall (m :: Type -> Type). String -> OptKind m -> Flag m Source #

defGhciFlag :: forall (m :: Type -> Type). String -> OptKind m -> Flag m Source #

defHiddenFlag :: forall (m :: Type -> Type). String -> OptKind m -> Flag m Source #

hoistFlag :: (forall a. m a -> n a) -> Flag m -> Flag n Source #

errorsToGhcException :: [(String, String)] -> GhcException Source #

newtype Err Source #

A command-line error message

Constructors

Err |

Fields

- errMsg :: Located String

type Warn = Located DriverMessage Source #

A command-line warning message and the reason it arose

This used to be own type, but now it's just ``MsgEnvelope` `DriverMessage``.

warnsToMessages :: DiagOpts -> [Warn] -> Messages DriverMessage Source #

data EwM (m :: Type -> Type) a Source #

#### Instances

Instances details

MonadIO m => MonadIO (EwM m) Source # |
Instance details Defined in GHC.Driver.CmdLine Methods liftIO :: IO a -> EwM m a Source #
Monad m => Applicative (EwM m) Source # |
Instance details Defined in GHC.Driver.CmdLine Methods pure :: a -> EwM m a Source # (<*>) :: EwM m (a -> b) -> EwM m a -> EwM m b Source # liftA2 :: (a -> b -> c) -> EwM m a -> EwM m b -> EwM m c Source # (*>) :: EwM m a -> EwM m b -> EwM m b Source # (<*) :: EwM m a -> EwM m b -> EwM m a Source #
Functor m => Functor (EwM m) Source # |
Instance details Defined in GHC.Driver.CmdLine Methods fmap :: (a -> b) -> EwM m a -> EwM m b Source # (<$) :: a -> EwM m b -> EwM m a Source #
Monad m => Monad (EwM m) Source # |
Instance details Defined in GHC.Driver.CmdLine Methods (>>=) :: EwM m a -> (a -> EwM m b) -> EwM m b Source # (>>) :: EwM m a -> EwM m b -> EwM m b Source # return :: a -> EwM m a Source #

runEwM :: EwM m a -> m (Errs, Warns, a) Source #

addErr :: forall (m :: Type -> Type). Monad m => String -> EwM m () Source #

addWarn :: forall (m :: Type -> Type). Monad m => String -> EwM m () Source #

addFlagWarn :: forall (m :: Type -> Type). Monad m => DriverMessage -> EwM m () Source #

getArg :: forall (m :: Type -> Type). Monad m => EwM m String Source #

getCurLoc :: forall (m :: Type -> Type). Monad m => EwM m SrcSpan Source #

liftEwM :: Monad m => m a -> EwM m a Source #