#3541: Allow local foreign imports
-----------------------------+----------------------------------------------
Reporter:  mokus             |          Owner:                  
    Type:  feature request   |         Status:  new             
Priority:  normal            |      Component:  Compiler (FFI)  
 Version:  6.10.4            |       Severity:  normal          
Keywords:                    |       Testcase:                  
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
-----------------------------+----------------------------------------------
 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.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3541>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to