[Haskell-cafe] Contributing to http-conduit

Michael Snoyman michael at snoyman.com
Sat Jan 28 17:28:07 CET 2012


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.

Michael



More information about the Haskell-Cafe mailing list