
Hello, I'm a maintainer and creator of GHCJS tool [1]. GHCJS currently uses GHC API to produce Javascript code from Haskell sources. There is a great interest to the project, but there have been little progress recently. I'm considering the future of it and I'd like to get some advices or suggestions from GHC maintainers. GHCJS originally was fork of GHC 6.6 with javascript generation built in. Since javascript generation is very experimental, I wasn't trying to push it into GHC mainline. Besides it was expressed several times [2] that GHC HQ doesn't want to support another backend which brings lots of interoperability problems with it. Since then GHCJS switched to GHC API. For now code generation works decently well. But I have many problems that I'd like to solve and I'm not sure if it is feasible using GHC API, == Command line interface == I'd like to reproduce GHC command line interface for GHCJS tool. For now I'm using something like this: main :: IO () main = do args <- getArgs defaultErrorHandler defaultDynFlags $ runGhc (Just GHC.Paths.libdir) $ do sdflags <- getSessionDynFlags (dflags, fileargs, _) <- parseDynamicFlags sdflags (map noLoc args) _ <- setSessionDynFlags dflags let fileargs' = map unLoc fileargs targets <- mapM (flip guessTarget Nothing) fileargs This works, but I'm not allowed to parse some custom flags used by GHCJS code and not by GHC API. ParseDynamicFlags throws UsageError if it encounters some unknown flags. What can I do to extend GHC's command line arguments' syntax with some custom arguments used by GHCJS? I can parse arguments myself and throw the rest of them to parseDynamicFlags, but GHC's flags are really complicated and I'm not aware of any argument parsing library that can be used to filter out some specified flags and return the rest GHC's flags untouched. == Foreign Function Interface == What I want is to provide FFI for Javascript, But GHC doesn't allow to extend FFI declaration syntax. I'd like to create some new FFI calling convention ("javascript") like this: foreign import javascript "alert" jsalert :: Ptr JSString -> IO () But GHC always emit parse error on "javascript" keyword. For now I'm using (abusing) ccall calling convention and simple imports works pretty well, but I would like to support exports and static/dynamic wrappers. GHC generates C-code to support them, and GHCJS should generate Javascript-code, but I have no idea how to use GHC API to generate custom (Javascript) stubs. Is it possible at all? == Packages support == It will be very handy if users can use Cabal to install and build packages with GHCJS. It should work if I replicate ghc and ghc-pkg command line interface, but remaining problem is that package index and package directories will be shared with GHC, I'd like to create ghcjs and ghcjs-pkg tools that will use their own directories and package index and will not interfere with ghc. Is it possible with GHC API? How can I do it? [1] https://github.com/sviperll/ghcjs [2] http://www.haskell.org/haskellwiki/GHC:FAQ#Why_isn.27t_GHC_available_for_.NE... -- Victor Nazarov