Haskell 脱糖策略

发布于 2024-10-09 09:12:46 字数 264 浏览 6 评论 0原文

我正在为纯函数式程序开发虚拟机,并且我希望能够测试和使用现有的各种 Haskell 模块。 VM 本质上采用无类型 lambda 演算中的项作为输入。我想知道从现代 Haskell 模块中提取这种表示的好方法是什么(例如使用 MPTC、模式防护等)。我做了一些研究,似乎还没有一个工具可以做到这一点(我很高兴被弄错),但这没关系。我正在寻找一种方法。

GHC Core 似乎过于注重操作,特别是因为 VM 所做的事情之一就是显着改变评估顺序。是否有更接近 lambda 演算的可访问中间表示形式?

I'm developing a virtual machine for purely functional programs, and I would like to be able to test and use the the wide variety of Haskell modules already available. The VM takes as input essentially terms in the untyped lambda calculus. I'm wondering what would be a good way to extract such a representation from modern Haskell modules (eg. with MPTC's, pattern guards, etc.). I did a little research and there doesn't seem to be a tool that does this already (I would be delighted to be mistaken), and that's okay. I'm looking for an approach.

GHC Core seems too operationally focused, especially since one of the things the VM does is to change the evaluation order significantly. Are there any accessible intermediate representations that correspond more closely to the lambda calculus?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

凉城凉梦凉人心 2024-10-16 09:12:46

GHC 的外部核心与使用 GHC 得到的 lambda 演算非常接近。 此处 是直接指向表达式类型的链接。

The External Core for GHC is about as close to the lambda calculus as you're going to get, using GHC. Here is a link straight to the expression type if you want to jump right in.

  • Library for processing external core files
  • How to generate external core with GHC
  • An academic paper on its use
泛滥成性 2024-10-16 09:12:46

EHC过去在表示之间具有这种流动:

HS -> H EH->核心->咧嘴一笑-> Silly

HS 显然是 Haskell,EH 糖分较少并由类型检查器使用,Core 与 GHC 的 Core 类似,Grin 和 Silly 的级别比它低。

Jeroen Fokker 有一篇描述 EHC 架构的论文,我抄袭了上面的内容,但它可能已经过时了(我不知道 EHC 仍然使用 Silly 表示)。我认为 EHC 为其每个内部表示提供了解析器和漂亮的打印机,这会很方便。

还有来自 YHC 的 York.Core,我看到人们对它的评价比 GHC Core 更好,但我不知道是否有一种方法可以将“现代”Haskell 编译成 York.Core。

EHC used to have this flow between representations:

HS -> EH -> Core -> Grin -> Silly

HS is obviously Haskell, EH is less sugary and used by the type checker, Core is the analogue to GHC's Core and Grin and Silly are lower level than that.

There is a paper describing EHC's architecture by Jeroen Fokker, where I've cribbed the above from, but it's probably out of date (I don't know that EHC still uses the Silly representation). I think that EHC provides parsers and pretty printers for each of its internal representations, which would be handy.

There's also York.Core from YHC which I've seen people speak more favorably of then GHC Core, but I don't know if there is a means of compiling "modern" Haskell into York.Core.

因为看清所以看轻 2024-10-16 09:12:46

嗯...听说过 Haskell 内核 吗?我不确定你需要什么。它是某种脱糖的 Haskell,本质上是在 Haskell 报告中定义的。我不确定这是否是您所需要的。

Hm... Ever heard of the Haskell Kernel? I'm not sure what you need. It's some kind of desugared Haskell, and is essentially defined in the Haskell report. I'm not sure whether this is what you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文