[Haskell-beginners] warning in making instances of Functor class!
Imants Cekusins
imantc at gmail.com
Fri Dec 25 19:56:17 UTC 2015
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
More information about the Beginners
mailing list