How to interrupt, exit a compose or pipe?

I don't think there is a generic way of dealing with that.

Often when working with algebraic data types, things are defined so that you can continue to run functions even when the data you would prefer is not present. This is one of the extremely useful features of types such as Maybe and Either for instance.

But most versions of compose or related functions don't give you an early escape mechanism. Ramda's certainly doesn't.


While you can't technically exit a pipeline, you can use pipe() within a pipeline, so there's no reason why you couldn't do something like below to 'exit' (return from a pipeline or kick into another):

pipe(
  // ... your pipeline 
  propOr(undefined, 'foo'), // - where your value is missing
  ifElse(isNil, always(undefined), pipe(
    // ...the rest of your pipeline
  ))
)