RE: Overlapping Instances + Existentials = Incoherent Instances

2010-02-10 Thread Simon Peyton-Jones
This is a tricky one. The motivating example is this: -- Overlapping instances instance Show a => Show [a] where ... instance Show Char where ... data T where MkT :: Show a => [a] -> T f :: T -> String f (MkT xs) = show xs ++ "\n" Here it's clear that the only way to discharge t

Re: Overlapping Instances + Existentials = Incoherent Instances

2010-02-03 Thread Dan Doel
On Wednesday 03 February 2010 11:34:27 am Stefan Holdermans wrote: > I don't think it's the same thing. The whole point of the existential > is that at the creation site of any value of type Ex the type of the > value being packaged is hidden. At the use site, therefore, the only > suitable instanc

Re: Overlapping Instances + Existentials = Incoherent Instances

2010-02-03 Thread Stefan Holdermans
Dan, class C a where foo :: a -> String instance C a where foo _ = "universal" instance C Int where foo _ = "Int" [...] Now, IncoherentInstances is something most people would suggest you don't use (even people who are cool with OverlappingInstances). However, it turns out t