[Haskell-cafe] Question about instance

Ketil Malde ketil+haskell at ii.uib.no
Fri Jan 14 03:08:57 EST 2005


John Velman <velman at cox.net> writes:

>> data Relation a i b = Rel {name::RN, arity::Int, members::(Set [EN])}

Why do you parametrize the data type when you don't use the
parameters?  Either do

      data Relation = Rel {name::RN, arity::Int, members::Set [EN]}
or
      data Relation a i b = {name::a, arity::i, members::Set b}

(or whatever you intended).

>> instance (Show a, Show i, Show b) => Show (Relation a i b)
>>   where
>>     show (Rel a i b) =
>>                    a ++ "/" ++ (show i) ++ " "
>>                    ++ (show b)

It doesn't matter whether a,i,b are in Show, as you don't use them
(they are completely unrelated to the a,i,b in (Rel a i b), the former
are types, the latter are variables)

-kzm

PS: Please don't quote the entire thread in each message.  Although I
haven't seen Andreas' message on the list (yet).
-- 
If I haven't seen further, it is by standing in the footprints of giants



More information about the Haskell-Cafe mailing list