Anonymous closures with Proc,new, lambda and ->

Naw, monads are actually really, really easy. They’re just poorly
explained… one day, they just clicked for me, and I can’t believe it
took
me all this time to learn them.

Steve K. wrote in post #994098:

Naw, monads are actually really, really easy. They’re just poorly
explained… one day, they just clicked for me, and I can’t believe it
took
me all this time to learn them.

According to this doc, anybody could have invented monads:

http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html

Brian C. wrote in post #994123:

Steve K. wrote in post #994098:

Naw, monads are actually really, really easy. They’re just poorly
explained… one day, they just clicked for me, and I can’t believe it
took
me all this time to learn them.

According to this doc, anybody could have invented monads:

A Neighborhood of Infinity: You Could Have Invented Monads! (And Maybe You Already Have.)

I’ve looked at that before. I dropped out of class at the second
diagram.

My interest in learning functional programming( or at least the
foundation of) is because I haven’t done it before( though I flirted
with scheme a couple years ago). I don’t really know what monads are I
was just compiling a list of “things I should look into” for future
reference to take the autodidactic approach to learning functional
paradigms.

When I first to the plunge to learn object oriented paradigm from a
procedural background I know I made it harder than it is. The first
thing I did to tackle the learning curve was to break down the four
concept layers encapsulation, inheritance, polymorphism and
abstraction. It wasn’t until I began creating composite objects,
sending messages and creating observer objects until it finally hit me
and all seemed so simple that I didn’t understand why it was so hard
in the first place.

As a side note the Ruby Language shows just how well an object
oriented program is. Simply the organisation behind every object in
it’s own inheritance hierarchy all the way down to BasicObject,
polymorphic design of variants like lambda and Proc.new. Even the
redefinition of operators to deal with primitive and abstract data
types in their own domain( i.e. 3 * 3, [42,3] - [3,45,54], "lamda " *
3)… This is inspirational for modelling my own objects with this
type of object framework if I may be so Propos.

My background consists of posix shell scripting( ash, awk) and some c.
My interest in ruby has been to add a general purpose programming
language to my toolbox. After I get to a proficiency apex with ruby I
have in the learning queue to go back and refresh my c knowledge and
take the time to truly grok the fundamental data structures and
algorithms. Once that goal is hit I had planned to move to c++. C++0x
will be incorporating lambda and closures. I imagine c++ will be a
life long journey as it’s a multi-paradigm programming language as
well. (is it 4 or 5 languages in one now?)

As Robert pointed out Ruby may not be the best language to learn
functional programming concepts with. This speaks volumes to me as I
am a huge proponent to the attitude to use the right tool for the
right job. If I am not mistaken most of these languages are dialects
of Lisp( correct me if I am wrong). I am not in a position to learn to
earn nor am I a mathematician. My interest is to simply better myself
as a programmer.

Those of you who have used Haskell monads does one really need to have
invented string theory to understand it or is it like how I explained
the object oriented learning curve where one might over-think it’s
simplicity therefor overcomplicating their comprehension of the
paradigm?

Also is there a canonical or pedagogical tutorial for me to start
with? Hello, World! =)

Which language would be a decent new users language which would fit
well into my unix toolkit above as well as threading the knowledge
back into ruby’s hybrid programming? (scheme, haskell, clojure common
lisp)

Thanks in advance

~Stu

On Thu, Apr 21, 2011 at 8:31 AM, Stu [email protected] wrote:

Also is there a canonical or pedagogical tutorial for me to start
with? Hello, World! =)

Well, the typical program which prints “Hello World!” is difficult for
purely functional languages since IO is a side effect. Of course, a
language which could not interface with the outside world would be
deemed to be purely academical. Maybe in the functional world the
equivalent example should be “2 * 4”? :slight_smile:

Cheers

robert

On Thu, Apr 21, 2011 at 8:31 AM, Stu [email protected] wrote:

My interest in learning functional programming( or at least the
foundation of) is because I haven’t done it before( though I flirted
with scheme a couple years ago). I don’t really know what monads are I
was just compiling a list of “things I should look into” for future
reference to take the autodidactic approach to learning functional
paradigms.

I just came across this report how others teach FP:

Cheers

robert

Stu wrote in post #994213:

As Robert pointed out Ruby may not be the best language to learn
functional programming concepts with.

I would agree with that. Functional programming is much different than
creating a ruby closure.

Also is there a canonical or pedagogical tutorial for me to start
with? Hello, World! =)

Learn you a Haskell for great Good!

http://learnyouahaskell.com/

Just start the tutorial, and see what you can see.

Stu wrote in post #994213:

Which language would be a decent new users language which would fit
well into my unix toolkit above as well as threading the knowledge
back into ruby’s hybrid programming?

If you are coming to functional programming from an imperative
background, I would recommend Erlang as a sound starting point. It’s a
highly practical language for real-world applications, albeit with a
frustrating syntax.

In Erlang, functions can and do have side effects, in particular the
sending of messages between processes. However variables can be bound
only once, and data structures are immutable. There is no “A = A + 1”
:slight_smile:

So each individual process is functional, and you start getting your
head around functional algorithms “in the small”, such as using
recursion for looping and traversing data structures. But you don’t have
to worry about building your entire application in a purely functional
form.

The immutability of data means concurrency is easy (no mutexes!) and you
have zero-copy passing of data structures, at least between processes on
the same node.

On Thu, Apr 21, 2011 at 7:06 PM, Steve K. [email protected]
wrote:

+1 for learn you a haskell.

Professor Robert Harper thinks “Haskell is not suitable for teaching
introductory functional programming”:

Cheers

robert

+1 for learn you a haskell.

Ruby does have functional elements, but you won’t truly learn FP,
because
Ruby is all about structuring programs in an OO fashion, and solving
small
problems in FPish ways when it makes sense. If that makes sense. Using a
‘real’ FP language will make you structure your problems in a functional
way…

Erlang would be okay too, but Haskell is better. Scheme is also solid.
But
Haskell is uber-strict, and so you’ll end up really learning FP well.

I’m gonna give scheme a go. I did run through a bit of
http://tryhaskell.org/ though.

On Wed, Apr 27, 2011 at 6:49 AM, Robert K.

Professor Robert Harper thinks

Well, non-professor Steve disagrees. :stuck_out_tongue: