[英]Purescript inside Haskell code
I want to use a PureScript in the program code to generate text of JavaScript from it.我想在程序代码中使用 PureScript 来从中生成 JavaScript 文本。 For example, I use Julius (from Yesod) to directly insert a javascript.
例如,我使用 Julius(来自 Yesod)直接插入一个 javascript。 I want to use the same PureScript .Maybe there are such solutions or libraries?
我想使用相同的 PureScript 。也许有这样的解决方案或库? Thank you!
谢谢!
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).当我做了类似的事情时,我将 Purescript 源代码保存在单独的文件中,并在稍后(在构建期间或运行时)组合了 Haskell 和 Purescript 部分。 I think this is the easiest way, and you can keep using existing Purescript tools.
我认为这是最简单的方法,您可以继续使用现有的 Purescript 工具。
I had my web server read the JS output from purs
at runtime.我让我的 Web 服务器在运行时从
purs
读取 JS 输出。 Another option would be to use file-embed
to include the JS text when compiling the Haskell code.另一种选择是在编译 Haskell 代码时使用
file-embed
来包含 JS 文本。 One reason to prefer file-embed
is if you need to have a single executable file to deploy.首选
file-embed
一个原因是,如果您需要部署单个可执行文件。
Finally, I have a Makefile that builds the Purescript code, then the Haskell code.最后,我有一个构建 Purescript 代码的 Makefile,然后是 Haskell 代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.