[Haskell-cafe] workarounds for Codec.Compression.Zlib errors in darcs

Luke Palmer lrpalmer at gmail.com
Thu Nov 27 12:27:48 EST 2008


On Thu, Nov 27, 2008 at 10:20 AM, Ian Lynagh <igloo at earth.li> wrote:
> On Wed, Nov 26, 2008 at 10:28:21PM +0000, Duncan Coutts wrote:
>> On Wed, 2008-11-26 at 14:38 +0000, Eric Kow wrote:
>> >
>> > Older versions of darcs can to produce gzipped files with broken CRCs.
>> > We never noticed this because our homegrown wrapper around the C libz
>> > library does not pick up these errors.
>>
>> I should note that one moral of this story is to check that your FFI
>> imports are correct. That is, check they import the foreign functions at
>> the right Haskell types. In this case the mistake was that the foreign
>> function returned a C int, but the Haskell foreign import declaration
>> stated that the C function returned IO () rather than IO CInt.
>
> While that's true, Haskell also makes it easy to make the same sort of
> error with IO (or any other Monad) values, whether created with the FFI
> or not. If you say
>
>    f = do x
>           y
>           z
>
> and y has type IO CInt then you won't get an error (and I don't think
> you can even ask for a warning with the current implementations).
>
> Should we have
>    (>>) :: (Monad m) => m () -> m a -> m a
> and force you to write
>    _ <- y
> ?

I'd like that (though I certainly didn't like that prospect when I
started learning).  I think the option of turning on a warning would
be a nice happy medium.

Luke


More information about the Haskell-Cafe mailing list