You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Idris 2中选择命名实现的对应语法是什么?

Idris 2 替代 Idris 1 using implementation 的语法

Idris 1 中的 using implementation 语法可用于为代码块指定默认实现,Idris 2 已移除该语法,改用 default 关键字实现相同功能。

你尝试的 Idris 1 风格代码:

using implementation Any
  tick1 : Time -> Writer Bool Time
  tick1 t = pure t

会触发如下解析错误:

`-- src/HL2/Clock.idr line 14 col 0:
     Expected end of input.
     
     HL2.Clock:14:1--14:6
      14 | using implementation Any
           ^^^^^

Idris 2 的正确写法:

default Any
  tick1 : Time -> Writer Bool Time
  tick1 t = pure t

default 关键字后紧跟目标实现名称,缩进范围内的代码块会默认使用该实现,功能与 Idris 1 的 using implementation 完全一致。

内容的提问来源于stack exchange,提问作者Cactus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 05:12:30