[Haskell-beginners] confused by <-

Brent Yorgey byorgey at seas.upenn.edu
Thu Sep 27 19:48:18 CEST 2012


On Thu, Sep 27, 2012 at 10:38:31AM -0700, Bryce Verdier 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")
> 
> and I got this error:
> playhaven.hs:54:73:
>     Ambiguous type variable `a0' in the constraints:
>       (Show a0) arising from a use of `show' at playhaven.hs:54:73-76
>       (Exception a0) arising from a use of `try' at playhaven.hs:52:13-15
>     Probable fix: add a type signature that fixes these type variable(s)
> 
> So I figured that adding the type signature would help with it. If
> you know of another way to make this work I would really like to hear
> about it.

Ah, yes, then you do need a type signature.

(Sadly I cannot answer your real question, since I don't know anything
about the libraries in question.)

-Brent



More information about the Beginners mailing list