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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:09:27+00:00 2026-06-07T23:09:27+00:00

I write a code to sort index of tuple list I try to use

  • 0

I write a code to sort index of tuple list I try to use map with bubblesort()
to avoid using loops

     bubblesort::(Ord t) => [t]->[t]
     bubblesort[x,y,z,xs]=
                if x<y then x : map bubblesort [y,z,xs]
                       else y : map bubblesort [x,z,xs]  

but it give me an error that :

ERROR line 20 - Type error in list
*** Expression     : [y,xs]
*** Term           : xs
*** Type           : [a]
*** Does not match : a
*** Because        : unification would give infinite type

*note please give me instruction only

–The complier is online compiler

  • 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-06-07T23:09:29+00:00Added an answer on June 7, 2026 at 11:09 pm

    The main problem you’re having is one which I see beginners make all the time. You’re using a list, so you’ve decided that you have to use square brackets. What you really need is something like:

    bubblesort (x:y:xs) = 
        if x < y 
           then x : bubblesort (y:xs)
           else y : bubblesort (x:xs)
    

    when you use something like

    foo [a,b,c] = …
    

    You’re explicitly pattern matching on a list with exactly three elements. If you use

    foo (a:b:c:xs) = …
    

    then you’re explicitly matching on a list with at least three elements, where the first is bound to the name a, the second b, the third c, and the rest of the list (no matter how long it is) is called xs.

    I hope that helps clear it up. It’s a very common mistake.

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

Sidebar

Related Questions

I am able to write code that can send a sort data message using
I'm trying to write a code to actually sort my array in an ascending
I need to write a code in C# that will select a list of
I have a list mapped using Hibernate with an index column. The table looks
We're using a third-party middleware product that allows us to write code in an
I have been struggling to write a simple code to sort an array of
I'm trying to write code in my controller that when run, will create a
I m trying write code that after reset set up rrpmax as 3000. It
I am trying to write code for getting my cords on the mobile. I
How do I write code to connect through Windows VPN client? I want this

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.