DEV Community

Discussion on: Ask me dumb questions about functional programming

 
shepelevstas profile image
Shepelev Stas

I think I found a somewhat simple solution!

const getUser = token => fold(
  (res, f) => res.isRight ? res : f(token),
  left('None Worked'),
  [getUserFromDB, getNewUser, someOtherAttempt, ...]
)
Thread Thread
 
joelnet profile image
JavaScript Joel

Ahh okay. I see what you are trying to do. Nice solution!