[xmonad] DynamicLog improvements and new contrib module, XMonad.Util.Loggers

Brent Yorgey byorgey at gmail.com
Wed Feb 20 10:37:11 EST 2008

On Wed, Feb 20, 2008 at 8:15 AM, Andrea Rossato <andrea.rossato at unibz.it>

> On Wed, Feb 20, 2008 at 07:04:33AM -0500, Brent Yorgey wrote:
> > Hmm... well, using 'catMaybes' doesn't do that: catMaybes [Just "abc",
> > Nothing] --> ["abc"], but catMaybes [Just "abc", Just ""] --> ["abc",
> ""].
> > But in the end I guess you're right, since the status bar output
> function
> > filters out the empty string (in particular the "sepBy" function filters
> out
> > the null string).  I didn't realize this before, and I wonder whether it
> is
> > really the correct behavior.  My intention was to allow for two
> different
> > cases, one in which a logger does not want to output anything (or gives
> an
> > error), and another in which the logger explicitly wants to output the
> empty
> > string. For example, maybe you have a logger which only outputs
> something
> > some of the time, but when it is not outputting anything you still want
> a
> > blank space where it would have been.  I don't know, it's not really
> very
> > important either way, I guess. =)
> well, I was assuming a status bar is a one line only string and so a
> "" is... nothing...;)
> I see your point: someone wanted the prompt, afair, to return a Maybe
> String, where a Nothing was the user exiting the prompt with Esc or
> so. I don't think that could be the case of a logger, though.

Yes, that was me. =)  Anyway, the question here comes down to whether it's
useful to be able to distinguish between failure and success returning the
empty string.  Even if we decide we don't care to distinguish between them
right now (since empty strings will get filtered out anyway), on principle
it still just seems sort of icky and non-Haskelly to me to signal failure
with the special value "".  It reminds me of returning -1 from int functions
in C. =P

> BTW, it was Spencer who pushed me to reflect about the fact that a
> 'Maybe list' is usually something uselessly complicated - I used a
> maybe [Window] or something like that in the very first version of the
> prompt if I recall it correctly...

I think it depends on whether you are using a list to represent a "list of
successes" (in which case Maybe [a] is not needed, since [] = no successes =
failure), or to represent a singular data result (in which case the empty
list is just as valid of a result as any other list, hence Maybe [a] is
needed to denote possible failure).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/xmonad/attachments/20080220/441cf194/attachment.htm

More information about the xmonad mailing list