[Haskell-beginners] confused by <-
Chaddaï Fouché
chaddai.fouche at gmail.com
Thu Sep 27 21:43:35 CEST 2012
On Thu, Sep 27, 2012 at 9:25 PM, Chaddaï Fouché
<chaddai.fouche at gmail.com> wrote:
>
> > body <- try (simpleHttp "http://www.google.com")
> > case body of
> > Left (SomeException _) -> jsonToRepJson $ object ["response" .= ( show "ERROR: NO DATA FOR ONE REASON OR ANOTHER")]
>
> I think that should work...
>
Since the signature was made necessary by the ambiguity on which type
of exception you wished to catch with your "try", using (SomeException
_) in your pattern match should make that clear. By the way, why are
you show()ing a String ? The only thing that does is adding quotes
around it and escaping some characters, shouldn't you just use :
> Left (SomeException _) -> jsonToRepJson $ object ["response" .= "ERROR: NO DATA FOR ONE REASON OR ANOTHER"]
--
Jedaï
More information about the Beginners
mailing list