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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:04:43+00:00 2026-05-28T00:04:43+00:00

If I understood rightly, exceptions in Haskell basically intended to deal within IO monad.

  • 0

If I understood rightly, exceptions in Haskell basically intended to deal within IO monad. At least exception could be caught inside IO monad.

But sometimes even pure functions may throw an exception, e.g. read "..." :: Int (when reading string does not represent integer), operator (!!) (when we trying to get item out of range of the list), and so forth. And this is true behavior, I don’t deny. However, I would not want to change signature of function just to get it chance to catch possible exception, because in this case I have to change signature all the functions by call stack before.

Is there some pattern to deal with exceptions more comfortable in Haskell, out of IO monad? May be I should use unsafePerformIO in this case? How “safe” to use unsafePerformIO just for catching exceptions in pure functions?

  • 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-28T00:04:44+00:00Added an answer on May 28, 2026 at 12:04 am

    In pure code, it’s usually best to avoid exceptions from happening in the first place. That is, don’t use head unless you’re absolutely positive that the list isn’t empty, and use reads and pattern matching instead of read to check for parse errors.

    I think a good rule of thumb is that exceptions in pure code should only come from programming errors, i.e. calls to error, and these should be treated as bugs, not something an exception handler can deal with.

    Note that I’m only talking about pure code here, exceptions in IO have their uses when dealing with the exceptional cases that sometimes happen when interfacing with the “real world”. However, pure mechanisms like Maybe and ErrorT are easier to work with, so they are often preferred.

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

Sidebar

Related Questions

I understood that this Bind attribute was not necessary, but JSON type is not
I thought I understood Java generics pretty well, but then I came across the
OK thought I understood IDipose but just reading the best practices section of Accelerated
I've always understood XMLSchemas and DTDs to be equivalent but that the latter is
I thought I understood the chaining power of jQuery, but now I'm a little
I understood how simple route, default route and root routes are used. But I
I think I have understood a particular situation as described below, but I lack
I thought I understood Perl RE to a reasonable extent, but this is puzzling
I understood changing corner and disable navigation bar. but i need to build through
I thought I understood ViewState, but this is a bit of a weird one.

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.