tuple :: (Integer a,Fractional b) => (a,b,String)
tuple = (18,5.55,"Charana")
所以这给了我错误
‘Integer’ is applied to too many type arguments
In the type signature for ‘tuple’:
tuple :: (Integer a, Fractional b) => (a, b, String)
为什么会这样?
答案 0 :(得分:7)
Integer是Haskell中的具体类型,而Integral是一个类型类,用于表示可以表示为整数的事物。因此,您可以选择写:
tuple :: Fractional a => (Integer,a,String)
tuple = (18,5.55,"Charana")
或
tuple :: (Integral a,Fractional b) => (a,b,String)
tuple = (18,5.55,"Charana")
答案 1 :(得分:4)
Integer
只是一种类型。
tuple :: Fractional a => (Integer, a, String)
或许您打算使用Integral a
?