The Quipper System

Safe HaskellNone

Libraries.CommandLine

Contents

Description

This module provides some functions that are useful in the processing of command line options, and that are shared between several algorithms.

Synopsis

Option processing

optfail :: String -> IO a Source #

Exit with an error message after a command line error. This also outputs information on where to find command line help.

parse_int :: Integral r => String -> Maybe r Source #

Parse a string to an integer, or return Nothing on failure.

parse_list_int :: String -> Maybe [Int] Source #

Parse a string to a list of integers, or return Nothing on failure.

parse_double :: String -> Maybe Double Source #

Parse a string to a Double, or return Nothing on failure.

match_enum :: [(String, a)] -> String -> [(String, a)] Source #

In an association list, find the key that best matches the given string. If one key matches exactly, return the corresponding key-value pair. Otherwise, return a list of all key-value pairs whose key have the given string as a prefix. This list could be of length 0 (no match), 1 (unique match), or greater (ambiguous key). Note: the keys in the association list must be lower case. The input string is converted to lower case as well, resulting in case-insensitive matching.

show_enum :: String -> [(String, a)] -> String Source #

Pretty-print a list of possible values for a parameter. The first argument is the name of the parameter, and the second argument is its enumeration.