WASM compatibility
As suggested in https://github.com/jgm/typst-hs/pull/72 , it is better to migrate to a more lightweight XML library for XML parsing, than to drop this feature completely for WASM compat. I've changed the XML library from xml-conduit to xml, and the test suite passed. Now typst works with the WASM backend.
Before making this change, I'd like to have a clearer idea of how a wasm typst plugin could make productive use of this library. After all, this library was designed to parse typst in Haskell, but if you're already working in the rust/typst ecosystem, aren't there better tools?
The WASM interface for Typst plugins acts by passing byte arrays around and is quite low level.
Using types and tools provided in this library, you can reify Typst values as in Typst.Types from and to byte arrays with some boilerplate code, thus allowing you to directly write high level Haskell code that manipulate Typst values and compile them to valid Typst plugins.
This enables you to write Typst plugins using Haskell in a high-level way, adding Haskell tools to the Typst ecosystem, and I consider this really valuable.
One more thing you could try that wouldn't require changes here. In https://github.com/haskell-wasm/pandoc/commit/336228bb8d5e9bf35750cfe6b546ffb4bcd86c15 they use a special modified version of xml-conduit (see cabal.project) that apparently compiles with wasm. You could try adding this to your cabal.project and see if typst-hs compiles to wasm without modifications.
I'm not necessarily against moving to xml-light, but there are XML files that this library can't handle, and it's also quite a bit slower.
I tried adding the lines:
source-repository-package
type: git
location: https://github.com/haskell-wasm/xml
subdir: xml-conduit
to the cabal.project file. It seems that this repository is successfully pulled from the remote, but building with the WASM backend still failed due to network. I also tried the lines:
source-repository-package
type: git
location: https://github.com/haskell-wasm/network
subdir: .
to directly depend on the version of network claimed to be compatible with WASM. However, this repository doesn't build at all with either backend on my device. It seems to require a file called configure in the project root, generated by autoconf -i. However, even if I have generated that file, running cabal build or cabal configure in that project deletes the script and then compiles about its nonexistence, which I don't understand. I am going to open an issue in that network fork for this.