ghc-9.6.3: The GHC API

Safe Haskell | Safe-Inferred
Language | Haskell2010

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], [Warn])
- parseResponseFile :: MonadIO m => FilePath -> EwM m [Located String]
- data OptKind m
  - = 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 ())
  - | WordSuffix (Word -> EwM m ())
  - | FloatSuffix (Float -> EwM m ())
  - | PassFlag (String -> EwM m ())
  - | AnySuffix (String -> EwM m ())
- data GhcFlagMode
  - = OnlyGhc
  - | OnlyGhci
  - | AllModes
  - | HiddenFlag
- data Flag m = Flag {
  - flagName :: String
  - flagOptKind :: OptKind m
  - flagGhcMode :: GhcFlagMode
  }
- defFlag :: String -> OptKind m -> Flag m
- defGhcFlag :: String -> OptKind m -> Flag m
- defGhciFlag :: String -> OptKind m -> Flag m
- defHiddenFlag :: String -> OptKind m -> Flag m
- hoistFlag :: forall m n. (forall a. m a -> n a) -> Flag m -> Flag n
- errorsToGhcException :: [(String, String)] -> GhcException
- newtype Err = Err {
  - errMsg :: Located String
  }
- data Warn = Warn {
  - warnReason :: DiagnosticReason
  - warnMsg :: Located String
  }
- data WarnReason
  - = NoReason
  - | ReasonDeprecatedFlag
  - | ReasonUnrecognisedFlag
- data EwM m a
- runEwM :: EwM m a -> m (Errs, Warns, a)
- addErr :: Monad m => String -> EwM m ()
- addWarn :: Monad m => String -> EwM m ()
- addFlagWarn :: Monad m => DiagnosticReason -> String -> EwM m ()
- getArg :: Monad m => EwM m String
- getCurLoc :: 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], [Warn]) |

parseResponseFile :: MonadIO m => FilePath -> EwM m [Located String] Source #

Parse a response file into arguments.

data OptKind m 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 ()) |
WordSuffix (Word -> 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 Source #

Constructors

Flag |

Fields

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

defFlag :: String -> OptKind m -> Flag m Source #

defGhcFlag :: String -> OptKind m -> Flag m Source #

defGhciFlag :: String -> OptKind m -> Flag m Source #

defHiddenFlag :: String -> OptKind m -> Flag m Source #

hoistFlag :: forall m n. (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

data Warn Source #

A command-line warning message and the reason it arose

Constructors

Warn |

Fields

- warnReason :: DiagnosticReason
- warnMsg :: Located String

data WarnReason Source #

Used when filtering warnings: if a reason is given it can be filtered out when displaying.

Constructors

NoReason |
ReasonDeprecatedFlag |
ReasonUnrecognisedFlag |

#### Instances

Instances details

Show WarnReason Source # |
Instance details Defined in GHC.Driver.CmdLine Methods showsPrec :: Int -> WarnReason -> ShowS Source # show :: WarnReason -> String Source # showList :: [WarnReason] -> ShowS Source #
ToJson WarnReason Source # |
Instance details Defined in GHC.Driver.CmdLine Methods json :: WarnReason -> JsonDoc Source #
Outputable WarnReason Source # |
Instance details Defined in GHC.Driver.CmdLine Methods ppr :: WarnReason -> SDoc Source #
Eq WarnReason Source # |
Instance details Defined in GHC.Driver.CmdLine Methods (==) :: WarnReason -> WarnReason -> Bool # (/=) :: WarnReason -> WarnReason -> Bool #

data EwM m 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 :: Monad m => String -> EwM m () Source #

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

addFlagWarn :: Monad m => DiagnosticReason -> String -> EwM m () Source #

getArg :: Monad m => EwM m String Source #

getCurLoc :: Monad m => EwM m SrcSpan Source #

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