0

You use fmap to lift a function over some context:

fmap succ [1] = [2]

You can use function composition to lift over two layers of context:

(fmap . fmap) succ [[1]] = [[2]]

And because fmap for functions is equal to (.), this can also be written as:

fmap fmap fmap succ [[1]] = [[2]]

What about three layers of context?

fmap . fmap . fmap = 
(fmap . fmap) . fmap = 
fmap (fmap . fmap) fmap = 
fmap (fmap fmap fmap) fmap = 
(fmap . fmap fmap) fmap fmap = 
fmap fmap (fmap fmap) fmap fmap = 
(fmap fmap . fmap) fmap fmap fmap = 
(fmap . fmap) fmap fmap fmap fmap fmap = 
fmap fmap fmap fmap fmap fmap fmap fmap

Eight! We just went from 5 (2 of which where infix) to 8.
How many fmaps in a row do I need to lift over four layers of context? A lot apparently, so many that I can't figure it out trough bruteforce. Is it even possible, does the pattern stop at 3?

BlackCap
  • 1,064
  • 9
  • 14

0 Answers0