Choosing a type-class instance based on the context

Hi all, I was reading: http://www.haskell.org/haskellwiki/GHC/AdvancedOverlap and I became curious. Playing with the code I started to find a way to say: instance Show a => ShowPred a HTrue instead of enumerating all the instances, mirroring those of the Show class: instance ShowPred Int HTrue instance ShowPred Bool HTrue instance ShowPred a flag => ShowPred [a] flag Would that be possible? My opinion is that's not possible but I want to hear what the type-system gurus think about it. Thanks, -- Cristiano GPG Key: 4096R/C17E53C6 2010-02-22 Fingerprint = 4575 4FB5 DC8E 7641 D3D8 8EBE DF59 B4E9 C17E 53C6

Though its quite different to AdvancedOverlap, Conal Elliott has a method of answering the title of your post - "Choosing a type-class instance based on the context". See the CxMonoid (context monoid) in Section 3. Flexible Layout of the paper Applicative Data-Driven Computation. http://conal.net/papers/data-driven/paper.pdf Best wishes Stephen

On Wed, Jan 5, 2011 at 20:35, Stephen Tetley
Though its quite different to AdvancedOverlap, Conal Elliott has a method of answering the title of your post - "Choosing a type-class instance based on the context".
See the CxMonoid (context monoid) in Section 3. Flexible Layout of the paper Applicative Data-Driven Computation.
Thank you Stephen. I'll read it and come back to this ml. Regards, -- Cristiano GPG Key: 4096R/C17E53C6 2010-02-22 Fingerprint = 4575 4FB5 DC8E 7641 D3D8 8EBE DF59 B4E9 C17E 53C6
participants (2)
-
Cristiano Paris
-
Stephen Tetley