多态推理 [英] Polymorphic reasoning

查看:43
本文介绍了多态推理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Haskell,在互联网上,我发现是来自Philip Wadler.
我读了它,一点也不理解,但是它以某种方式连接到了多态函数.

I am learning Haskell and in internet I've found is paper from Philip Wadler.
I read it and did not understand at all, but it somehow connects to polymorphic function.

例如:

polyfunc :: a -> a -> a

它是任何类型的多态函数.

It is a polymorphic function of any type.

示例 polyfunc 的自由定理是什么?

What is the free theorem in connection of the example polyfunc?

推荐答案

我觉得,如果我真正理解了这篇论文,那么我写的任何代码都将由上帝共同创作.

I feel like if I actually understood that paper then any code I wrote would be coauthored by God.

我对这个问题的最佳猜测是,所有 polyfunc 可以做的就是要么总是返回第一个参数,要么总是返回第二个参数.因此,实际上只有两种实现 polyfunc

My best guess for this problem though is that all polyfunc can do is either always return the first argument or always return the second argument. So there are actually only two implementations of polyfunc,

polyfuncA a _ = a
polyfuncB _ b = b

本文为您提供了证明这一主张的方法.

The paper gives you a way to prove that claim.

这是一个非常重要的概念.例如,我以前参与过数据质量研究.这个自由定理说,没有函数可以从任意两个数据中选择最佳数据.我们必须知道更多.实际上,我很惊讶地发现有些人愿意忽略它,这真是理所当然.

This is a very important concept. For example, I've been involved in data quality research previously. This free theorem says that there is no function which can select the best data from two arbitrary pieces of data. We have to know something more. Its actually a no-brainer that I was surprised to find some people willing to overlook.

这篇关于多态推理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆