[Haskell-cafe] workarounds for Codec.Compression.Zlib errors in
igloo at earth.li
Thu Nov 27 12:20:08 EST 2008
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
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
More information about the Haskell-Cafe