Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

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

Open
gelisam opened this issue May 23, 2022 · 2 comments
Open

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

gelisam opened this issue May 23, 2022 · 2 comments

Comments

@gelisam
Copy link

gelisam commented May 23, 2022

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
@freedomhero
Copy link

Any updates? Stuck on the same problem here.

@xhliu
Copy link

xhliu commented Sep 20, 2022

Same here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants