[Haskell-cafe] Maintaining lambdabot
Jason Dagit
dagitj at gmail.com
Sat Mar 16 00:31:54 CET 2013
On Fri, Mar 15, 2013 at 3:30 PM, James Cook <mokus at deepbondi.net> wrote:
> On Mar 15, 2013, at 2:45 PM, Jason Dagit <dagitj at gmail.com> wrote:
>
> > I haven't been following the thread closely. Is there also a github? If
> so, where? Some of us figured out a bug fix for the quotes plugin and I'll
> send a pull request if I get a chance.
>
> Yep, there is[1]. I'm not sure what the specific bug is that you are
> referring to, but it's possible it doesn't exist anymore - a large part of
> the quotes plugin has been rewritten (actually outsourced to a fortune-mod
> clone written in Haskell called "misfortune"). If it still does, then of
> course I'd be happy to accept a fix :)
>
> [1] https://github.com/mokus0/lambdabot
>
>
Awesome.
I believe the bug is still there. The type for the quote db is:
type Key = P.ByteString
type Quotes = M.Map Key [P.ByteString]
Which leaves the possibility that a key exists but there are no quotes.
This is problematic for the current version of random. I glanced at your
new version and it wasn't clear to me if it's still a problem (I suspect it
is). One bandaid for this is to change the lines below:
https://github.com/mokus0/lambdabot/blob/master/src/Lambdabot/Plugin/Quote.hs#L161
https://github.com/mokus0/lambdabot/blob/master/src/Lambdabot/Plugin/Quote.hs#L166
In both cases "Just qs" could be changed to "Just qs@(_:_)" and then empty
lists would fall through to the default case.
The other fix is to prune out degenerate entries (where key maps to the
empty list). I believe that would be fixed in the serialization function:
moduleSerialize = Just mapListPackedSerial
Changing that to something like:
moduleSerialize = Just mapListPackedSerialSansEmpties
where
mapListPackedSerialSansEmpties = mapListPackedSerial { serialize =
(serialize mapListPackedSerial) . Map.filter (not.null) }
Perhaps that should be added to the Serial module as an alternative to
mapListPackedSerial.
I haven't tested any of the above code (or even tried to compile it).
Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130315/e1e8d14a/attachment.htm>
More information about the Haskell-Cafe
mailing list