type error. reply

S.D.Mechveliani mechvel@math.botik.ru
Thu, 05 Apr 2001 10:04:50 +0400


Norman Ramsey <nr@eecs.harvard.edu> writes

> [..]
> class Formula f where
>   eval    :: f a -> Environment a -> Bool 
> [..]
> type Environment a = Var -> a
> type Var = String
> [..]
> data Formula f => Row a = Row (f a, Weight)
> type Weight = Float
>
> Hugs rejects this program:  [ .. ]


Maybe, the contexts are not needed in the data declarations.
I would write in your case something like   

  data Row f a = Row (f a, Weight) 

and then, define the same instances as the initially intended to 
define for Row: 
               instance (Context1 f a) => Foo1 (Row f a) where ...
               instance (Context2 f a) => Foo2 (Row f a) where ...
               ...
But there arises a question: as the instances define what is allowed 
to do with the data type under various conditions on its parameters, 
then why at all the language allows the `data' contexts?

-----------------
Serge Mechveliani
mechvel@botik.ru