[Haskell-cafe] the overlapping instance that wasn't?
mvanier42 at gmail.com
Tue Aug 24 16:55:40 EDT 2010
On 8/24/10 1:54 PM, Bartek Æwik³owski wrote:
> Hello Michael,
> This is because instance selection is solely based on instance heads,
> it doesn't consider contexts. There's a nice explanation available
> here: http://www.haskell.org/haskellwiki/GHC/AdvancedOverlap
> The fix in this case is very easy because there are only two cases
> (and you don't want to provide new Nat class instances):
> instance Show Z where
> show _ = "0"
> instance Nat n => Show (S n) where
> show _ = show $ toInt (undefined :: n) + 1
> Bartek Æwik³owski
More information about the Haskell-Cafe