[Haskell-cafe] subclasses and classes with same type in instance
Albert Y. C. Lai
trebla at vex.net
Tue Oct 18 22:22:24 CEST 2011
On 11-10-16 01:56 PM, Patrick Browne wrote:
> I get the same results from Listing 1 and Listing 2 below.
I carefully diff'ed the two listings and found no difference except for
comments.
> -- ====Listing 1- Subclass====
> data Shed = Shed
>
> class Building building where
> addressB :: building -> Integer
> addressB b = 1
>
> -- subclass, but none in Listing 2
> class Building house => House house where
> addressH :: house -> Integer
> addressH b = 0
>
> instance Building Shed where
> instance House Shed where
>
>
> -- ====Listing 2 -- No subclass====
> data Shed = Shed
>
> class Building building where
> addressB :: building -> Integer
> addressB b = 1
>
> -- No subclass
> class Building house => House house where
> addressH :: house -> Integer
> addressH b = 0
>
> instance Building Shed where
> instance House Shed where
More information about the Haskell-Cafe
mailing list