考虑这个例子:
applyKTimes :: Integral i => i -> (a -> a) -> a -> a
applyKTimes 0 _ x = x
applyKTimes k f x = applyKTimes (k-1) f (f x)
applyThrice :: (a -> a) -> a -> a
applyThrice = applyKTimes 3applyThrice中的3由GHC缺省为Integer,如使用-Wall编译时所示
Warning: Defaulting the following constraint(s) to type 'Integer'
'Integral t'
arising from a use of 'applyKTimes'所以我猜Integer是默认的Integral a => a。
-Wall..)时,它确实会抱怨
https://stackoverflow.com/questions/2861988
复制相似问题