[Haskell-cafe] Why Haskell?

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Sun Jul 23 04:27:09 EDT 2006

Matthew Bromberg <mattcbro at earthlink.net> writes:

> 1) Hat looks really interesting thanks.  Hopefully it will run on windows.

Under mingw or cygwin, possibly.  Natively, not.

> 3)  The problem here is existing code.  I don't want to add every 
> function that I use into a class just to maintain simple polymorphism 
> over closely related numeric types.  This would take longer than just 
> calling the coercion routines.

Possibly you just need to move the coercions to a single more manageable
location.  e.g. you could rename the FFI calls, then wrap them with a
simple coercion function, and call it by the original name.

   inject :: CInt -> Int
   eject  :: Int  -> CInt

   foreign import ccall "blah" prim_blah :: CInt -> CInt
   blah x = inject (prim_blah (eject x))

By the way, there are tools for generating FFI bindings that can create
code like this (e.g. GreenCard).


More information about the Haskell-Cafe mailing list