[Haskell-beginners] confused by <-

David McBride toad3k at gmail.com
Thu Sep 27 19:43:52 CEST 2012


I think what he is asking is if try (from lifted) has type

try :: (MonadBaseControl<http://hackage.haskell.org/packages/archive/monad-control/0.3.1.4/doc/html/Control-Monad-Trans-Control.html#t:MonadBaseControl>
IO<http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/System-IO.html#t:IO>m,
Exception<http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/Control-Exception-Base.html#t:Exception>e)
=> m a -> m (
Either<http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/Data-Either.html#t:Either>e
a)

and simpleHttp is

simpleHttp "googe" ::
IO<http://hackage.haskell.org/packages/archive/base/4.6.0.0/doc/html/System-IO.html#t:IO>(
Result<http://hackage.haskell.org/packages/archive/HTTP/latest/doc/html/Network-Stream.html#t:Result>(
Response<http://hackage.haskell.org/packages/archive/HTTP/latest/doc/html/Network-HTTP-Base.html#t:Response>ty))

then how can the whole statement have

try $ simpleHttp "goog" :: GHandler master sub (Either SomeException
ByteString)

when the m in both parts of try is the same, it should end up IO not
GHandler master sub.  So I don't understand why this would work, either.

On Thu, Sep 27, 2012 at 1:33 PM, Brent Yorgey <byorgey at seas.upenn.edu>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
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120927/9863ef11/attachment.htm>


More information about the Beginners mailing list