compilation - 如何理解 idris 中的 SDecl?
问题描述
我正在为 idris 编写后端,idris 代码(缩写)
main = putStrLn "hello"
生成了这个:
(SLet
(Loc 1)
(SLet
(Loc 1)
(SConst "hello\n")
(SOp LWriteStr [Loc 0,Loc 1]))
(SCon Nothing 0 MkUnit [])
)
那里怎么理解Loc n
?这与德布鲁金指数有关吗?
解决方案
这是 a SExp
,不是 aTT
所以它还没有被 de Bruijn 化:
Module : IRTS.Simplified
Description : Simplified expressions, where functions/constructors can only be applied to variables.
SLoc n
只是一个生成的标识符,因此在您的示例中,内部SLet
确实遮蔽了外部(未使用)SLet
;它可以加糖成
let v1 = let v1 = "hello\n" in writeStr v0 v1
in v1
或者,为变量分配唯一名称,以
let v1 = let v2 = "hello\n" in writeStr v0 v2
in v1
请注意,此片段中未绑定Loc 0
to 的参数;LWriteStr
我想这将是IO
传递给的世界令牌main
,所以整个main
将是
\v0 => let v1 = let v2 = "hello\n" in writeStr v0 v2 in v1
推荐阅读
- python - 如何创建字典值是字典列表的字典?
- twilio - 如何设置与多对人的 Twilio SMS 对话
- testing - symfony 4 - 针对不同数据测试命令
- java - 无法弄清楚为什么 java 在 if else 语句之后忽略了我的 print 语句
- sqlite - 无法在 SQLite 中创建新表,在表名附近出现错误
- git - 恢复推送的合并以删除错误推送的本地不需要的更改
- netlogo - 为什么 NetLogo 中的邻居补丁不以海龟位置为中心?另外,在邻居处设置“目标”时,为什么不互惠?
- docker - Docker Build 抛出错误-“Docker 输出被剪裁,日志限制达到 1MiB”
- grid-search - 为什么 GridSearchCV 中每个任务的时间在估计期间会增加?
- python - 在python 3中猜数字游戏