lib/fn/fn.rb
# Monadic Compose, using flat_map
# The result of a fn must return an Either.
# fmap_compose.([->(v) { M.Success(v + 1) }, ->(v) { M.Success(v + 10) }]).(M.Success(0))
Monadic Compose, using flat_map
The result of a fn must return an Either.
Monadic Compose using flat_map The result of a fn must return an Either .
def fmap_compose
        ->(fns, value) {
          fns.inject(value) {|result, fn| result.success? ? result.fmap(fn).value_or : result}
        }.curry
      end
def fmap_compose -> ( fns , value ) { fns . inject ( value ) { | result , fn | result . success? ? result . fmap ( fn ) . value_or : result } } . curry end
Monadic Compose, using flat_map
The result of a fn must return an Either.
Monadic Compose using flat_map The result of a fn must return an Either .