[Haskell-beginners] Re: Overlapping Instances

Jürgen Doser jurgen.doser at gmail.com
Mon Oct 25 17:39:23 EDT 2010


El lun, 25-10-2010 a las 22:00 +0200, John Smith escribió:
> Thank you. Why does this code succeed for a, but stills fails on instance Show B? Do they not both invoke the same Show A?
 
No, a doesn't use the instance for Array Int Bool. The (1,3) get
defaulted to Integers. The following code will complain, though: 

> {-# LANGUAGE TypeSynonymInstances, OverlappingInstances, IncoherentInstances #-}
> 
> import Data.Array
> 
> type A = Array Int Bool
> 
> data B = B A
> 
> instance Show A where
>      show a = "foo"
> 
> a = show $ listArray (1::Int,3) $ repeat True
 




More information about the Beginners mailing list