Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6075327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:28:56+00:00 2026-05-23T10:28:56+00:00

I am trying to define a function that will concatenate two tuples of (Int,

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:28:57+00:00Added an answer on May 23, 2026 at 10:28 am

    Char is no type class, it is a type:

    tupleCat :: (Integral a) => (a, Char) ->  (a, Char) -> (a, [Char])
    tupleCat (x1, y1) (x2, y2) =(x1 + x2, [y1] ++ [y2])
    

    And if you really want Ints and not an Integral, they are types, too:

    tupleCat :: (Int, Char) ->  (Int, Char) -> (Int, [Char])
    tupleCat (x1, y1) (x2, y2) =(x1+ x2, [y1] ++ [y2])
    

    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

    newtype Cat = Cat (Int, String)
    
    instance Monoid Cat where
      mempty = Cat (0, [])
      mappend (Cat (i1,s1)) (Cat (i2,s2)) = Cat (i1 + i2, s1 ++ s2)
    

    With this definition tupleCat becomes simply mappend. Then you can e.g. concatenate the Cats in every Foldable (e.g. a list). Of course I don’t know your intentions, so this is just a educated guess.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to define a delegate function that will return an IEnumerable. I'm having
I am trying to define a function that will include a variable n where
I am trying to figure out how to define a function that works on
I'm trying to dynamically define functions that call through to another function that takes
I am trying to define a WCF contract that returns an interface, something like
I am trying to make a function in C that will print a string
I'm trying to create a custom patch for Quartz Composer that will function just
I'm trying to code a user defined function under SQL Server 2005 that will
I am trying to use this code to define the APIs that are needed
I'm trying to develop a Scheme function that will take a graph as defined:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.