Haskell 运行时如何表示惰性值?

How does Haskell runtime represent lazy values?

这个问题我都不知道怎么表达了。 假设有一个指向未计算表达式的指针。如果它被请求(通过一些强制它的严格函数),那么指针值将被评估的值替换。正确的?我错了吗?

所以我假设每个指针都有一个标志,说明它是否已被评估。

如果评估是未定义的,比如空列表的头部怎么办? “指针”中存储了什么?

I assume there's a pointer to a non evaluated expression. If it's requested (by some strict function that coerces it) then the pointer value is replaced by the value evaluated. Right? Am I wrong?

这就是它的要点。

So I assume every pointer has a flag stating if it has been evaluated or not.

每个指针都指向某个结构,您可以在其中找到此类信息。

And what if the evaluation is undefined, like the head of an empty list? What is stored in the "pointer"?

指针指向其计算抛出异常的表达式。

详情在GHC wiki的以下页面;具体参见“对象类型”:https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/rts/storage/heap-objects

数据构造函数、函数闭包、thunk(“未计算的表达式”)是主要的。