On Thu, 2008-11-27 at 17:20 +0000, Ian Lynagh wrote: > On Wed, Nov 26, 2008 at 10:28:21PM +0000, Duncan Coutts wrote:
> > 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). Right, which is why we do not use IO CInt style error handling much in Haskell. For functions that return a real result we use Maybe, or for things that would otherwise be IO (), then using IO exceptions is the obvious thing to do. In either case the error is hard to ignore. Duncan _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe