[Haskell-cafe] Choosing a type-class instance based on the context

Cristiano Paris frodo at theshire.org
Wed Jan 5 17:36:32 CET 2011


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



More information about the Haskell-Cafe mailing list