[英]Haskell point-free compilation type
So I'm really new to Haskell, but I was playing around with the point free notation and came across this issue. 所以我对Haskell来说真的很新,但我正在玩点免费符号,并遇到了这个问题。 I'm in the console: 我在控制台:
> let c = (.)negate
> :t c
> (a -> Integer) -> a -> Integer -> a
but negate takes a Number, so why is it being constrained to an Integer type? 但是否定取一个数字,为什么它被约束为一个整数类型?
This is another case of the extended defaulting rules in GHCi. 这是GHCi中扩展违约规则的另一个案例。 Do :set -XNoMonomorphismRestriction
or just do 做:set -XNoMonomorphismRestriction
或者只做
> :set +m -- multiline input in GHCi
> let c :: (Num a) => (b -> a) -> b -> a -> b
| c = (.) negate
|
> :t c
Num a => (b -> a) -> b -> a -> b
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.