Question on constructor/type classes

Hello,

I have the following problem of which I think the answer is quite simple,

but of which I don't seem to be able to find the correct solution.

I have the following two data types

data N a = On a | Drie (N a) (N a) (N a) ,

data Q a = Oq a | Twee (N (Q a)) (N (Q a)) .

I also have

class Functor f where

map' :: (a -> b) -> (f a -> f b)

and

instance Functor f where

map' f (On x) = On (f x)

map' f (Drie x y z) = Drie (map' f x) (map' f y) (map' f z)

My question now is how to get a similar instance on data type Q.

I tried:

instance Functor f where

map' f (Oq x) = f x

map' f (Twee x y) = Twee (map' f x) (map' f y)

but this (of course) results in an error.

I know why I get the error, but I don't seem to find a way around it.

If you know what I am doing wrong and you know a solution I would

appreciate it very much if you could send me any comments and solutions.

Thank you very much in advance,

Harold Weffers c/o Eindhoven University of Technology

Department of Mathematics and Computing Science

/_/ / / HG 6.64

/ /. /_/_/. P.O. Box 513, 5600 MB EINDHOVEN, The Netherlands

Telephone: (+31) (0)40 - 474231

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

| Disclaimer: I say what? | - To err is human, to forgive divine - |

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#