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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:30:01+00:00 2026-06-12T17:30:01+00:00

So I have to make a function that finds a pair with its 1st

  • 0

So I have to make a function that finds a pair with its 1st letter and returning the 2nd letter.

I actually found one answer but with the map function and I couldn’t get it.

      lookUp :: Char -> [(Char, Char)] -> Char
      lookUp x [] = x
      lookUp x ( ( st,nd ): rst) | st == x = nd
                   | otherwise = lookUp x rst

And I get this message:

No instance for (Show ([(Char, Char)] -> Char))
arising from a use of `print'
 Possible fix:
  add an instance declaration for (Show ([(Char, Char
  In a stmt of an interactive GHCi command: print it
  • 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-12T17:30:03+00:00Added an answer on June 12, 2026 at 5:30 pm

    Your code is fine, you just need to supply all the arguments at the ghci prompt, eg

    lookUp 'c' [('b','n'), ('c','q')]
    

    Should give you ‘q’.

    It’s complaining that it can’t show a function. Any time it says it doesn’t
    have a Show instance for something with -> in, it’s complaining it can’t
    show a function. It can only show the result of using the function on some data.

    When you give it some, but not all data, Haskell interprets that as a new function
    that takes the next argument, so

    lookUp 'c'
    

    is a function that will take a list of pairs of characters and give you a character.
    That’s what it was trying to show, but couldn’t.

    By the way, almost every time you get a “No instance for…” error, it’s because
    you did something wrong with the arguments – missed some out, put them in
    the wrong order. The compiler’s trying to be helpful by suggesting you add
    an instance, but probably you just need to check you supplied the write type
    of arguments in the right order.

    Have fun learning Haskell!

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

Sidebar

Related Questions

I have to make a recursive function that finds the number of ones from
I have been fruitlessly trying for several hours to make a function that filter
I have a javascript function that calls a generic function to make an ajax
I have: void add_all_msgs(std::deque<Message>::iterator &iter); How can I make that function generic, so it
I have a PHP function that I want to make available publically on the
I have an application that I make a call to a DLL function that
gcc 4.4.2 c89 I have a function that has to run (config_relays). It make
I have link that calls a function when clicked: <a href=javascript:spawnMenu(this); id=link1>Test1</a> To make
I have two Ajax calls. I need to make sure that a JS function
I have a MATLAB function that finds charateristic points in a sample. Unfortunatley it

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.