
21 Feb
2014
21 Feb
'14
12:02 a.m.
On 02/20/2014 11:48 PM, Philippe Sismondi wrote:
In the Haskell 98 and 2010 reports it states that one may declare something of the form /(tyvar1 -> tyvar2)/ to be an instance of a type class. Is that a function or what is it? Can anyone point me to an example of this?
It refers to something like (a -> b) which is the type of functions from 'a' to 'b' (tyvar1 and tyvar2 in the report). Here's a not-terribly-useful example of such an instance: instance Show (a -> b) where show f = "some kinda function" main = print foldl A better example could make those functions an instance of Num, so that you could write f + g to represent f(x) + g(x), f * g for f(x) * g(x), and so on.