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 6758689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:49:50+00:00 2026-05-26T13:49:50+00:00

Hey everyone i am trying to write this code and I am having problems

  • 0

Hey everyone i am trying to write this code and I am having problems with the data types

data Collection = Set [Int] deriving (Show)

remove :: Int -> Collection -> Collection
remove _ (Set []) = (Set [])
remove numberToRemove (Set (x:xs))
    |x == numberToRemove = (Set xs)
    |otherwise = Set ([x]:remove numberToRemove xs)

I am getting this error, its a problem with the types:

 Couldn't match expected type `Int' with actual type `[t0]'
In the first argument of `(:)', namely `[x]'
In the first argument of `Set', namely
  `([x] : remove numberToRemove xs)'
In the expression: Set ([x] : remove numberToRemove xs)
Failed, modules loaded: none.

Any help is appreciated
Thanks

  • 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-26T13:49:51+00:00Added an answer on May 26, 2026 at 1:49 pm

    First problem, in the expression:

    Set ([x] : remove numberToRemove xs)
    

    The head of the list (before : ) must be an Int, not a [Int], replace with:

    Set (x : remove numberToRemove xs)
    

    Then, a second problem. In the same expression, the sub-expression:

    remove numberToRemove xs
    

    is a Collecion, but there must be a [Int] after the operator : so, a possible solution:

    data Collection = Set [Int] deriving (Show)
    
    col_to_list :: Collection -> [Int]
    col_to_list (Set xs) = xs
    
    remove :: Int -> Collection -> Collection
    remove _ (Set []) = (Set [])
    remove numberToRemove (Set (x:xs))
        |x == numberToRemove = (Set xs)
        |otherwise = Set (x : col_to_list (remove numberToRemove (Set xs)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey everyone, I am having a problem with a website I'm trying to build;
Hey everyone I've looked for hours trying to find a solution to this, my
Hey everyone, I am trying to hide/show different html elements (div, etc...) based on
Hey everyone, I am trying to run the following program, but am getting a
Hey everyone. I'm trying to make a swing GUI with a button and a
Hey everyone, my first time trying to draw a multi-color gradient in actionscript 3.
Hey everyone. The following is the code that I am using to play random
Hey everyone, I am trying to figure out a way to query my mysql
Hey everyone, my problem is that im trying to figure out how to get
Hey everyone. I'm not big into UI programming so this may be an easy

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.