首页 > 解决方案 > 如何找出运算符“+”的类型?

问题描述

在 GHCi 版本 8.6.3 ( https://repl.it/languages/haskell ) 中,我想知道如何找出运算符“+”的类型。我想看看它的类型是num a, b,c => a -> b -> cor num a, b,c => (a,b) -> c

但我找不到它的类型。它还会以未知的方式影响下一个表达式。为什么我会失败,那我该怎么办?

   :type +
   :type not
<interactive>:1:1: error: parse error on input ‘+’
   :type not
not :: Bool -> Bool
=> "12"

标签: haskell

解决方案


这边走:

> :type (+)
(+) :: Num a => a -> a -> a

并且

> :t (+) 4
(+) 4 :: Num a => a -> a

> :t (+) 4 3
(+) 4 3 :: Num a => a

推荐阅读