什么 =>在类型签名中意味着什么? [英] What does => mean in a type signature?

查看:36
本文介绍了什么 =>在类型签名中意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始向你学习 Haskell,我在一个没有解释的例子中看到了这个:

tell :: (Show a) =>[a] ->细绳

这是什么意思,特别是 =>?我知道如果我替换 -> 或删除它就行不通,但我真的不明白为什么.

解决方案

这是对类型的约束,意味着 a 应该是类 Show 的一个实例.

参见此处

I just starting Learn you a Haskell, and I saw this used in an example without explanation:

tell :: (Show a) => [a] -> String

What does this mean, in particular the =>? I know it won't work if I substitute -> or delete it, but I don't really understand why.

解决方案

It's a constraint on the type, means a should be an instance of class Show.

see for example here

这篇关于什么 =>在类型签名中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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