-
Notifications
You must be signed in to change notification settings - Fork 93
Description
First of all, thanks for your talk about Ruby monads, it blew my mind ^^
I've been trying to imitate your logic as a TDD exercise, and was comparing what I was writing to your code and found a difference puzzling me in the "Many" monad.
When I'm trying to use yours, I find that:
Blaher = Struct.new(:blahs)
Bloher = Struct.new(:blohs)
blahers = [Blaher.new([Bloher.new([1, 2, 3, 4])])]
Monads::Many.new(blahers).blahs.blohs.valuesEnds up in a:
NoMethodError: undefined method `bloh' for [#<struct bloh=[1, 2, 3, 4]>]:Array
I thought it had something to do with the Many.from_value method and tried a quick-and-dirty fix with:
def from_value(value)
Many.new(value)
endIt makes the method_missing do its job and return the subelements expected, though I find one test (spec/monads/many_spec.rb:49 the one that verifies that Many.from_value wraps the value in an array before wrapping it in the monad) fails.
I'm a bit unsure on what to do to fix this, so I thought I'd let you know ^^°
Again, thanks for the awesome talk and ideas.