Difference between revisions of "Command line option parsers"

From HaskellWiki
Jump to navigation Jump to search
(list of packages taken from Tutorials/Programming Haskell/Argument handling)
 
(details on yaop, simpleargs, ReadArgs)
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
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:
 
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:
   
  +
{| class="wikitable"
* {{HackagePackage|id=cmdargs}}
 
  +
|-
* {{HackagePackage|id=cmdlib}}
 
  +
! Package !! Multi-mode !! Extensions !! Remark
* {{HackagePackage|id=cmdtheline}}
 
  +
|-
* {{HackagePackage|id=console-program}}
 
  +
| {{HackagePackage|id=cmdargs}} || X || TemplateHaskell, SYB generics, ViewPatterns, ... || <hask>unsafePerformIO</hask>
* {{HackagePackage|id=getflag}}
 
  +
|-
* {{HackagePackage|id=hflags}}
 
* {{HackagePackage|id=multiarg}}
+
| {{HackagePackage|id=cmdlib}} || X || SYB generics || based on [[GetOpt]]
  +
|-
* {{HackagePackage|id=options}}
 
  +
| {{HackagePackage|id=cmdtheline}} || X || FlexibleInstances (although unnecessary) || shows help as man-page
* {{HackagePackage|id=optparse-applicative}}
 
  +
|-
* {{HackagePackage|id=parseargs}}
 
* {{HackagePackage|id=ReadArgs}}
+
| {{HackagePackage|id=console-program}} || X || TemplateHaskell || configure options via files
  +
|-
* {{HackagePackage|id=simpleargs}}
 
* {{HackagePackage|id=yaop}}
+
| {{HackagePackage|id=getflag}} || - || Haskell98 || like [[GetOpt]] but with Unix/Plan 9 option syntax
  +
|-
  +
| {{HackagePackage|id=hflags}} || - || TemplateHaskell || inspired by Google's gflags, provides parsed options in top-level variables, allow to set options via environment variables
  +
|-
  +
| {{HackagePackage|id=multiarg}} || - || CPP || long options with multiple arguments
  +
|-
 
| {{HackagePackage|id=options}} || X || TemplateHaskell ||
  +
|-
 
| {{HackagePackage|id=optparse-applicative}} || X || GADT || Applicative Functor
  +
|-
  +
| {{HackagePackage|id=parseargs}} || - || FlexibleInstances (although unnecessary) || supports a fixed set of argument types: <hask>Int, Integer, Float, Double, String, FileOpener</hask>
  +
|-
  +
| {{HackagePackage|id=ReadArgs}} || - || OverlappingInstances, TypeOperators || No options, only arguments. The argument template is derived from the requested argument tuple.
  +
|-
  +
| {{HackagePackage|id=simpleargs}} || - || OverlappingInstances (although unnecessary) || the same as ReadArgs
  +
|-
  +
| {{HackagePackage|id=yaop}} || - || TemplateHaskell, GeneralizedNewtypeDeriving || wrapper around GetOpt
  +
|}
  +
  +
The column for required Haskell extensions gives an idea of how easy it is to port the package to compilers other than [[GHC]].
  +
   
 
[[Category:Packages]]
 
[[Category:Packages]]

Revision as of 17:56, 7 November 2012

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:

Package Multi-mode Extensions Remark
cmdargs X TemplateHaskell, SYB generics, ViewPatterns, ... unsafePerformIO
cmdlib X SYB generics based on GetOpt
cmdtheline X FlexibleInstances (although unnecessary) shows help as man-page
console-program X TemplateHaskell configure options via files
getflag - Haskell98 like GetOpt but with Unix/Plan 9 option syntax
hflags - TemplateHaskell inspired by Google's gflags, provides parsed options in top-level variables, allow to set options via environment variables
multiarg - CPP long options with multiple arguments
options X TemplateHaskell
optparse-applicative X GADT Applicative Functor
parseargs - FlexibleInstances (although unnecessary) supports a fixed set of argument types: Int, Integer, Float, Double, String, FileOpener
ReadArgs - OverlappingInstances, TypeOperators No options, only arguments. The argument template is derived from the requested argument tuple.
simpleargs - OverlappingInstances (although unnecessary) the same as ReadArgs
yaop - TemplateHaskell, GeneralizedNewtypeDeriving wrapper around GetOpt

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