- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Idris 中将幺半群定义为
interface Is_monoid (ty : Type) (op : ty -> ty -> ty) where
id_elem : () -> ty
proof_of_left_id : (a : ty) -> ((op a (id_elem ())) = a)
proof_of_right_id : (a : ty) -> ((op (id_elem ())a) = a)
proof_of_associativity : (a, b, c : ty) -> ((op a (op b c)) = (op (op a b) c))
interface (Is_monoid ty op) => Is_group (ty : Type) (op : ty -> ty -> ty) where
inverse : ty -> ty
proof_of_left_inverse : (a : ty) -> (a = (id_elem ()))
When checking type of Group.proof_of_left_inverse:
Can't find implementation for Is_monoid ty op
最佳答案
错误信息有点误导,但实际上,编译器不知道 Is_monoid
的哪个实现用于您调用 id_elem
在您对 proof_of_left_inverse
的定义中.您可以通过使其调用更明确来使其工作:
proof_of_left_inverse : (a : ty) -> (a = (id_elem {ty = ty} {op = op} ()))
interface Pointed a where
x : a
origin : (Pointed b) => b
origin = x
x
可以认为是一个函数
x : {a : Type} -> {auto p : PointedImpl a} -> a
PointedImpl
是一些伪类型,表示
Pointed
的实现. (想想函数的记录。)
origin
看起来像
origin : {b : Type} -> {auto j : PointedImpl b} -> b
x
尤其是有两个
隐式参数 ,编译器试图在类型检查和统一期间推断。在上面的例子中,我们知道
origin
必须返回
b
,所以我们可以统一
a
与
b
.
i
也是
auto
,因此它不仅需要统一(这在这里没有帮助),而且如果没有明确指定,编译器还会寻找可以填补该漏洞的“周围值”。首先要查看我们没有的局部变量是参数列表,我们确实在其中找到了
j
。 .
origin
无需我们显式指定任何其他参数即可解决。
interface Test a b where
x : a
y : b
test : (Test c d) => c
test = x
x : {a : Type} -> {b -> Type} -> {auto i : TestImpl a b} -> a
test : {c : Type} -> {d -> Type} -> {auto j : TestImpl c d} -> c
a
和
c
,但没有什么能告诉我们
d
应该是。具体来说,我们无法将其与
b
统一起来。 ,因此我们无法统一
TestImpl a b
与
TestImpl c d
因此我们不能使用
j
作为
auto
的值-参数
i
.
关于idris - 在 Idris 中定义组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59582709/
我正在学习 Idris 并且我陷入了一个非常简单的引理,该引理表明某些特定索引对于数据类型是不可能的。我尝试使用不可能的模式,但 Idris 拒绝使用以下错误消息: RegExp.idr line 3
灵感来自 this blog post和 this code我想我会使用 Idris 的接口(interface)(类型类)在 Idris 中尝试一些类别理论。 我定义了Category如下,效果很好
借此我可以构建一个匿名的临时记录;那是可编辑的、可附加的、可修改的,其中每个值可以具有不同的异构类型,以及编译器检查消费者类型期望是否与所有给定键处生成的记录的类型一致? 类似于 Purescript
是否有一种简单的方法可以为数据类型编写相等 ( DecEq ) 实例?例如,我希望下面的 DecEq 中有 O(n) 行声明,其中 ?p很简单: data Foo = A | B | C | D in
是否有任何关于 postulate 的性质和用途的最新信息?在 idris build ?教程/手册中没有关于该主题的任何内容,我似乎也无法在 wiki 中找到任何内容。 TIA。 最佳答案 我认为我
在玩了一下 Idris 及其效果教程示例后,我终于弄清楚了如何链接效果。不确定链是否是正确的词,但我基本上是指一种效果是根据另一种效果实现的。 在这个例子中,我有一个效果,我称之为 Lower。它直接
Idris 中是否存在有理数的现有实现? 例如Data.Ratio 来自 Haskell 的端口。 最佳答案 通过快速搜索,我找到了 this , 如果它可能很有趣 关于idris - Idris 中
在官方 Idris wiki 上的非官方常见问题解答(官方是因为它在该语言的 git 仓库中),它是 stated that in a total language [e.g. Idris] we d
我在看 Idris tutorial .我无法理解以下代码。 disjoint : (n : Nat) -> Z = S n -> Void disjoint n p = replace {P = d
在 Idris 中定义我们在其他语言中称为常量的惯用方式是什么?是这个吗? myConstant : String myConstant = "some_constant1" myConstant2
在 idris 0.9.17.1 中, 灵感来自 https://wiki.haskell.org/Prime_numbers , 我编写了以下代码来生成素数 module Main concat:
我编写了一个函数doSomething,它接受一个左括号或右括号并返回相应的Int: doSomething : (c : Char) -> {auto isPar : c == '(' || c =
这实际上是我的第一行 Idris 代码。当我查阅文档时,一切都显得正确: Idris> data T = Foo Bool | Bar (T -> T) (input):1:6: | 1 | da
我正在使用 Idris 进行类型驱动开发,学习如何定义具有可变数量参数的函数。我有点野心,想写一个 mapN将映射 (n : Nat) 的函数的函数参数到 n一些 Applicative 的值类型。
我正在尝试编写一个函数 mSmallest需要两个自然数,n和 m作为输入并产生一个向量。输出向量包含 m有限集的最小成员 n成员。 例如 mSmallest 5 3应该生产 [FS (FS Z),
我在 Idris 中将幺半群定义为 interface Is_monoid (ty : Type) (op : ty -> ty -> ty) where id_elem : () -> ty
我正在阅读 Type driven development with Idris ,其中一个练习要求读者定义一个类型 TupleVect ,这样一个向量可以表示为: TupleVect 2 ty =
试图证明以下断言: equalityCommutesNat : (n : Nat) -> (m : Nat) -> n = m -> m = n 我找到了 plusCommutes在图书馆里,但没有平
为什么 Idris 要求函数按照定义的顺序出现,并使用 mutual 声明的相互递归? 我希望 Idris 执行函数之间的第一次依赖分析,并自动对它们进行重新排序。我一直相信 Haskell 是这样做
我一直无法让 Idris 整体检查器相信我的功能是完整的。这是我遇到的问题的一个简单示例版本。假设我们有一个如下形式的非常简单的表达式类型: data SimpleType = Prop | Fn S
我是一名优秀的程序员,十分优秀!