[Haskell-beginners] Haskell as a useful practical 'tool' for intelligent non-programmers

Michael Orlitzky michael at orlitzky.com
Sun Apr 29 04:22:34 CEST 2012


On 04/28/2012 08:47 PM, Mike Meyer wrote:
> 
> Ruby makes a bad fit if Haskell is a goal (and that's a good
> goal). Ruby functions aren't first-class objects, and can't simply be
> passed to other functions as arguments.

That's like, the least true thing you can say about Ruby =)

A simple test program:

  $ cat fcf.rb
  def foo
    puts "foo"
  end

  def call_arg(f)
    f
  end

  call_arg(foo)


Running it:

  $ ruby fcf.rb
  foo


Moreover, every function and method implicitly accepts a function as an
argument:

  $ cat yield.rb
  def call_block
    yield
  end

  call_block { puts "foo" }

This allows you some nice do-block syntactic sugar instead of lambdas
which can get ugly.

  $ ruby yield.rb
  foo



More information about the Beginners mailing list