Charana
Charana

Reputation: 1072

Haskell difficulty with type signature for a variable

tuple :: (Integer a,Fractional b) => (a,b,String)
tuple = (18,5.55,"Charana")

So this is giving me the error

‘Integer’ is applied to too many type arguments
In the type signature for ‘tuple’:
tuple :: (Integer a, Fractional b) => (a, b, String)

Why is this?

Upvotes: 2

Views: 76

Answers (2)

jazmit
jazmit

Reputation: 5420

Integer is a concrete type in Haskell, whereas Integral is a typeclass used to denote things which can be represented as an integer. As such, you could choose to write:

tuple :: Fractional a => (Integer,a,String)
tuple = (18,5.55,"Charana")

or

tuple :: (Integral a,Fractional b) => (a,b,String)
tuple = (18,5.55,"Charana")

Upvotes: 7

Ry-
Ry-

Reputation: 225238

Integer is just a type.

tuple :: Fractional a => (Integer, a, String)

Or maybe you meant to use Integral a?

Upvotes: 4

Related Questions