[Haskell-cafe] Contributing to http-conduit
michael at snoyman.com
Sun Jan 29 05:17:39 CET 2012
Thanks, looks great! I've merged it into the Github tree.
On Sat, Jan 28, 2012 at 8:36 PM, Myles C. Maxfield
<myles.maxfield at gmail.com> wrote:
> Ah, yes, you're completely right. I completely agree that moving the
> function into the Maybe monad increases readability. This kind of function
> is what the Maybe monad was designed for.
> Here is a revised patch.
> On Sat, Jan 28, 2012 at 8:28 AM, Michael Snoyman <michael at snoyman.com>
>> On Sat, Jan 28, 2012 at 1:20 AM, Myles C. Maxfield
>> <myles.maxfield at gmail.com> wrote:
>> > the fromJust should never fail, beceause of the guard statement:
>> > | 300 <= code && code < 400 && isJust l'' && isJust l' = Just $ req
>> > Because of the order of the && operators, it will only evaluate fromJust
>> > after it makes sure that the argument isJust. That function in
>> > particular
>> > shouldn't throw any exceptions - it should only return Nothing.
>> > Knowing that, I don't quite think I understand what your concern is. Can
>> > you
>> > elaborate?
>> You're right, but I had to squint really hard to prove to myself that
>> you're right. That's the kind of code that could easily be broken in
>> future updates by an unwitting maintainer (e.g., me). To protect the
>> world from me, I'd prefer if the code didn't have the fromJust. This
>> might be a good place to leverage the Monad instance of Maybe.
More information about the Haskell-Cafe