[GHC] #14227: Add -fdefer-ffi-errors flag

GHC ghc-devs at haskell.org
Wed Sep 13 17:38:05 UTC 2017


#14227: Add -fdefer-ffi-errors flag
-------------------------------------+-------------------------------------
           Reporter:  tysonzero      |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.2.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Currently when I do:

 {{{#!hs
 foreign import javascript unsafe
     "foo()"
     foo :: IO ()
 }}}

 I understandably get:

 {{{
     • The `javascript' calling convention is unsupported on this platform
     • When checking declaration:
         foreign import javascript unsafe "static foo()" foo :: IO ()
 }}}

 However when I am developing with GHCJS I still want to use all my typical
 GHC tooling, a lot of which is not supported on GHCJS. So I need GHC to be
 able to compile my code even though I don't actually run it, currently I
 often have to do:

 {{{#!hs
 #ifdef __GHCJS__
 foreign import javascript unsafe
     "foo()"
     foo :: IO ()
 #else
 foo :: IO ()
 foo = error "GHCJS required to use foo"
 #endif
 }}}

 Which is really noisy and annoying code to write, and it also does not
 help me with compiling external library code that does not do the above.
 It also pins me specifically to GHCJS and any future compiler that
 supports JS to any degree will need the code changed.

 The easiest solution to the problem seems to me to be a `-fdefer-ffi-
 errors` flag which replaces any unsupported ffi declaration with a runtime
 `error` call that gives a similar error message to the one currently given
 at compile time. I would also like a `-fdefer-ffi-errors-no-warn` flag to
 avoid my tooling complaining / emitting a bunch of warnings that don't
 actually help me much.

 This is not a very exciting request, but it would be a huge quality of
 life improvement for front end Haskell web development, and it does not
 seem overly difficult or dangerous to implement.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14227>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list