re: Actually, callbacks are fine VIEW POST

VIEW FULL DISCUSSION
 
 

It's allowing him to eventually compose the sequential chain of after/succeed events. The result of each previous curried expression determines whether the sequence will produce an error or continue to the next statement.

 

Hi Pablo. What currying is doing for this code is turning an impure function of type (ignoring errors for simplicity):

// :: (Username, Password, { userInfo: UserInfo, roles: Roles } -!-> Undefined) -!-> Undefined

, which is not a monadic value, into a pure function of the type:

// :: Username -> Password -> ({ userInfo: UserInfo, roles: Roles } -!-> Undefined) -!-> Undefined

for which the return type ({ userInfo: UserInfo, roles: Roles } -!-> Undefined) -!-> Undefined (and more generally, the type (a -!-> r) -!-> r) forms a monad.

We're changing our perspective so that all of our impure functions of multiple arguments can instead be interpreted as pure functions that accept one less argument and return an impure, callback-accepting computation with possibility of failure.

code of conduct - report abuse