[Haskell-cafe] Contributing to http-conduit

Erik de Castro Lopo mle+hs at mega-nerd.com
Sat Jan 28 21:09:32 CET 2012


Michael Snoyman wrote:

> 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.

Maybe fromMaybe is a more grokkable function.

Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/



More information about the Haskell-Cafe mailing list