{-# LANGUAGE TemplateHaskell #-} module Options (Options(..), OutputForm(..), Package(), Packages(Packages), parseCommandLine, setPackages) where import Constants (hlDesc, noPackagesError) import Control.Lens.Combinators (makeLenses, makePrisms) import Data.Default (Default(def)) import Data.List (isPrefixOf) import Data.Maybe (fromMaybe) import Data.Set (Set(), fromList) import Data.Text (Text()) import Data.Version (showVersion) import Options.Applicative ((<**>), Parser, ParserResult(Success, Failure, CompletionInvoked), argument, command, defaultPrefs, execParserPure, fullDesc, header, help, helper, hidden, info, long, metavar, option, optional, progDesc, short, simpleVersioner, some, str, strOption, switch) import Paths_shellify (version) data OutputForm = Traditional | Flake deriving (OutputForm -> OutputForm -> Bool (OutputForm -> OutputForm -> Bool) -> (OutputForm -> OutputForm -> Bool) -> Eq OutputForm forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: OutputForm -> OutputForm -> Bool == :: OutputForm -> OutputForm -> Bool $c/= :: OutputForm -> OutputForm -> Bool /= :: OutputForm -> OutputForm -> Bool Eq, Int -> OutputForm -> ShowS [OutputForm] -> ShowS OutputForm -> String (Int -> OutputForm -> ShowS) -> (OutputForm -> String) -> ([OutputForm] -> ShowS) -> Show OutputForm forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> OutputForm -> ShowS showsPrec :: Int -> OutputForm -> ShowS $cshow :: OutputForm -> String show :: OutputForm -> String $cshowList :: [OutputForm] -> ShowS showList :: [OutputForm] -> ShowS Show) newtype Packages = Packages (Set Package) deriving (Packages -> Packages -> Bool (Packages -> Packages -> Bool) -> (Packages -> Packages -> Bool) -> Eq Packages forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: Packages -> Packages -> Bool == :: Packages -> Packages -> Bool $c/= :: Packages -> Packages -> Bool /= :: Packages -> Packages -> Bool Eq, Semigroup Packages Packages Semigroup Packages => Packages -> (Packages -> Packages -> Packages) -> ([Packages] -> Packages) -> Monoid Packages [Packages] -> Packages Packages -> Packages -> Packages forall a. Semigroup a => a -> (a -> a -> a) -> ([a] -> a) -> Monoid a $cmempty :: Packages mempty :: Packages $cmappend :: Packages -> Packages -> Packages mappend :: Packages -> Packages -> Packages $cmconcat :: [Packages] -> Packages mconcat :: [Packages] -> Packages Monoid, NonEmpty Packages -> Packages Packages -> Packages -> Packages (Packages -> Packages -> Packages) -> (NonEmpty Packages -> Packages) -> (forall b. Integral b => b -> Packages -> Packages) -> Semigroup Packages forall b. Integral b => b -> Packages -> Packages forall a. (a -> a -> a) -> (NonEmpty a -> a) -> (forall b. Integral b => b -> a -> a) -> Semigroup a $c<> :: Packages -> Packages -> Packages <> :: Packages -> Packages -> Packages $csconcat :: NonEmpty Packages -> Packages sconcat :: NonEmpty Packages -> Packages $cstimes :: forall b. Integral b => b -> Packages -> Packages stimes :: forall b. Integral b => b -> Packages -> Packages Semigroup, Int -> Packages -> ShowS [Packages] -> ShowS Packages -> String (Int -> Packages -> ShowS) -> (Packages -> String) -> ([Packages] -> ShowS) -> Show Packages forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> Packages -> ShowS showsPrec :: Int -> Packages -> ShowS $cshow :: Packages -> String show :: Packages -> String $cshowList :: [Packages] -> ShowS showList :: [Packages] -> ShowS Show) type Package = Text makePrisms ''Packages setPackages :: [Text] -> Packages setPackages = Set Text -> Packages Packages (Set Text -> Packages) -> ([Text] -> Set Text) -> [Text] -> Packages forall b c a. (b -> c) -> (a -> b) -> a -> c . [Text] -> Set Text forall a. Ord a => [a] -> Set a fromList opts :: ParserInfo CommandLineOptions opts = Parser CommandLineOptions -> InfoMod CommandLineOptions -> ParserInfo CommandLineOptions forall a. Parser a -> InfoMod a -> ParserInfo a info (Parser CommandLineOptions commandParser Parser CommandLineOptions -> Parser (CommandLineOptions -> CommandLineOptions) -> Parser CommandLineOptions forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b <**> String -> Parser (CommandLineOptions -> CommandLineOptions) forall a. String -> Parser (a -> a) simpleVersioner (Version -> String showVersion Version version) Parser CommandLineOptions -> Parser (CommandLineOptions -> CommandLineOptions) -> Parser CommandLineOptions forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b <**> Parser (CommandLineOptions -> CommandLineOptions) forall a. Parser (a -> a) helper) (InfoMod CommandLineOptions -> ParserInfo CommandLineOptions) -> InfoMod CommandLineOptions -> ParserInfo CommandLineOptions forall a b. (a -> b) -> a -> b $ InfoMod CommandLineOptions forall a. InfoMod a fullDesc InfoMod CommandLineOptions -> InfoMod CommandLineOptions -> InfoMod CommandLineOptions forall a. Semigroup a => a -> a -> a <> String -> InfoMod CommandLineOptions forall a. String -> InfoMod a progDesc String hlDesc InfoMod CommandLineOptions -> InfoMod CommandLineOptions -> InfoMod CommandLineOptions forall a. Semigroup a => a -> a -> a <> String -> InfoMod CommandLineOptions forall a. String -> InfoMod a header String "Quickly generate shell.nix files once you have a working shell" commandParser :: Parser CommandLineOptions commandParser :: Parser CommandLineOptions commandParser = Maybe [Text] -> Maybe Text -> Bool -> Bool -> Maybe [String] -> Maybe [Text] -> CommandLineOptions CommandLineOptions (Maybe [Text] -> Maybe Text -> Bool -> Bool -> Maybe [String] -> Maybe [Text] -> CommandLineOptions) -> Parser (Maybe [Text]) -> Parser (Maybe Text -> Bool -> Bool -> Maybe [String] -> Maybe [Text] -> CommandLineOptions) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser [Text] -> Parser (Maybe [Text]) forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a) optional (Parser Text -> Parser [Text] forall a. Parser a -> Parser [a] forall (f :: * -> *) a. Alternative f => f a -> f [a] some (ReadM Text -> Mod OptionFields Text -> Parser Text forall a. ReadM a -> Mod OptionFields a -> Parser a option ReadM Text forall s. IsString s => ReadM s str ( String -> Mod OptionFields Text forall (f :: * -> *) a. HasName f => String -> Mod f a long String "packages" Mod OptionFields Text -> Mod OptionFields Text -> Mod OptionFields Text forall a. Semigroup a => a -> a -> a <> Char -> Mod OptionFields Text forall (f :: * -> *) a. HasName f => Char -> Mod f a short Char 'p' Mod OptionFields Text -> Mod OptionFields Text -> Mod OptionFields Text forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Text forall (f :: * -> *) a. HasMetavar f => String -> Mod f a metavar String "PACKAGE" Mod OptionFields Text -> Mod OptionFields Text -> Mod OptionFields Text forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Text forall (f :: * -> *) a. String -> Mod f a help String "Packages to install in the shell.nix file. This option can be used multiple times to specify multiple packages" ))) Parser (Maybe Text -> Bool -> Bool -> Maybe [String] -> Maybe [Text] -> CommandLineOptions) -> Parser (Maybe Text) -> Parser (Bool -> Bool -> Maybe [String] -> Maybe [Text] -> CommandLineOptions) forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser Text -> Parser (Maybe Text) forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a) optional (ReadM Text -> Mod OptionFields Text -> Parser Text forall a. ReadM a -> Mod OptionFields a -> Parser a option ReadM Text forall s. IsString s => ReadM s str ( String -> Mod OptionFields Text forall (f :: * -> *) a. HasName f => String -> Mod f a long String "command" Mod OptionFields Text -> Mod OptionFields Text -> Mod OptionFields Text forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Text forall (f :: * -> *) a. HasName f => String -> Mod f a long String "run" Mod OptionFields Text -> Mod OptionFields Text -> Mod OptionFields Text forall a. Semigroup a => a -> a -> a <> Char -> Mod OptionFields Text forall (f :: * -> *) a. HasName f => Char -> Mod f a short Char 'c' Mod OptionFields Text -> Mod OptionFields Text -> Mod OptionFields Text forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Text forall (f :: * -> *) a. HasMetavar f => String -> Mod f a metavar String "COMMAND" Mod OptionFields Text -> Mod OptionFields Text -> Mod OptionFields Text forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields Text forall (f :: * -> *) a. String -> Mod f a help String "Command to run on initial shell startup" )) Parser (Bool -> Bool -> Maybe [String] -> Maybe [Text] -> CommandLineOptions) -> Parser Bool -> Parser (Bool -> Maybe [String] -> Maybe [Text] -> CommandLineOptions) forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Mod FlagFields Bool -> Parser Bool switch ( String -> Mod FlagFields Bool forall (f :: * -> *) a. HasName f => String -> Mod f a long String "with-flake" Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool forall a. Semigroup a => a -> a -> a <> String -> Mod FlagFields Bool forall (f :: * -> *) a. String -> Mod f a help String "When using the -p option to specify packages, use this switch to have a flake.nix created in addition to a shell.nix. This is recommended to ensure the versions of dependencies are kept for reproducibility and so that shells are cached to load faster." ) Parser (Bool -> Maybe [String] -> Maybe [Text] -> CommandLineOptions) -> Parser Bool -> Parser (Maybe [String] -> Maybe [Text] -> CommandLineOptions) forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Mod FlagFields Bool -> Parser Bool switch ( String -> Mod FlagFields Bool forall (f :: * -> *) a. HasName f => String -> Mod f a long String "allow-local-pinned-registries-to-be-prioritized" Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool forall a. Semigroup a => a -> a -> a <> String -> Mod FlagFields Bool forall (f :: * -> *) a. String -> Mod f a help String "Pinned local repoisitory URLs are usually taken last when looking for URLs for generated flake.nix files. This is usually desired. If you do however want to see these pinned entries in the flake file as specified in your registry, then set this flag." ) Parser (Maybe [String] -> Maybe [Text] -> CommandLineOptions) -> Parser (Maybe [String]) -> Parser (Maybe [Text] -> CommandLineOptions) forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser [String] -> Parser (Maybe [String]) forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a) optional (Parser String -> Parser [String] forall a. Parser a -> Parser [a] forall (f :: * -> *) a. Alternative f => f a -> f [a] some (ReadM String -> Mod OptionFields String -> Parser String forall a. ReadM a -> Mod OptionFields a -> Parser a option ReadM String forall s. IsString s => ReadM s str ( String -> Mod OptionFields String forall (f :: * -> *) a. HasName f => String -> Mod f a long String "arg" Mod OptionFields String -> Mod OptionFields String -> Mod OptionFields String forall a. Semigroup a => a -> a -> a <> String -> Mod OptionFields String forall (f :: * -> *) a. HasName f => String -> Mod f a long String "argstr" Mod OptionFields String -> Mod OptionFields String -> Mod OptionFields String forall a. Semigroup a => a -> a -> a <> Mod OptionFields String forall (f :: * -> *) a. Mod f a hidden ))) Parser (Maybe [Text] -> CommandLineOptions) -> Parser (Maybe [Text]) -> Parser CommandLineOptions forall a b. Parser (a -> b) -> Parser a -> Parser b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser [Text] -> Parser (Maybe [Text]) forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a) optional (Parser Text -> Parser [Text] forall a. Parser a -> Parser [a] forall (f :: * -> *) a. Alternative f => f a -> f [a] some (ReadM Text -> Mod ArgumentFields Text -> Parser Text forall a. ReadM a -> Mod ArgumentFields a -> Parser a argument ReadM Text forall s. IsString s => ReadM s str (String -> Mod ArgumentFields Text forall (f :: * -> *) a. HasMetavar f => String -> Mod f a metavar String "shell PACKAGES..."))) data Options = Options { Options -> Packages _packages :: !Packages , Options -> Maybe Text _command :: !(Maybe Text) , Options -> OutputForm _outputForm :: !OutputForm , Options -> Bool _prioritiseLocalPinnedSystem :: !Bool } deriving (Options -> Options -> Bool (Options -> Options -> Bool) -> (Options -> Options -> Bool) -> Eq Options forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: Options -> Options -> Bool == :: Options -> Options -> Bool $c/= :: Options -> Options -> Bool /= :: Options -> Options -> Bool Eq, Int -> Options -> ShowS [Options] -> ShowS Options -> String (Int -> Options -> ShowS) -> (Options -> String) -> ([Options] -> ShowS) -> Show Options forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> Options -> ShowS showsPrec :: Int -> Options -> ShowS $cshow :: Options -> String show :: Options -> String $cshowList :: [Options] -> ShowS showList :: [Options] -> ShowS Show) data CommandLineOptions = CommandLineOptions { CommandLineOptions -> Maybe [Text] __packages :: !(Maybe [Text]) , CommandLineOptions -> Maybe Text __command :: !(Maybe Text) , CommandLineOptions -> Bool __withFlake :: !Bool , CommandLineOptions -> Bool __prioritiseLocalPinnedSystem :: Bool , CommandLineOptions -> Maybe [String] __discard :: !(Maybe [String]) , CommandLineOptions -> Maybe [Text] __shellPackages :: Maybe [Package] } deriving (Int -> CommandLineOptions -> ShowS [CommandLineOptions] -> ShowS CommandLineOptions -> String (Int -> CommandLineOptions -> ShowS) -> (CommandLineOptions -> String) -> ([CommandLineOptions] -> ShowS) -> Show CommandLineOptions forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> CommandLineOptions -> ShowS showsPrec :: Int -> CommandLineOptions -> ShowS $cshow :: CommandLineOptions -> String show :: CommandLineOptions -> String $cshowList :: [CommandLineOptions] -> ShowS showList :: [CommandLineOptions] -> ShowS Show) makeLenses ''Options instance Default Options where def :: Options def = Options { _packages :: Packages _packages = Packages forall a. Monoid a => a mempty, _command :: Maybe Text _command = Maybe Text forall a. Maybe a Nothing, _outputForm :: OutputForm _outputForm = OutputForm Traditional, _prioritiseLocalPinnedSystem :: Bool _prioritiseLocalPinnedSystem = Bool False } parseCommandLine :: [String] -> Either Text (ParserResult Options) parseCommandLine :: [String] -> Either Text (ParserResult Options) parseCommandLine = (\case Success CommandLineOptions res -> (Options -> ParserResult Options) -> Either Text Options -> Either Text (ParserResult Options) forall a b. (a -> b) -> Either Text a -> Either Text b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Options -> ParserResult Options forall a. a -> ParserResult a Success (CommandLineOptions -> Either Text Options parseCommandLineOptions CommandLineOptions res) Failure ParserFailure ParserHelp failure -> ParserResult Options -> Either Text (ParserResult Options) forall a b. b -> Either a b Right (ParserResult Options -> Either Text (ParserResult Options)) -> ParserResult Options -> Either Text (ParserResult Options) forall a b. (a -> b) -> a -> b $ ParserFailure ParserHelp -> ParserResult Options forall a. ParserFailure ParserHelp -> ParserResult a Failure ParserFailure ParserHelp failure CompletionInvoked CompletionResult f -> ParserResult Options -> Either Text (ParserResult Options) forall a b. b -> Either a b Right (ParserResult Options -> Either Text (ParserResult Options)) -> ParserResult Options -> Either Text (ParserResult Options) forall a b. (a -> b) -> a -> b $ CompletionResult -> ParserResult Options forall a. CompletionResult -> ParserResult a CompletionInvoked CompletionResult f) (ParserResult CommandLineOptions -> Either Text (ParserResult Options)) -> ([String] -> ParserResult CommandLineOptions) -> [String] -> Either Text (ParserResult Options) forall b c a. (b -> c) -> (a -> b) -> a -> c . ParserPrefs -> ParserInfo CommandLineOptions -> [String] -> ParserResult CommandLineOptions forall a. ParserPrefs -> ParserInfo a -> [String] -> ParserResult a execParserPure ParserPrefs defaultPrefs ParserInfo CommandLineOptions opts ([String] -> ParserResult CommandLineOptions) -> ([String] -> [String]) -> [String] -> ParserResult CommandLineOptions forall b c a. (b -> c) -> (a -> b) -> a -> c . [String] -> [String] fixupRequest where parseCommandLineOptions :: CommandLineOptions -> Either Text Options parseCommandLineOptions :: CommandLineOptions -> Either Text Options parseCommandLineOptions CommandLineOptions originalParsedOptions = if Options -> Packages _packages Options transformedOptions Packages -> Packages -> Bool forall a. Eq a => a -> a -> Bool == Packages forall a. Monoid a => a mempty then Text -> Either Text Options forall a b. a -> Either a b Left Text noPackagesError else Options -> Either Text Options forall a b. b -> Either a b Right Options transformedOptions where transformedOptions :: Options transformedOptions = (Packages -> Maybe Text -> OutputForm -> Bool -> Options Options (Packages -> Maybe Text -> OutputForm -> Bool -> Options) -> (CommandLineOptions -> Packages) -> CommandLineOptions -> Maybe Text -> OutputForm -> Bool -> Options forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [Text] -> Packages setPackages ([Text] -> Packages) -> (CommandLineOptions -> [Text]) -> CommandLineOptions -> Packages forall b c a. (b -> c) -> (a -> b) -> a -> c . ([Text] -> [Text] -> [Text] forall a. [a] -> [a] -> [a] (++) ([Text] -> [Text] -> [Text]) -> (CommandLineOptions -> [Text]) -> CommandLineOptions -> [Text] -> [Text] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [Text] -> Maybe [Text] -> [Text] forall a. a -> Maybe a -> a fromMaybe [Text] forall a. Monoid a => a mempty (Maybe [Text] -> [Text]) -> (CommandLineOptions -> Maybe [Text]) -> CommandLineOptions -> [Text] forall b c a. (b -> c) -> (a -> b) -> a -> c . CommandLineOptions -> Maybe [Text] __packages (CommandLineOptions -> [Text] -> [Text]) -> (CommandLineOptions -> [Text]) -> CommandLineOptions -> [Text] forall a b. (CommandLineOptions -> a -> b) -> (CommandLineOptions -> a) -> CommandLineOptions -> b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Maybe [Text] -> [Text] forall {a}. (Eq a, IsString a) => Maybe [a] -> [a] shellArgs (Maybe [Text] -> [Text]) -> (CommandLineOptions -> Maybe [Text]) -> CommandLineOptions -> [Text] forall b c a. (b -> c) -> (a -> b) -> a -> c . CommandLineOptions -> Maybe [Text] __shellPackages) (CommandLineOptions -> Maybe Text -> OutputForm -> Bool -> Options) -> (CommandLineOptions -> Maybe Text) -> CommandLineOptions -> OutputForm -> Bool -> Options forall a b. (CommandLineOptions -> a -> b) -> (CommandLineOptions -> a) -> CommandLineOptions -> b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> CommandLineOptions -> Maybe Text __command (CommandLineOptions -> OutputForm -> Bool -> Options) -> (CommandLineOptions -> OutputForm) -> CommandLineOptions -> Bool -> Options forall a b. (CommandLineOptions -> a -> b) -> (CommandLineOptions -> a) -> CommandLineOptions -> b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> \case CommandLineOptions f | CommandLineOptions -> Bool __withFlake CommandLineOptions f -> OutputForm Flake | (Maybe [Text] -> Bool forall {a}. (Eq a, IsString a) => Maybe [a] -> Bool hasShellArg (Maybe [Text] -> Bool) -> (CommandLineOptions -> Maybe [Text]) -> CommandLineOptions -> Bool forall b c a. (b -> c) -> (a -> b) -> a -> c . CommandLineOptions -> Maybe [Text] __shellPackages) CommandLineOptions f -> OutputForm Flake CommandLineOptions _ | Bool otherwise -> OutputForm Traditional (CommandLineOptions -> Bool -> Options) -> (CommandLineOptions -> Bool) -> CommandLineOptions -> Options forall a b. (CommandLineOptions -> a -> b) -> (CommandLineOptions -> a) -> CommandLineOptions -> b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> CommandLineOptions -> Bool __prioritiseLocalPinnedSystem) CommandLineOptions originalParsedOptions hasShellArg :: Maybe [a] -> Bool hasShellArg (Just (a "shell":[a] _)) = Bool True hasShellArg Maybe [a] _ = Bool False shellArgs :: Maybe [a] -> [a] shellArgs (Just (a "shell": [a] rst)) = [a] rst shellArgs Maybe [a] _ = [] fixupRequest :: [String] -> [String] fixupRequest (String a : String b : String c : [String] d) | (String a String -> String -> Bool forall a. Eq a => a -> a -> Bool == String "-p" Bool -> Bool -> Bool || String a String -> String -> Bool forall a. Eq a => a -> a -> Bool == String "--packages") Bool -> Bool -> Bool && String -> Bool isNotASwitch String b Bool -> Bool -> Bool && String -> Bool isNotASwitch String c = String a String -> [String] -> [String] forall a. a -> [a] -> [a] : String b String -> [String] -> [String] forall a. a -> [a] -> [a] : [String] -> [String] fixupRequest (String "-p" String -> [String] -> [String] forall a. a -> [a] -> [a] : String c String -> [String] -> [String] forall a. a -> [a] -> [a] : [String] d) where isNotASwitch :: String -> Bool isNotASwitch = Bool -> Bool not (Bool -> Bool) -> (String -> Bool) -> String -> Bool forall b c a. (b -> c) -> (a -> b) -> a -> c . String -> String -> Bool forall a. Eq a => [a] -> [a] -> Bool isPrefixOf String "-" fixupRequest (String a : [String] b) = String a String -> [String] -> [String] forall a. a -> [a] -> [a] : [String] -> [String] fixupRequest [String] b fixupRequest [] = []