0

Say we have the following two functions :

getTweetsForUser( handle, callback )

And

expandShortLink ( stringHasLink, callback )

Please show how we would compose these with:

  1. A monad and
  2. An arrow

Assume the functions do not have side effects and please show how we would compose them and also carry a little bit of state, say a debugging log message.

Note: this is not homework, I am just looking to get some good, clear reference code for my own learning and programming with monads and arrows, thank you.

Cris
  • 441
  • 3
  • 11

1 Answers1

0

There is no concept of monads in Python or JavaScript (it is allowed for functions to have side effects and the code is always executed in the order you have written – so there is no need for monads in these languages).

In the context of functions is the arrow composition the normal function composition. So you can write

getTweetsForUser( handle, expandShortLink( stringHasLink, callback ))

for example.

Stephan Kulla
  • 4,739
  • 3
  • 26
  • 35