Command line option parsers

From HaskellWiki
Revision as of 08:35, 23 October 2021 by Andreas.abel (talk | contribs)
Jump to: navigation, search

There are several packages that want to simplify the task of writing command line parsers. Unfortunately, they are distributed across several Hackage categories. Here is an attempt to list them.

Based on Hackage downloads, as of May 2017, cmdargs (126k downloads) and optparse-applicative (120k downloads) are the most popular.

Package Multi-mode Extensions Maintenance Remark
argparser - None (though it depends on package containers, which uses extensions) GHC 9.0 build successful (2021-10-23)
cmdargs X TemplateHaskell, SYB generics, ViewPatterns, ... GHC 9.0 build successful (2021-10-23) unsafePerformIO
cmdlib X SYB generics DEAD: latest (0.3.6) only for GHC <= 8.4; no repo (2021-10-23) based on GetOpt
cmdtheline X FlexibleInstances (although unnecessary) DEAD: latest (0.2.3) only for GHC <= 7.8; no repo (2021-10-23) shows help as man-page
console-program X (none) DYING: latest ( only for GHC <= 8.8; no issue tracker (2021-10-23) configure options via files
getflag - Haskell98 GHC 9.0 build successful (2021-10-23) like GetOpt but with Unix/Plan 9 option syntax
hflags - TemplateHaskell GHC 9.0 build successful (2021-10-23) inspired by Google's gflags, provides parsed options in top-level variables, allow to set options via environment variables
multiarg - CPP GHC 9.0 build successful (2021-10-23) long options with multiple arguments
options X GHC 9.0 build successful (2021-10-23)
optparse-applicative X GADT GHC 9.0 build successful (2021-10-23) Applicative Functor; for wrong arguments it does not show a specific error message but the general usage pattern
parseargs - FlexibleInstances (although unnecessary) GHC 9.0 build successful (2021-10-23) supports a fixed set of argument types: Int, Integer, Float, Double, String, FileOpener
ReadArgs - OverlappingInstances, TypeOperators GHC 9.0 build successful (2021-10-23) No options, only arguments. The argument template is derived from the requested argument tuple.
simpleargs - OverlappingInstances (although unnecessary) DEAD: latest (0.2.1) only for GHC <= 8.0; no repo (2021-10-23) the same as ReadArgs
uu-options - latest ( only for GHC <= 8.10 (2021-10-23) Uses the less popular data-lens. Error correction.

The column for required Haskell extensions gives an idea of how easy it is to port the package to compilers other than GHC.