a ->-6ren">
gpt4 book ai didi

haskell - 如何找出运算符 "+"的类型?

转载 作者:行者123 更新时间:2023-12-04 22:54:29 25 4
gpt4 key购买 nike

在 GHCi 8.6.3 ( https://repl.it/languages/haskell ) 中,我想知道如何找出运算符“+”的类型。我想看看它的类型是不是num a, b,c => a -> b -> cnum 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

关于haskell - 如何找出运算符 "+"的类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57028635/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com