Food for thought: Numeric.Special

Alastair Reid
Fri, 6 Jun 2003 12:11:11 +0100

On Friday 06 June 2003 11:38 am, Keith Wansbrough wrote:

> That wouldn't be too hard, and if there really are zillions of
> functions, it would save a lot of work for the straightforward cases.

My experience is that there are an annoying number of non-straightforward 
cases where you need a programmer to read documentation and make sensible 

There's a tool for ML which directly translates header files into the obvious 
ML type.  There's also swig which does much the same but for a wide range of 
languages (I think it started with python).  The problem is that you end up 
with an idiomatic C interface like:

  getMousePos :: Ptr CInt -> Ptr CInt -> IO CInt

instead of an idiomatic Haskell interface like:

  getMousePos :: IO (CInt,CInt)
  -- raises an exception if device not present

Before anyone can use this function, they will have to read the documentation 
and figure it out and, since this is the hard part of creating the interface, 
it is best to have a human do it just once instead of having everyone who 
uses the library have to repeat the work.

Alastair Reid