Questions related to GHC haskell's `OverlappingInstances` extension
Questions tagged [overlapping-instances]
42 questions
1
vote
2 answers
Dirty hack for overlapping instances?
Module A imports modules B and C
Module B imports instance X
Module C imports instance Y
X and Y are instances of a common type class.
Instances X and Y are identical in type, that is, fully overlapping.
When I use B or C separately, everything…

letmaik
- 3,348
- 1
- 36
- 43
0
votes
4 answers
How to share common context between classes?
Present Scenario :
I have a set of classes that all take a common argument context in constructor, and all the classes inherit from a common base.
class base:
def common_method(self):
pass
class a(base):
def __init__(self,context,…

Yugal Jindle
- 44,057
- 43
- 129
- 197
0
votes
1 answer
Haskell - Overlapping Instances and Conversion typeclass
I'm writing code to implement extension by definitions in mathematical logic.
It takes in a description of languages and their extensions, and it outputs a new haskell file which will parse a high-level language into a lower-level one. Of course, if…

HallaSurvivor
- 103
- 4
0
votes
1 answer
Confused by "Conflicting family instance declarations"
I'm getting a conflicting family instance error that I don't quite understand:
data DNum n = DNumAdd n | DNumSub n
instance Num n => V n where
type D n = DNum n
-- ...
data DList a = DListUpdate Int a | DListCons a
instance V [a] where
type D…

gregory michael travis
- 31
- 1
- 5
0
votes
2 answers
Overlapping instance for Show
Suppose we have the following:
{-# LANGUAGE FlexibleInstances #-}
module Sample where
newtype A a =
A a
deriving (Show)
newtype L a =
L [a]
class ListContainer l where
getList :: l a -> [a]
instance ListContainer L where
getList (L l)…

Allan W
- 2,791
- 4
- 23
- 41
0
votes
1 answer
GHC uses catch-all instance if constraint is missing?
I've been experimenting with this simple implementation of HLists and a function hasInt which returns True if an Int is a member of the list:
{-# LANGUAGE FlexibleInstances #-}
data HNil = HNil
deriving (Show, Read)
data HCons a b = HCons a b
…

ErikR
- 51,541
- 9
- 73
- 124
0
votes
1 answer
How to declare instances of a typeclass (like Show) for all types in my own typeclass?
I have a typeclass:
class Wrapper w where
open :: w -> Map String Int
close :: Map String Int -> w
It doesn't look very useful, but I use it to strongly (not just a type synonym) distinguish between semantically different varieties of Map…

Leif Willerts
- 205
- 1
- 9
0
votes
0 answers
Third Try - Class instance overwriting another instance
The problem is that the class instance LowE is overwritten with MedE when the button to load the second file is pushed.
I tried to ask this question without posting the entire project code and was not successful So, here is what I have:
File…

Michael Forbush
- 1
- 4
0
votes
2 answers
Composite and Hierarchy without instance shared variables
I've written a good chunk of code that relies heavily on both inheritances and composition. Now i've run into a problem where my hierarchy classes need variables to be shared to work between each other, but that causes the composited classes to be…

Cestarian
- 232
- 4
- 10
0
votes
2 answers
Num instance for Monad; overlapping instances only in the presence of seemingly unrelated code?
I have a bit of code that would be more cleanly written if I could treat Monads as Nums (where applicable, of course). Easily enough done:
{-# LANGUAGE FlexibleInstances #-}
import Control.Monad (liftM, liftM2)
import Data.Char…

James Cunningham
- 775
- 4
- 13
0
votes
1 answer
Using the Additive Class from the Numeric Prelude leads to Overlapping Instances
While trying to define some mathematical objects using the Numeric prelude I've run into a problem. The Additive typeclass defines an instance
instance Additive.C v => Additive.C [v]
Which I read "if v is Additive, [v] is too" (apparently I was…

Gareth Charnock
- 1,166
- 7
- 17
-2
votes
1 answer
In Angular 8, i have problem with overlapping of components in angular .Header component is overlapping child component? how to overcome?
In Angular 8, i have problem with overlapping of components in angular .Header component is overlapping child component? how to overcome strong text