CurryInfo: html2-3.5.0 / C2C.Options.processOptions

definition:
processOptions :: [String] -> IO (Options,String)
processOptions argv = do
  let (funopts, args, opterrors) = getOpt Permute options argv
      opts = foldl (flip id) defaultOptions funopts
  unless (null opterrors)
         (putStr (unlines opterrors) >> printUsage >> exitWith 1)
  when (optHelp opts) (printUsage >> exitWith 0)
  case args of
    [p] -> let mname = stripCurrySuffix p
               opts1 = opts { optFormMods = nub (optFormMods opts ++ [mname])
                            , optMain = if null (optMain opts)
                                          then mname ++ ".main"
                                          else optMain opts }
           in return (opts1, mname)
    []  -> error $ "Name of main module missing!"
    _   -> error $ "Too many main modules: " ++ unwords args ++
                   "\nPlease provide only one main module!"
 where
  printUsage = putStrLn (banner ++ "\n" ++ usageText)
demand:
no demanded arguments
deterministic:
deterministic operation
documentation:
--- Process the actual command line argument and return the options
--- and the name of the main program.
failfree:
_
indeterministic:
referentially transparent operation
infix:
no fixity defined
iotype:
{(_) |-> _}
name:
processOptions
precedence:
no precedence defined
result-values:
_
signature:
[String] -> Prelude.IO (Options, String)
solution-complete:
operation might suspend on free variables
terminating:
possibly non-terminating
totally-defined:
possibly non-reducible on same data term