Skip to content

fmap with a function

What is this code doing?

repl example
> func = fmap not (\x -> x > 3) 
> func 2
True
> func 4 
False

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:

Functor

The line $dFunctor :: Functor ((->) Integer) means that the instance of Functor being used is ((->) Integer).

Tip

If it is unclear what ((->) Integer) means, see here and here.

Under 🚧


Last update: January 13, 2023
Created: January 13, 2023

Comments