takusen -> cabal -> ArgDescr (2) - my journey + suggestion

Marc Weber marco-oweber at gmx.de
Mon Mar 10 18:15:21 EDT 2008


Hi,

If you don't have time jump to the last Suggestion section.


I'd like to tell you about my reading cabal source journey today..
I wanted to compile takusen using an older Cabal Setup format (without
lag)

So I wondered who to find a getDefaultVerbosity method..

There is a defaultConfigFlags functions .. *ugh* taking a
ProgramConfiguration I don't need for getting just the :: Flag Verbosity
value ?
So writing something like 
  getDefault programConf get flags = get (defaultConfigFlags programConf) `mappend` get flags
seemed to be a (very verbose) solution at first glance..

I had to use it at two places.. and there was no ProgramConfiguration at
one (or I was to lazy to digg it up?)

Anyway I reallize that this is kind of complicated so I called for
dcoutts. He told me that configVerbose has a default value .. so I
should just use fromFlag..
Wait? Why couldn't I found out this by myself?
Because the line
  configVerbose :: Flag Verbosity -- this sets the verbosity ..
doesn't tell me about the default value and where I can assume it's set
(thus wether it's save to use fromFlag without gettint error..) he,
that's haskell with type safety? Not the way I like it..
So I thought there must be better way to handle this.

I starte hacking on cabal by
  instance Monoid Verbosity where
    mempty = normal 
    a `mappend` b = b 

and substituting 
  ":: Flag Verbosity" with ":: Verbosity"
an
  "= Flag" normal by "= mempty"

Then I've rewritten verboseoption (ugly get) (ugly set) ..
to only return Verbosity without Flag as well.
*shrug* still doesn't type check?

Simple.Commands trouble

What the hell is the third arg in ArgDescr ( OptArg) ?
Where is this used ? ([ a -> [Maybe String])
argDescrToGetOpt _ ? no, not here
ah in commandShowOptions ?
Wow.. you can print your commandlines again? wow.
But wait that function is used nowhere?


To make the long story short:

== Suggestion ================================================

What do you think about either
  a) adding a comment where configVerbose is defined that it has
    *always* a valid Flag value.. (or can you expect readers to dig into
    source for hours?)
  b) use Verbosity instead of Flag Verbosity and
      throw away commandShowOptions (and the 3 Arg of Simple.Command.ArgDescr)
      or print -v <normal> even if you haven't specified the arg?
  c) maybe do b) but keep raw args somehow to print them again instead
    of printing -v <normal> unless -v <user value> is given?

Sincerly Marc Weber



More information about the cabal-devel mailing list