Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
    Shao Cheng
    Improving the gc situation is among our top priorities btw

    Hiya friends, I've been taking a look at Asterius and am really amazed by how well everything already works! I'm currently trying to attach event listeners, but am running into some trouble:

    foreign import javascript "(${1}).addEventListener(${2}, ${3})" ffi_addEventListener :: JSVal -> JSString -> JSFunction -> IO ()

    This is my foreign import, and this is the wrapper I make around it:

    addEventListener :: DOMNode -> String -> (JSVal -> IO ()) -> IO ()
    addEventListener node eventName _callback = do
      -- Temporary, just trying to get *something* out of Haskell
      cb <- makeHaskellCallback (putStrLn "Got callback")
      ffi_addEventListener (coerce node) (toJSString eventName) cb

    Unfortunately, I never end up getting anything back...
    Whenever I change the ffi import to

    foreign import javascript "(${1}).addEventListener(${2}, () => { console.log((${3})()) } )" ffi_addEventListener :: JSVal -> JSString -> JSFunction -> IO ()

    I do in fact get a console message, but it's a Promise that has already resolved by then. Does this have something to do with laziness?

    It seems that GHC can’t figure out what to be lazy on when it comes to callback functions, modifyIORef', for example, works
    Shao Cheng
    @emiflake Hi, thanks for reaching out. I tried locally, and if you don't use putStrLn and instead import console.log as a Haskell function and make it a callback, it'll work.
    This is not related to laziness, our implementation of "standard output and error" in the browser is buggy, after the main thread exits, later writes to stdout/stderr buffers won't be affected to the actual browser console..
    We'll fix this problem and make the stdout/stderr buffer writes go to the actual console as soon as a line delimiter is detected in the buffer.
    Ah, thank you for your answer! This is exactly what I was able to reproduce as well earlier. Interesting. How active is development on Asterius still? I am currently playing around with a small library for web apps and it’s working really well, is the project still taking contributions?
    Shao Cheng
    It's still active, I'm working full time on it and would be glad to take contributions!
    I've been trying to compile Asterius from source on Nix, but I have had no success. Any tips on how to get it done? (I'm a nix newbie, but wanting to learn.) Ideally I would add the derivation if I succeed with creating it.
    Shao Cheng
    I know little nix myself so hard to tell how much remaining work it takes to full nix support.
    Ah, thank you! I'll keep on smashing my head against it until it compiles, maybe. Maybe that link will help.
    Anyone have any suggestions for how to patch the packages for those that are dependent on integer-gmp to make it run in austerius? More details : tweag/asterius#610
    Mike Solomon
    @TerrorJack is there a form of ghci for ahc (ie ahci)? I'd love to use
    something like rapid to prototype web projects in an ahci so that the process went faster. Thanks!
    Jack Armitage
    Hey, greetings from the tidalcycles.org community! We noticed that you list tidal as a package that compiles with asterius tweag/asterius#354
    Has anyone here tried to run/use tidal?
    We would be very excited to know
    Jack Armitage
    Trying to do ahc-cabal install tidal but Cabal- and hsc2hs both fail to install, the latter with openBinaryFile: does not exist (related? https://gitlab.haskell.org/ghc/ghc/issues/15758)
    cabal: Failed to build Cabal- The build process was killed (i.e.
    SIGKILL). The typical reason for this is that there is not enough memory
    available (e.g. the OS killed a process using lots of memory).
    Any ideas?
    Also the readme says "The image also ships ~2k prebuilt packages from a recent Stackage snapshot for convenience of testing simple programs without needing to set up a Cabal project.", but when I did import Sound.Tidal.Context it was not found. So maybe I'm confused about what the readme means
    Jack Armitage
    @TerrorJack i would also be interested to know the deal with ghci / ahci!
    Cristhian Motoche

    Hello! I usedahc-cabal to create a simple hello-world app (ahc-cabal init -p helloworld). After adding base to the build-depends, I build the project: ahc-cabal new-build && ahc-cabal new-install --installdir .. It worked but when I tried to use ahc-dist to generate the wasm file and the js files I got this error:

    root@5ec2d300a3d2:/workspace/hello# ahc-dist --input-exe helloworld
    ahc-dist: Out of memory

    I used the image with tag 200707 and I used podman.
    Please, let me know if I'm missing any step or if I'm doing something wrong.

    Chris Lavoie
    I've been trying to use asterius to generate code in a web worker -- it keeps dying with RuntimeError: returnFFIPromise: unsupported thread stopping reason 0 -- which looks to my untrained eye like a normal thread stopping point: success. The relevant somewhat minimal reproducible code is is at https://gist.github.com/christianlavoie/db264f799ef10638d102259e10d188f4 and https://gist.github.com/christianlavoie/06254660f118fb718909f448ff1273d5. Thoughts?
    Ramakrishnan Muthukrishnan

    Trying to cross compile a library to wasm. During the ahc-dist step, it fails with:

    [wasm-validator error in function networkzm3zi1zi2zi0zm93370f294a5ccad85a2ba1fe91dc1b8fe0ad85f859334db533820874b4f0b8f5_NetworkziSocketziTypes_.LsklD] unexpected false: non-final block elements returning a value must be drop()ed (binaryen's autodrop option might help you)

    I am running the ahc-dist this way: stack exec -- ahc-dist --browser --input-exe ./hocus-pocus

    Any help in resolving this appreciated. Thanks.