How do I take a value out of a Maybe monad in ramda-fantasy?

429 views Asked by At

I want to have a pipe that does some operations on a Maybe, and want to return its value at last. Currently I am doing:

const data = Maybe(5)
pipe(
  map(add(1)),
  ... other operations
  y => y.getOrElse([])
)(data)

Is there any cleaner way out?

1

There are 1 answers

0
Alfred Young On

The only improvement would be to create a pointfree helper function

const getOrElse = (defaultValue) => (m) => m.getOrElse(defaultValue);