
13 Sep
2011
13 Sep
'11
10:58 a.m.
Is there a way to make the following code working? {-# LANGUAGE TypeFamilies #-} data family Foo a data instance (Num a) => Foo a = A a deriving Show data instance (Fractional a) => Foo a = B a deriving Show I want to have different constructors for 'Foo a' depending on a class of 'a'. Note also, that in the example above I also meant constructor A to be available for (Fractional a) => Foo, since in that case 'a' has Num too. How can I achieve it, maybe not with TypeFamilies? Current error is Conflicting family instance declarations: data instance Foo a -- Defined at 1.hs:7:33-35 data instance Foo a -- Defined at 1.hs:5:33-35