Allow local foreign imports
I have no idea the level of difficulty this would entail, but it would be rather nice to be able to import foreign functions at scopes other than the top level. When writing glue code, especially for C++ where I often want to catch and haskellize exceptions, I find myself using wrappers quite a bit, for example:
foreign import ccall "foo.h foo" raw_foo :: CString -> IO () foo :: String -> IO () foo s = withCString s raw_foo
Where I only want "foo" exported from the module. It's not that big a deal to list explicit exports, I know, but I would like to be able to say instead:
foo :: String -> IO () foo s = withCString s raw_foo where foreign import ccall "foo.h foo" raw_foo :: CString -> IO ()
In addition to reducing clutter in the top level namespace, it makes for less clutter on the left margin of the code, making it easier to scan through function names visually.