Is it possible to compile HLS to work with JS/WASM backends? If not, what are the main obstacles?
In principle I think it could work if you have a cross GHC in scope and cabal set up to build your project cross, but I don’t think it’s been tried much so I would guess it’s broken for some reason.
HLS is a GHC API program, for it to work for cross targets you need a special HLS build that links against ghc
package that’s configured for that specific target. If you manage to build HLS this way, it may work for simple projects that doesn’t involve Template Haskell (disclaimer: I haven’t been able to build such an HLS myself yet, cabal
gets really confused if you try to pass custom package database in a hadrian build directory)
It’s even more complex when the project involves TH. Each cross target requires specific hacks and setups to make TH work and I won’t be surprised at all if HLS will choke at TH splices. For wasm backend, TH hasn’t been implemented yet but I’m slowly working at it, with some luck something simpler like ghcid
may work for wasm projects first.