Maintainer | defanor <defanor@uberspace.net> |
---|---|
Stability | unstable |
Portability | non-portable (uses GHC extensions) |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Coalpit is a library for building command-line interfaces: the goal is to build interfaces quickly and easily (by deriving those), while keeping them language-agnostic and more user- and shell scripting-friendly than JSON and similar formats.
Synopsis
- fromDSV :: Coalpit a => Options -> String -> Either String a
- fromDSVList :: Coalpit a => Options -> String -> Either String [a]
- toDSV :: Coalpit a => Options -> a -> String
- toDSVList :: Coalpit a => Options -> [a] -> String
- dsvFromList :: Options -> [String] -> String
- class Coalpit a where
- coalpitParser :: Options -> Parser a
- coalpitPrint :: Options -> a -> [String]
- coalpitDescription :: Options -> [String] -> Proxy a -> Usage
- usage :: Coalpit a => Options -> Proxy a -> Usage
- usageString :: Coalpit a => Options -> Proxy a -> String
- data Usage
- data SelNamePolicy
- data Options = Options {
- fieldSeparators :: NonEmpty Char
- recordSeparators :: NonEmpty Char
- conNameMod :: String -> String
- selNameMod :: String -> String
- selNamePolicy :: SelNamePolicy
- timeLocale :: TimeLocale
- dateFormat :: String
- timeFormat :: String
- dateTimeFormat :: String
- scientificFormat :: FPFormat
- scientificDecimals :: Maybe Int
- uriUserInfo :: String -> String
- defOpt :: Options
- escape :: Options -> String -> String
- pString :: Options -> Parsec String m String
- pFieldSep :: Options -> Parsec String m ()
- pRecordSep :: Options -> Parsec String m ()
Documentation
fromDSV :: Coalpit a => Options -> String -> Either String a Source #
Parse a single record from a string.
fromDSVList :: Coalpit a => Options -> String -> Either String [a] Source #
Parse multiple records from a string.
dsvFromList :: Options -> [String] -> String Source #
Build a record ("line") out of individual strings, escaping those if needed.
class Coalpit a where Source #
Coalpit class: parsing, printing, usage strings.
Nothing
coalpitParser :: Options -> Parser a Source #
coalpitPrint :: Options -> a -> [String] Source #
coalpitDescription :: Options -> [String] -> Proxy a -> Usage Source #
Instances
Usage
Usage description: can be translated into help messages or documentation formats.
UConstructor String | Data constructor. |
URecursive String | Constructor of a recursive data structure (its second appearance in the tree). |
USelector Bool String Usage | Record selector. |
UOptional Usage | Optional element. |
USum Usage Usage | Sum. |
UProduct Usage Usage | Product. |
UUnit | Unit. |
UType String | Type name (e.g., "INT"). |
Options
data SelNamePolicy Source #
How to handle selector names.
SNDisable | Do not parse or print selector names |
SNAvoid | Allow selector names on parsing, but do not print them |
SNPrefer | Allow selector names on parsing, print them |
SNRequire | Require selector names on parsing, print them |
Instances
Show SelNamePolicy Source # | |
Defined in Coalpit showsPrec :: Int -> SelNamePolicy -> ShowS # show :: SelNamePolicy -> String # showList :: [SelNamePolicy] -> ShowS # | |
Eq SelNamePolicy Source # | |
Defined in Coalpit (==) :: SelNamePolicy -> SelNamePolicy -> Bool # (/=) :: SelNamePolicy -> SelNamePolicy -> Bool # |
Printing and parsing options.
Options | |
|
Parsing and composition helpers
escape :: Options -> String -> String Source #
Enquote and escape a string, if it contains any characters that need it.