2
votes

I want to use a PureScript in the program code to generate text of JavaScript from it. For example, I use Julius (from Yesod) to directly insert a javascript. I want to use the same PureScript .Maybe there are such solutions or libraries? Thank you!

1
You, basically, want a Purescript quasiquoter. This should be pretty easy to make up.arrowd
But I also need a compilation into the Javascript's text.QSpider
This is essentially asking how to write a compiler/interpreter for Purescript in Haskell targeting Javascript. This is much too broad for a SO question.user2407038

1 Answers

1
votes

When I have done something similar, I've kept the Purescript source in separate files, and combined the Haskell & Purescript parts later (during the build or at runtime). I think this is the easiest way, and you can keep using existing Purescript tools.

I had my web server read the JS output from purs at runtime. Another option would be to use file-embed to include the JS text when compiling the Haskell code. One reason to prefer file-embed is if you need to have a single executable file to deploy.

Finally, I have a Makefile that builds the Purescript code, then the Haskell code.