Re: [Haskell] Instance declaration of classes with method type constraints

2005-06-30 Thread Johan Holmquist
Perfect! Problem solved and now I understand about "kinds" of types. instance Rect (PRect a) a where ... works if "Num a" is added to it, like: instance Num a => Rect (PRect a) a where ... (GHC has pretty informative error messages) Thank you for great answers! /johan _

Re: [Haskell] Instance declaration of classes with method type constraints

2005-06-30 Thread Wolfgang Jeltsch
Am Donnerstag, 30. Juni 2005 14:07 schrieb Johan Holmquist: > [...] > Anyone: > > However, I haven't been able to make PRect an instance of this class (with > extensions). If I understand your problem correctly, you may use the new Rect class (the one which is declared as class Num b => Rect a b

Re: [Haskell] Instance declaration of classes with method type constraints

2005-06-30 Thread Malcolm Wallace
Johan Holmquist <[EMAIL PROTECTED]> writes: > > class Num b => Rect a b | a -> b where > > instance Rect IRect Int where > > However, I haven't been able to make PRect an instance of this class (with > extensions). I might not have grasped this yet, but I came to think; if the > old class decla

Re: [Haskell] Instance declaration of classes with method type constraints

2005-06-30 Thread Johan Holmquist
> This type declaration for 'm' probably doesn't mean what you think it > does. I think what you want is "m takes an item of type 'a' and returns > an item of a particular type in the Num class, but I'm not going to tell > you which one", but what this declaration really means "m takes an item > o

Re: [Haskell] Instance declaration of classes with method type constraints

2005-06-29 Thread robert dockins
Hi, How do you instantiate from classes with method type constraints, such as this one: class C a where m :: (Num b) => a -> b This type declaration for 'm' probably doesn't mean what you think it does. I think what you want is "m takes an item of type 'a' and returns an item of a part

[Haskell] Instance declaration of classes with method type constraints

2005-06-29 Thread Johan Holmquist
Hi, How do you instantiate from classes with method type constraints, such as this one: class C a where m :: (Num b) => a -> b ?? I have been trying for some time now but everything I have tried fails. In particular, what I want to do is something like this: class Rect a where wid