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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:01:31+00:00 2026-06-05T17:01:31+00:00

Pivoting off some recent questions, I figured I’d turn the spotlight on the old

  • 0

Pivoting off some recent questions, I figured I’d turn the spotlight on the old bogeyman, OverlappingInstances.

A few years ago I might’ve been asking this question in earnest: after all, you can provide useful default instances and others can override them with more specific ones when they need to, what can be so bad about that?

Along the way I’ve absorbed some apprecation for the viewpoint that OverlappingInstances is really not so clean, and best avoided; mainly stemming from the fact that it’s not very well-grounded theoretically, unlike other big extensions.

But thinking about it, I’m not sure if I could explain what’s really so bad about it to another person, if I were asked.

What I’m looking for is specific examples of ways in which using OverlappingInstances can lead to bad things happening, whether it’s by subverting the type system or other invariants, or just general unexpectedness or messiness.

One particular problem I know of is that it breaks the property that merely adding or removing a single module import can’t change the meaning of your program, because with the extension on, a new instance overlap could be silently added or removed. While I can see why that’s unpleasant, I don’t see why it’s earth-shatteringly awful.

Bonus question: As long as we’re on the subject of useful but not theoretically well-grounded extensions that can lead to bad happenings, how come GeneralizedNewtypeDeriving doesn’t get the same bad rap? Is it because the negative possibilities are more easy to localize; that it’s easier to see what would cause problems and say, “don’t do that”?

(Note: I would prefer if the brunt of the answer focuses on OverlappingInstances, not IncoherentInstances which needs less explanation.)

EDIT: There are also good answers to a similar question here.

  • 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-05T17:01:35+00:00Added an answer on June 5, 2026 at 5:01 pm

    One principle that the haskell language attempts to abide by is adding extra methods/classes or instances in a given module should not cause any other modules that depend on the given module to either fail to compile or have different behaviour (as long as the dependent modules use explicit import lists).

    Unfortunately, this is broken with OverlappingInstances. For example:

    Module A:

    {-# LANGUAGE FlexibleInstances, OverlappingInstances, MultiParamTypeClasses, FunctionalDependencies #-}
    
    module A (Test(..)) where
    
    class Test a b c | a b -> c where
       test :: a -> b -> c
    
    instance Test String a String where
        test str _ = str
    

    Module B:

    module B where
    import A (Test(test))
    
    someFunc :: String -> Int -> String
    someFunc = test
    
    shouldEqualHello = someFunc "hello" 4
    

    shouldEqualHello does equal “hello” in module B.

    Now add the following instance declaration in A:

    instance Test String Int String where
        test s i = concat $ replicate i s
    

    It would be preferable if this didn’t affect module B. It worked before this addition, and should work afterwards. Unfortunately, this isn’t the case.

    Module B still compiles, but now shouldEqualHello now equals "hellohellohellohello". The behaviour has changed even though no method it was originally using had changed.

    What is worse is there is no way to go back to the old behaviour, as you cannot choose to not import an instance from a module. As you can imagine, this is very bad for backwards compatibility, as you cannot safely add new instances to a class that uses overlappinginstances, as it could change the behaviour of code that uses the module (especially true if you are writing library code). This is worse than a compile error, as it could be very difficult to track down the change.

    The only safe time to use overlapping instances in my opinion is when you are writing a class that you know will never need additional instances. This may occur if you are doing some tricky type based code.

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

Sidebar

Related Questions

I've written some very basic tools for grouping, pivoting, unioning and subtotaling datasets sourced
Im pivoting sys.[views] into key value pairs to compare with values on another server
I have the following pivoting table that I manage to do and here's the
I'm stumped by pivoting a table and the frustration level is rising. I realize
There are lots of posts out there on pivoting rows into columns for various
I'm pivoting data in MS SQL stored procedure. Columns which are pivoted are dynamically
I am not sure if this would be called pivoting. Data in my SQL
I am writing a query to pivoting table elements where column name is generated
Why would someone want to convert columns into rows (ie pivoting)? Which problem does
The wikipedia pseudocode on BK clique finding with pivoting: BronKerbosch2(R,P,X): if P and X

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.