warning in making instances of Functor class!

why am i getting warning in the following code?? though it works perfectly!!! Prelude> newtype Pair1 c b a=Pair1 {getPair1 :: (a,b,c)} Prelude> :{ Prelude| instance Functor (Pair1 m n) where Prelude| fmap f (Pair1 (x,y,z))=Pair1 (f x,y,z) Prelude| :} <interactive>:55:10: Warning: No explicit implementation for ‘Prelude.fmap’ In the instance declaration for ‘Functor (Pair1 m n)’ -- The below shows it is working fine! Prelude> getPair1 $ fmap (*100) (Pair1 (2,3,1)) (200,3,1)

Hello Abhijit a properly formatted statement as you intended it is: instance Functor (Pair1 m n) where fmap f (Pair1 (x,y,z))=Pair1 (f x,y,z) note the indent before fmap. without the tab, fmap f (Pair1 (x,y,z))=Pair1 (f x,y,z) is just a stand alone function delcaration if you enter instance.. line #1 but not the fmap line #2, you will see the same warning you are seeing. if you enter #2 but not #1, this line: getPair1 $ fmap (*100) (Pair1 (2,3,1)) will work fine too. basically, flush (no indent) line begins a new code block
participants (2)
-
Abhijit Patel
-
Imants Cekusins