Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's not performant though generally speaking you keep boxing and unboxing the type (imagine having a list of 100,000 notifications and then mapping over it 5 times in a row). The composition law would give you a just-as-readable option

    const dataForTemplate = notificationData.map(pipe(
      addReadableDate,
      sanitizeMessage,
      buildLinkToSender,
      buildLinkToSource,
      addIcon
    ))

> in most cases is not the best idea, at least I'd put a log about it

Well, in FP you don't want to do side effects like write to console. Instead you want to hold onto the errors (with an `data Either e a = Left e | Right a` instead of `data Maybe a = Just a | Nothing`) til you get to the part of your application where you do do the side effects.

  try {
    return Right(JSON.parse(data))
  } catch (err) {
    return Left(err)
  }


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: