0
votes

I have seen an example where you define the tuple type in this way:

countRepetitions :: (Integral a, Integral (a,a)) => [a] -> a -> (a,a)

But when I execute the code appears the message: Non type-variable argument in the constraint: Integral (a, a) How can I declare a tuple type?

1
What do you mean with "declare a tuple type"? Actually it rather weird to state this because a tuple is not really integral: it is hard to convert it to a nice "Integer"...Willem Van Onsem
It's not hard, but not particularly useful here.chepner

1 Answers

1
votes

You don't need to constraint with Integral (a, a). The constraint Integral a forces all values for type a to be Integral. Try rewriting it like this:

countRepetitions :: Integral a => [a] -> a -> (a,a)