Commits

Zachary Voase  committed 147cea4

Tweaks to the Maybe monad.

  • Participants
  • Parent commits a97068b

Comments (0)

Files changed (1)

File lib/tweed/monads/maybe.rb

       end
       
       def inspect
-        repr = @success ? "Just #{@value.inspect}" : "Nothing"
-        "#{self.class.inspect} :: #{repr}"
+        repr = @success ? "[#{@value.inspect}]" : ".zero"
+        "#{self.class.inspect}#{repr}"
       end
       
       # An example of safe division implemented over the Maybe monad.
         def /(other)
           self.bind do |x|
             other.bind do |y|
-              y.zero? ? self.class.fail : self.class[x / y]
+              y.zero? ? self.class.zero : self.class[x / y]
             end
           end
         end # def /