Module Prelude::Monad
In: lib/prelude/monad.rb

$Id: monad.rb 13 2006-09-11 05:19:16Z prelude $

Methods

<<   bind   empty   join   unwrap   wrap  

Constants

State = {}

Public Class methods

[Source]

    # File lib/prelude/monad.rb, line 45
45:     def Monad.join(arr)
46:       r = []
47:       arr.each {|a| r.push *a}
48:       r
49:     end

Public Instance methods

<<(f=nil)

Alias for bind

[Source]

    # File lib/prelude/monad.rb, line 51
51:     def bind(f=nil)
52:       case
53:       when f.kind_of?(Symbol) || f.kind_of?(Method) || f.kind_of?(Proc) :
54:           State[object_id] = f.to_proc.call(State[object_id])
55:         self
56:         
57: #      when f.kind_of?(Proc) :
58: #          State[object_id] = f.call(State[object_id])
59: #        self
60: 
61:       else
62:         f
63:       end # case
64:     end

[Source]

    # File lib/prelude/monad.rb, line 40
40:     def empty
41:       State[object_id] = nil
42:       self
43:     end

[Source]

    # File lib/prelude/monad.rb, line 36
36:     def unwrap
37:       State[object_id]
38:     end

[Source]

    # File lib/prelude/monad.rb, line 31
31:     def wrap
32:       State[object_id] = self
33:       self
34:     end