[Haskell-beginners] confused by <-

Chaddaï Fouché chaddai.fouche at gmail.com
Thu Sep 27 21:25:12 CEST 2012


On Thu, Sep 27, 2012 at 7:38 PM, Bryce Verdier <bryceverdier at gmail.com>wrote:

> On 9/27/12 10:33 AM, Brent Yorgey wrote:
>
>> On Thu, Sep 27, 2012 at 10:01:25AM -0700, Bryce Verdier wrote:
>>
>>> On 9/26/12 6:00 PM, Ertugrul Söylemez wrote:
>>>
>>>> Bryce Verdier <bryceverdier at gmail.com> wrote:
>>>>
>>>>        body <- L.try (simpleHttp "http://www.google.com") :: IO (Either
>>>>> L.SomeException Data.ByteString.Lazy.Internal.**ByteString)
>>>>>
>>>> Almost right, but your type signature is lying. =)
>>>>
>>>>
>>>> Greets,
>>>> Ertugrul
>>>>
>>> Thanks for your hint, with a fair amount of head bashing against a
>>> wall I was able to figure this out. At the end of day I got :
>>>
>>>      body <- try (simpleHttp "http://www.google.com") :: GHandler
>>> PlayHaven PlayHaven (Either SomeException ByteString)
>>>
>> Do you need a type signature there at all?
>>
>> -Brent
>>
> That is an awesome question. Originally I tried:
>
>
>        body <- try (simpleHttp "http://www.google.com")
>

this can be made to work by adding less stuff :


> getGoogR = do
>    body <- try (simpleHttp "http://www.google.com")
>    case body of
>        Left (SomeException _) -> jsonToRepJson $ object ["response" .= (
show "ERROR: NO DATA FOR ONE REASON OR ANOTHER")]
>        Right val -> jsonToRepJson $ object ["response" .= (showDigest $
sha1 val)]

I think that should work...

-- 
Jedaï
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120927/ae2ee7b1/attachment.htm>


More information about the Beginners mailing list