
Hi. I have the next definitions: type Ocurrence = (String, Int) type Inside = [Ocurrence] data Pattern = Return Inside | Abort | Filter (Ocurrence -> Bool) Pattern beyond :: Pattern -> Pattern beyond (Filter pred Abort) = Abort -- more definitions of beyond optimous :: Pattern -> Pattern optimous p = fixPoint beyond p where fixPoint f x = if(f x == x) then x else fixPoint f (f x) When I load the program an error is produced: ERROR - An instance of Eq (Event -> Bool) is required to derive Eq Pattern I put: data Pattern = Return Inside | Abort | Filter (Ocurrence -> Bool) Pattern deriving (Eq) and a new error was produced: ERROR - An instance of Eq (Ocurrence -> Bool) is required to derive Eq Pattern Who can I do an instance of Eq (Ocurrence -> Bool)? Is there another option to avoid the error? Regards Ulises _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

On 18 Jan 2005, at 21:45, Ulises Juarez Martinez wrote:
Who can I do an instance of Eq (Ocurrence -> Bool)? Is there another option to avoid the error?
In general, you can't define one. To define equality on functions you want to check the value on every possible input, and since Ocurrence is an infinite type, that can't be done in a finite time. In this specific case, you are dealing with indicator functions, which are isomorphic to (possibly infinite) Sets of Ocurrences. If you happen to know that they will always be finite (or, perhaps, always cofinite) you might solve the problem by using that representation. Jules
participants (2)
-
Jules Bean
-
Ulises Juarez Martinez