如何用类约束手动计算功能的类型?
以下功能应用程序的键入规则
f :: A -> B
e :: A
-----------
f e :: B
没有考虑到类约束的f
。我如何手动计算类型,例如:
(+) :: Num a => a -> a -> a
3 :: Int
---------------------------
(+) 3 :: ?
The following typing rule for function application
f :: A -> B
e :: A
-----------
f e :: B
doesn't take into account an f
with class constraints. How can I manually calculate the type of, for example:
(+) :: Num a => a -> a -> a
3 :: Int
---------------------------
(+) 3 :: ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于:
我们知道
a
(第一个参数)与int
(3
的类型)相同,因此这意味着<代码> a〜int (a
和int
是相同的类型),因此这意味着:由于
int
是成员在num
typeclass中,我们可以删除num Int =&gt;
,从而获得:For:
We know that
a
(the first parameter) is the same type asInt
(the type of3
), so that means thata ~ Int
(a
andInt
are the same type), so that means that:Since
Int
is a member of theNum
typeclass, we can removeNum Int =>
, and thus obtain: