#-- # This file is part of the Prelude library that provides tools to # enable Haskell style functional programming in Ruby. # # http://prelude.rubyforge.org # # Copyright (C) 2006 APP Design, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #++ # # $Id: prelude.rb 8 2006-09-06 17:06:22Z prelude $ $:.unshift(File.dirname(__FILE__)) require 'prelude/list' require 'prelude/tuple' require 'prelude/monad' module Prelude VERSION='0.0.2' end # Prelude class Symbol def to_proc proc { |obj, *args| obj.send(self, *args) } end def curry(one, *args) proc { |*args| self.to_proc.call(one, *args) } end end # Symbol class Proc def curry(one, *args) proc{ |*args| self.call(one, *args)} end # This is will serve as an infix composition operator def <<(*args) if (1==args.length) && args[0].is_a?(Proc) proc {|*a| self.call(args[0].call(*a)) } else self.call(*args.flatten) end end end # Proc