haskell - 如何找出运算符“+”的类型?
问题描述
在 GHCi 版本 8.6.3 ( https://repl.it/languages/haskell ) 中,我想知道如何找出运算符“+”的类型。我想看看它的类型是num a, b,c => a -> b -> c
or num a, b,c => (a,b) -> c
。
但我找不到它的类型。它还会以未知的方式影响下一个表达式。为什么我会失败,那我该怎么办?
:type +
:type not
<interactive>:1:1: error: parse error on input ‘+’
:type not
not :: Bool -> Bool
=> "12"
解决方案
这边走:
> :type (+)
(+) :: Num a => a -> a -> a
并且
> :t (+) 4
(+) 4 :: Num a => a -> a
> :t (+) 4 3
(+) 4 3 :: Num a => a
推荐阅读
- nginx - Nginx - 反向代理 - 404
- svg - 我需要一种更好的方法来使用 SVG 路径绘制字母
- azure-pipelines - 如何从 Azure Pipelines 表达式访问机密值?
- javascript - 将 javascript 循环转换为异步和函数式
- amazon-web-services - 在同一个 AWS EC2 实例上提供多个 Python 应用程序
- java - 在 Java 中迭代 2 个地图
- python - 无法使用 Windows Ubuntu 应用程序连接到 Docker
- r - 使用数据表将一个函数应用于具有参数值向量的多列
- python - 字典的性能优化更改
- algorithm - n^0.000001 和 log(n) 等的大 O 复杂度比较