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

The Archive Base Latest Questions

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

I have a Haskell program which uses Data.Map.! at several places. After executing the

  • 0

I have a Haskell program which uses Data.Map.! at several places. After executing the program, there is error message saying element not in the map.
I am wondering how can I know at which line of the program that uses the Data.Map.! that emits the error message and what element is not found in the map?

  • 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-23T22:28:02+00:00Added an answer on May 23, 2026 at 10:28 pm

    The (!) operator is not intended for looking up things that might not be in the map. While you can catch the resulting error in the IO monad, it would be very bad style.

    Instead, use lookup, which returns Maybe a, and in particular, returns Nothing when the element isn’t in the map.

    Edit: Okay, I misread your question. Leaving the original answer in case it’s useful, but supposing that (!) really was what you wanted and you’re debugging, there are a couple things you could do:

    1. You can temporarily hide (!) in the imports, and instead define your own version that uses lookup and throws a more useful error (perhaps containing the key that you tried to look up, if it has a Show instance).

    2. You can run the code in the GHCi debugger, and use -fbreak-on-exception to stop the code where the lookup occurs.

    3. You can use the Debug.Trace module to add trace statements to your code.

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

Sidebar

Related Questions

I am new at haskell, I have to write a program context-aware,so I thought
I wrote a Haskell code which has to solve the following problem : we
Does D have 'newtype' (as in Haskell). It's a naive question, as I'm just
I'm learning Haskell from a Java background. When I program Java, I feel like
I want to write a paint program in the style of MS Paint. For
The Haskell wiki shows that you need to both set a compilation flag and
I'm learning haskell. Currently working through 99 questions , a little bit stuck on
I have a list like this: (Pseudo notation) (X,...) -> (X,...) -> (X,...) ->
As a programmer, I have bought whole-heartedly into the TDD philosophy and take the
This is entirely theoretical at this point, but I've been trying to wrap my

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.