fmap with a function
What is this code doing?
Answer¶
fmap
is the method of the Functor typeclass.
To understand what fmap
does whenever it is called, it is necessary to know which instance of fmap
is being used. You can find this out by mousing over fmap
(first place the line func = fmap not (\x -> x > 3)
in a Haskell file in your project), to see:
The line $dFunctor :: Functor ((->) Integer)
means that the instance of Functor
being used is ((->) Integer)
.
The instance of Functor
for ((->) Integer)
is:
- Or in pointfree style: fmap = (.)
and this is what is being used in the examples above.
Last update:
January 17, 2023
Created: January 13, 2023
Created: January 13, 2023