These are chat archives for ramda/ramda
a -> b -> Maybe c?
R.liftis close, but will give me a function of type
Maybe a -> Maybe b -> Maybe (Maybe c).
(a -> b -> Maybe c) -> Maybe a -> Maybe b -> Maybe c
safeDiv = R.curry((a, b) => b !== 0 ? Just(a / b) : Nothing); maybeSafeDiv = R.compose(R.chain(R.identity), R.lift(safeDiv)); maybeSafeDiv(Just(10), Just(2)); //=> Just(5) maybeSafeDiv(Just(10), Just(0)); //=> Nothing maybeSafeDiv(Nothing, Just(2)); //=> Nothing
R.unnest). I was wondering whether there’s a nicer solution.
R.chain(R.identity)(and already forgetting
unnest!) but it wasn't yet as clean as this.
unnestdelegate for monads, or is it specialised to lists?
chain(_identity)to support things other than lists.
Just(42), but it doesn’t currently.