Module GetOpt2

Extension of the GetOpt command line argument parser. This module defines some utility functions to allow the parsing of option arguments to also handle errors in the arguments.

Author: Björn Peemöller

Version: September 2015

Summary of exported operations:

onOpts :: (a -> a) -> (a,[String]) -> (a,[String])   
Lift a function on options to options and errors.
onOptsArg :: (String -> a -> a) -> String -> (a,[String]) -> (a,[String])   
Lift a function on a string and options to options and errors.
addErr :: String -> (a,[String]) -> (a,[String])   
Add an error message to a option/errors pair.
option :: String -> [String] -> [(String,String,a -> a)] -> String -> String -> OptDescr ((a,[String]) -> (a,[String]))   
Convert an option table to option descriptions capable of error handling.
parseOptErr :: String -> [(String,String,a -> a)] -> String -> (a,[String]) -> (a,[String])   
Parsing function for option specified as an option table.
renderOptErrTable :: [(String,String,a -> a)] -> String   
Rendering of an option specified using an option table.

Exported datatypes:


OptErr

Type synonym for option and error message

Type synonym: OptErr a = (a,[String])


OptTable

An option table is a list of triples consisting of the option string, its description and the effect on the global option set.

Type synonym: OptTable a = [(String,String,a -> a)]


Exported operations:

onOpts :: (a -> a) -> (a,[String]) -> (a,[String])   

Lift a function on options to options and errors.

onOptsArg :: (String -> a -> a) -> String -> (a,[String]) -> (a,[String])   

Lift a function on a string and options to options and errors.

addErr :: String -> (a,[String]) -> (a,[String])   

Add an error message to a option/errors pair.

Further infos:
  • solution complete, i.e., able to compute all solutions

option :: String -> [String] -> [(String,String,a -> a)] -> String -> String -> OptDescr ((a,[String]) -> (a,[String]))   

Convert an option table to option descriptions capable of error handling.

parseOptErr :: String -> [(String,String,a -> a)] -> String -> (a,[String]) -> (a,[String])   

Parsing function for option specified as an option table.

renderOptErrTable :: [(String,String,a -> a)] -> String   

Rendering of an option specified using an option table.