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

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

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Marc Weber wrote: [snip] | 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? It's used in cabal-install; http://darcs.haskell.org/cabal-install I can agree the flag business seems confusing at first. | == Suggestion ================================================ I'd have to read the source more to give good answers here :) Cheers, take care, ~ Lennart Kolmodin -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFH1bqp4txYG4KUCuERArE1AJ9CM0AUxm192ViDLyd+aBOUSr+9uwCfUYKe 9NlmH+sl0KuneQMNYM90yv4= =yycp -----END PGP SIGNATURE-----

It's used in cabal-install; http://darcs.haskell.org/cabal-install I can agree the flag business seems confusing at first. so adding simple comments is the best choice then :)
Thanks Marc

dcoutts has told me that there was a choice: Duplicating the record (one for assembling options the way it's now (A)) and one for usage (B). Seems like beeing duplication but.. many (fromFlag configVerbose) in all Setup.lhs files is duplication as well. (A) now : definition ConfigureFlags = { ...; configVerbose :: Flag Verbosity ^^^ <- difference (for the user writing Setup.hs) usage fromFlag . configVerbose $ flags (B) the way it was (seen by the Setup.hs writer) and the other way: definition ConfigureFlagsGetOpt = { ...; configVerbose :: Flag Verbosity -- no longer any non configured values.. defaults must have been filled in there and you see can see it ReadConfigureFlags = { ...; configVerbose :: Verbosity ^^^^ <- difference (for the user writing Setup.hs ) usage: configVerbose $ flags Because Cabal is a tool designed to make package writing more easy for the mass maybe the right way to go in the future is a design beeing closer to (B) ? Why? Because you can just open Setup.hs and jump to the definition and you see what you have to see no longer wondering about default values and how things are used internally within Cabal. (I mean wether and when defaultConfigFlags is actually used so it's safe to use .. you know this already from my privious post :) I don't want to break things.. I only want tell you about my thoughts. Sincerly Marc Weber

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)
Which version of Cabal? I've kept a couple of Takusen's old Setup files around, for this reason. We should be able to build with cabal-1.1.4. Alistair

Hi Alistair! Wow, the author himself :) Dcoutts has suggested this replacement. Reading it in combination with the manual has brought much insight in how powerful cabal can be. He has pasted it : http://hpaste.org/6279 I haven't tried it yet but it looks really nice. The only thing missing is extending cabal so that configuration fails (thus flags get disabled automatically) if libs/ includes aren't found. Maybe this already works with pkg-config (don't know yet).. Meanwhile I've done the quickest hack just inserting the libs dirs manually and disabling the auto detect features (which works fine for nix), at least ghci -package Takusen no longer shows any errors. The Cabal version I've used is no older than 2 weeks. Alistair, Dcoutts: Thanks for your attention. It's more important getting started with the lib and adding gtk2hs etc than improving cabal. But it's good to know how it can / should be done in the future. Sincerly Marc Weber
participants (3)
-
Alistair Bayley
-
Lennart Kolmodin
-
Marc Weber