We find a couple of DOM nodes that may or may not be exist and run a calculation on the page height using applicatives.
For example we want to get the main content sections size by reduce the height of the header and footer, nomarlly we'll do Li Ke this:
1. Get the header height
2. Get the footer height
3. Use the screen height-header-footer.
Const $ = selector =ten})const getscreensize = (screen, header, Footer) = Screen-(header + footer); $ ('header'). Chain (Header = $ ('footer'). Map (footer = getscreensize ( ,header, footer )))
This happens in sequential, we can use Currey function to improve the code:
Const getscreensize = Screen = /Header = Footer = Screen -(header + footer);
either.of (getscreensize) . AP ($ ('header')) . AP ($ (' footer'))
Or We can use:
const liftA2 = (f, FX, FY) = Fx.map (f). AP (FY)
Const res = liftA2 (Getscreensize (), $ ('header'), $ ('footer '))
[Compose] 16. Apply multiple functors as arguments to a function (applicatives)