Thanks a lot. It works fine. Could you help me with this. With the following defintions, I want to be able to write (high \+ 4) (3.4,2) and (4 \+ high) (3.4,2) which both should be equal to 4+ (high 2) = 6. But hugs gives following error during run time: ERROR: Unresolved overloading *** Type : Lift a => Integer *** Expression : (high \+ 4) (1,1) type Formula a b = a -> b (\+) :: (Lift a,Lift c,Num b)=>Formula a b -> Formula c b -> Formula Env b p \+ q = \env -> (lift p) env + (lift q) env type Env = (Double,Integer) class Lift a where lift :: Formula a b -> Formula Env b instance Lift Double where lift f (c,i) = f c instance Lift Integer where lift f (c,i) = f i instance Lift Env where lift = id high :: Formula Integer Integer high n = n+1 low :: Formula Double Integer low = round instance Eq (Formula a b) where (==) = error "<< error >>" instance Show (Formula a b) where showsPrec n a1 = error "<< Formula >>" instance (Num b) => Num (Formula a b) where -- I tried instance (Lift a, Num b) =>...... does not work fromInteger x = \a -> fromInteger x Thanks, Saswat ----- Original Message ----- From: Ken Shan <ken@digitas.harvard.edu> To: Saswat Anand <iscp9157@nus.edu.sg> Cc: <haskell@haskell.org> Sent: Friday, February 16, 2001 12:17 PM Subject: Re: Lifting to the limit
Tis the season for type class overloading fun...
On 2001-02-16T21:45:32+0800, Saswat Anand wrote:
lift2 :: (a -> b -> c) -> Formula d a -> Formula e b -> Formula Env c
This type is too general. You need to specify a context that requires both d and e to satisfy Lift:
lift2 :: (Lift d, Lift e) => (a -> b -> c) -> Formula d a -> Formula e b -> Formula Env c
-- Edit this signature at http://rodimus.digitas.harvard.edu/cgi-bin/ken/sig "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" - Ernst Jan Plugge