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

  • Home
  • SEARCH
  • 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 9161105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:53:36+00:00 2026-06-17T13:53:36+00:00

I changed some old code from Prelude.catch to Control.Exception.catch and got an ambiguous type

  • 0

I changed some old code from Prelude.catch to Control.Exception.catch and got an ambiguous type error. “No big deal”, I thought. However, on closer inspection, I’m not exactly sure why this doesn’t work as-is…

handler :: Exception e => e -> IO x

with_handler :: IO x -> IO x
with_handler act = catch act handler

It appears to me that this code ought to work, and yet it clearly violates some nominative rule of the type system. (I’m not sure what though.)

Can somebody explain exactly what the type checker is unhappy about?

  • 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-17T13:53:38+00:00Added an answer on June 17, 2026 at 1:53 pm

    The compiler doesn’t know which type to use for the handler. It can’t see at runtime what exception is raised and then choose the appropriate type for handler, it must resolve the type at compile time.

    It might be possible to give handler the type

    handler :: SomeException -> IO x
    

    which would resolve the ambiguity.

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

Sidebar

Related Questions

For some reason when I changed my php code from mysql to mysqli everything
The other day this code was working. I changed some things and re-ran it
I wrote some code today and It was changed by another developer who said
I've some scenarios where i need to pass value type as reference without changed
I'm currently refactoring some Javascript code we have and amongst other things I've changed
While cleaning some code today written by someone else, I changed the access modifier
I received some code from a client containg a wsdl.exe generated SoapHttpClientProtocol sub-class for
I have some fairly old code that runs just fine in Excel versions before
I'm about to have to rewrite some rather old code using SQL Server's BULK
I've got a layer with some complex drawing code in its -drawInContext: method. I'm

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.