Skip to content

Instantly share code, notes, and snippets.

@safiire

safiire/kleisli.rb

Created Dec 16, 2016
Embed
What would you like to do?
Kleisli Gem is pretty awesome
require 'kleisli'
def do_lots(count)
(0..count).reduce(0){|sum, value| sum + value }
end
future = Future(100000000) >-> value {
Future {
do_lots(value.call)
} >-> big_sum {
Future{ big_sum.call }
}
}
puts "I'm doing other stuff."
puts "Oh, let's also add 7"
future2 = future >-> value {
Future{ value.call + 7 }
}
puts future2.await
# => I'm doing other stuff.
# => Oh, let's also add 7
# => 5000000050000007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.