1. Zachary Voase
  2. tweed

Commits

Zachary Voase  committed a97068b

Fix the definition of monadic zeros.

  • Participants
  • Parent commits 0ae3767
  • Branches default

Comments (0)

Files changed (1)

File lib/tweed/monad.rb

View file
  • Ignore whitespace
         define_method(:bind, &capture[:bind]) unless capture[:bind].nil?
         self.singleton_class.instance_eval do
           define_method(:return, &capture[:unit]) unless capture[:unit].nil?
-          define_method(:zero) { @zero ||= capture[:zero].call } unless capture[:zero].nil?
+          unless capture[:zero].nil?
+            define_method(:get_zero, &capture[:zero])
+            private(:get_zero)
+            define_method(:zero) { @zero ||= get_zero }
+          end
         end
       end