[darcs-devel] Logging

Jason Dagit dagit at codersbase.com
Mon Sep 11 14:17:30 PDT 2006


On 9/11/06, Eric Y. Kow <eric.kow at gmail.com> wrote:
> > >I'd rather avoid putting an Int into verbose, as in my experience this
> > >makes it hard to keep consistent levels of verbosity than otherwise.
> > >I'd go with something more like
>
> I have no opinion on whether having multiple levels of verbosity is a
> good thing or not.
>
> If we were to implement such a thing, though, I wonder if having as many
> instances of Verbose for the degree of verbosity we want would be a sane
> and workable solution.
>
> Then we can still say stuff like
> when (Verbose `elem` opts) $ blah blah

I was hoping to get rid of things like that so you'd say:
logStrLn opts Verbose $ blah blah

Or,
logStrLn opts Debug $ inane details that are only helpful when trouble shooting

While of course still giving the option of directly querying the
verbosity level so it's still possible to do conditional formating of
output and whatnot.

Although I hadn't mentioned it yet, I was actually hoping that at some
point in the distance future we may extend the IO monad to carry
around some extra details and at that time logStr could be updated to
read the opts from an environment.  For instance, if we could extend
the IO monad with features of the Reader monad.  I think someone else
on the list may have actually suggested something similar recently.

That's a terrible way to explain it if you're already familiar with
the Reader monad...so let me try this....I'm thinking we could
eventually use ReaderT DarcsEnv IO, where DarcsEnv is non-mutable
information that darcs uses (like configuration options and command
line flags).  This way we could more transparently access run-time
options instead of manually passing the data around as we do now.  I
have yet to try this technique so I don't know how well it works but
the more experienced haskell programmers in #haskell say it's a great
way to pass around 'application state'.

Here are some links if none of that made sense:
http://www.nomaware.com/monads/html/readermonad.html
http://www.nomaware.com/monads/html/xformerexamples.html#example23

My whole point of all that would be to make darcs more maintainable.
Does using ReaderT help with that?  Hopefully.  Not saying that darcs
isn't maintainable now, but maybe it could be even easier.

>
> And use something like this for more degrees of verbosity
>
> verbosity :: [DarcsFlag] -> Int
> verbosity = length . filter (== Verbose)

Hmm...I don't think this is fundamentally different than the idea that
David wanted to avoid.  In fact, I would argue here that we should try
to minimize flag duplication and instead try to 'normalize' the list
of flags that gets passed around.

Thanks for the looking over my proposal and giving feedback.
Jason




More information about the darcs-devel mailing list