ghc-lib-parser-9.10.1.20250103: 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 #

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] #

Parse a response file into arguments.

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

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 #

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) #

Constructors

Flag |

Fields

- 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 #

A command-line error message

Constructors

Err |

Fields

- errMsg :: Located String

type Warn = Located DriverMessage #

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 #

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

#### Instances

Instances details

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