
21 Jan
2008
21 Jan
'08
5:33 p.m.
2008/1/21 Alexander Seliverstov
So, the function type "(Num a)=>Integer->a" means that return value of this function can be cast to any particular instance of class Num.
Ok. I have a my own class "class A a" and want to write function like this "f:: (A a)=>Integer->a". Can I do it?
Only if you make the function f a member of class A. Then it is the responsibility of each particular type which is an instance of A to define a way of converting an Integer into a value of that type. For example: class A a where f :: Integer -> a ... other functions... instance A Integer where f = id instance A String where f = show and so on. -Brent