[arch-haskell] Cmdargs and common flags
Magnus Therning
magnus at therning.org
Thu Jan 20 09:48:35 CET 2011
I'm looking for a good way of dealing with common flags in cmdargs.
Currently what I do requires a bit of repetition that I'd really like
to get rid of:
1. Data types
data Modes = Cmd1 { foo :: String, ... } | Cmd2 { foo :: String, ... }
2. Mode specifications
cmd1 = Cmd1 { foo = def &= help "..", ...}
cmd2 = Cmd2 { foo = def &= help "..", ...}
I have no idea how to deal with the repetition in the data types, so
all suggestions are welcome.
For the repetition in the mode specifications I attempted to factor
the common bits into a "variable":
flagFoo = "" &= help ".."
but that resulted in only the first command getting the proper
specification. I suppose this comes down to the impurity, but how do
I work around that? (Especially, are there any good examples of using
the pure part of the API?)
/M
--
Magnus Therning OpenPGP: 0xAB4DFBA4
email: magnus at therning.org jabber: magnus at therning.org
twitter: magthe http://therning.org/magnus
More information about the arch-haskell
mailing list