CmdLineParser

ghc-8.6.3: The GHC API

Safe Haskell | None
Language | Haskell2010

CmdLineParser

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] -> m ([Located String], [Err], [Warn])
- 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 ())
  - | FloatSuffix (Float -> EwM m ())
  - | PassFlag (String -> EwM m ())
  - | AnySuffix (String -> EwM m ())
  - | PrefixPred (String -> Bool) (String -> EwM m ())
  - | AnySuffixPred (String -> Bool) (String -> EwM m ())
- data GhcFlagMode
  - = OnlyGhc
  - | OnlyGhci
  - | AllModes
  - | HiddenFlag
- newtype CmdLineP s a = CmdLineP {
  - runCmdLine :: s -> (a, s)
  }
- getCmdLineState :: CmdLineP s s
- putCmdLineState :: s -> CmdLineP s ()
- 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
- errorsToGhcException :: [(String, String)] -> GhcException
- newtype Err = Err {
  - errMsg :: Located String
  }
- data Warn = Warn {
  - warnReason :: WarnReason
  - 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 => WarnReason -> String -> EwM m ()
- getArg :: Monad m => EwM m String
- getCurLoc :: Monad m => EwM m SrcSpan
- liftEwM :: Monad m => m a -> EwM m a
- deprecate :: Monad m => String -> EwM m ()

# Documentation

processArgs :: Monad m => [Flag m] -> [Located String] -> m ([Located String], [Err], [Warn]) #

data OptKind m #

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 ()) |
FloatSuffix (Float -> EwM m ()) |
PassFlag (String -> EwM m ()) |
AnySuffix (String -> EwM m ()) |
PrefixPred (String -> Bool) (String -> EwM m ()) |
AnySuffixPred (String -> Bool) (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

newtype CmdLineP s a #

Constructors

CmdLineP |
Fields runCmdLine :: s -> (a, s)

Instances

Monad (CmdLineP s) # |
Instance details Defined in CmdLineParser Methods (>>=) :: CmdLineP s a -> (a -> CmdLineP s b) -> CmdLineP s b Source # (>>) :: CmdLineP s a -> CmdLineP s b -> CmdLineP s b Source # return :: a -> CmdLineP s a Source # fail :: String -> CmdLineP s a Source #
Functor (CmdLineP s) # |
Instance details Defined in CmdLineParser Methods fmap :: (a -> b) -> CmdLineP s a -> CmdLineP s b Source # (<$) :: a -> CmdLineP s b -> CmdLineP s a Source #
Applicative (CmdLineP s) # |
Instance details Defined in CmdLineParser Methods pure :: a -> CmdLineP s a Source # (<*>) :: CmdLineP s (a -> b) -> CmdLineP s a -> CmdLineP s b Source # liftA2 :: (a -> b -> c) -> CmdLineP s a -> CmdLineP s b -> CmdLineP s c Source # (*>) :: CmdLineP s a -> CmdLineP s b -> CmdLineP s b Source # (<*) :: CmdLineP s a -> CmdLineP s b -> CmdLineP s a Source #

getCmdLineState :: CmdLineP s s #

putCmdLineState :: s -> CmdLineP s () #

data Flag m #

Constructors

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

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

newtype Err #

A command-line error message

Constructors

Err |
Fields errMsg :: Located String

data Warn #

A command-line warning message and the reason it arose

Constructors

Warn |
Fields warnReason :: WarnReason warnMsg :: Located String

data WarnReason #

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

Constructors

NoReason |
ReasonDeprecatedFlag |
ReasonUnrecognisedFlag |

Instances

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

data EwM m a #

Instances

Monad m => Monad (EwM m) # |
Instance details Defined in CmdLineParser 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 # fail :: String -> EwM m a Source #
Monad m => Functor (EwM m) # |
Instance details Defined in CmdLineParser Methods fmap :: (a -> b) -> EwM m a -> EwM m b Source # (<$) :: a -> EwM m b -> EwM m a Source #
Monad m => Applicative (EwM m) # |
Instance details Defined in CmdLineParser 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 #

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

addErr :: Monad m => String -> EwM m () #

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

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

getArg :: Monad m => EwM m String #

getCurLoc :: Monad m => EwM m SrcSpan #

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

deprecate :: Monad m => String -> EwM m () #