I am trying to define a function that will concatenate two tuples of (Int, Char) like this:
tupleCat :: (Integral a, Char b )=> (a, b) -> (a, b) -> (a, [Char])
tupleCat (x1, y1) (x2, y2) =(x1+ x2, [y1] ++ [y2])
However, I get the following error message:
Type constructor `Char' used as a class ...
What am I doing wrong?
Charis no type class, it is a type:And if you really want
Ints and not anIntegral, they are types, too:Further, you might consider to make this a new type and to implement the Monoid type class (as suggested in the comments). One possibility would be
With this definition
tupleCatbecomes simplymappend. Then you can e.g. concatenate theCats in everyFoldable(e.g. a list). Of course I don’t know your intentions, so this is just a educated guess.