Fmap for functions in Haskell

I am trying to implement fmap for functions and I can’t understand how the “elevator” refers to the function compared to the way all the documentation relates to simple types, for example Maybe

The type of function I want to implement is

 fmapFunction :: (a -> b) -> (e -> a) -> (e -> b) 

Any ideas how I should do this?

+4
source share
1 answer

You may find it easier to see if you flip types around:

 (e -> a) -> (a -> b) -> (e -> b) 

We can turn a e into a , a a into b . So how can we turn e into b ?

Do not pay too much attention to "lifting"; with Functor instances, the best way to discover an implementation is to simply follow the type.

+11
source

Source: https://habr.com/ru/post/1404027/


All Articles