[Haskell-cafe] Guide for converting existing code to Conduit 0.4?

Michael Snoyman michael at snoyman.com
Mon Apr 9 13:34:16 CEST 2012

On Mon, Apr 9, 2012 at 2:27 PM, Erik de Castro Lopo
<mle+hs at mega-nerd.com> wrote:
> Michael Snoyman wrote:
>> Hmm... I'd be surprised if you really need the Pipe signature that
>> you're providing.
> I'm not providing it, the compiler is suggesting it:
>    Network/HTTP/Proxy.hs:835:47:
>        Couldn't match expected type `ByteString' with actual type `()'
>        Expected type: C.Pipe Void ByteString (ResourceT IO) ByteString
>          Actual type: C.Source (ResourceT IO) ByteString
>        In the return type of a call of `requestBody'
>        In the second argument of `($)', namely `requestBody req'
> For the code:
>    HC.requestBody = HC.RequestBodySource contentLength
>                         $ fmap copyByteString
>                         $ Wai.requestBody req
> but the type of the RequestBodySource constructor and Wai.requestBody
> hasn't changed.
> Erik
> --
> ----------------------------------------------------------------------
> Erik de Castro Lopo
> http://www.mega-nerd.com/
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

It's caused by fmap. This is one of the downsides with the move to a
single type: some of the instances don't make sense anymore. In
particular, Functor will allow you to map the *result* type, not the
*output* type. I think I'll add a helper function- mapOutput- to the
next version of conduit. Meanwhile, you can use:

    Wai.requestBody req $= Data.Conduit.List.map copyByteString


More information about the Haskell-Cafe mailing list