tweag/asterius

--export-function doesn't work with ahc-dist

gelisam opened this issue · 2 comments

Describe the bug
When using foreign export javascript to export a Haskell function, the function appears in __asterius_jsffi.exports if the code is compiled with ahc-link, but not if it is compiled with ahc-dist.

To Reproduce

I wrote a short program which exports mult_hs and then checks if __asterius_jsffi.exports.mult_hs exists:

$ cat Example.hs
{-# LANGUAGE ForeignFunctionInterface #-}

foreign export javascript "mult_hs" (*) :: Int -> Int -> Int

foreign import javascript "console.log(__asterius_jsffi.exports.mult_hs)" js_print_exports :: IO ()

main :: IO ()
main = js_print_exports

$ cat example.cabal
cabal-version:      2.4
name:               example
version:            0.1.0.0

executable example-exe
    main-is:          Example.hs
    build-depends:    base
    hs-source-dirs:   .

Inside the asterius image, I then compile and run that code using ahc-link and ahc-dist, and get two different results:

# ahc-link --input-hs Example.hs --export-function mult_hs --run
[...]
[AsyncFunction: cb]

# ahc-cabal new-install --installdir=. example-exe
[...]
Symlinking 'example-exe' to './example-exe'
# ahc-dist --input-exe example-exe --export-function js_greet --run
[...]
undefined

Expected behavior

I expected the ahc-dist command to produce [AsyncFunction: cb] as well.

Environment

  • OS name + version:
    $ uname -a
    Linux monolith 5.16.20-100.fc34.x86_64 #1 SMP PREEMPT Wed Apr 13 22:10:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
    
  • Version of the code: terrorjack/asterius:210111

Any updates? Stuck on the same problem here.

xhliu commented

Same here.