On Fri, Dec 28, 2007 at 11:00:21PM -0800, Tracy R Reed wrote:

I really like the idea of purely functional programming and the idea that you can theoretically prove correctness for some codes. Still trying to grok monads though.

There are two ways of looking at Monads.

  - Warm fuzzy things that allow you to do stuff that looks like side
    effects in a purely functional language.

  - Visciously complicated mathematical things.

The first gets you to where you can do I/O and technically do anything in
Haskell.  The second is where you can do powerful things and make your own
monads.  Making of monads seems to be where people are able to take things
that are very complicated and express them in a way that seems simple, at
least can be used in a simple way.

There's nothing wrong, at all, with a global that doesn't change.  The
problems come with globals that can change value.  Things define'd will

Right. If you can somehow guarantee (by declaring it static or whatever) that it won't change. But as long as it could possibly change via a bug it's a problem.

One advantage of Haskell, globals just can't change.  Although it seems to
be a common request people have asking how to make one that does.  Turns
out, there isn't a way of doing it that is reliable.  You have to create a
state variable, inside of unsafePerformIO, and make sure you use enough
pragmas to keep the compiler from inlining it.  If the compiler inlines the
term, then each inline instance will get their own copy of the state.

Yep. Still trying to grok closures also. I like the idea of designing smart data structure that can do things themselves as opposed to functions to manipulate data structures that are external to them.

I seem to remember SICP covering this well.  There is a lot of similarity
between classes and closures, except that you don't declare anything for
closures, they are inferred from the structure of the program.

Python has real closures, and it's even functional about it (a closure
can't modify an outer variable).  Although, it's easy to just have the
variable be a reference to something and change what it refers to.

Again, "pure" functional programming doesn't have any mutable state.

Yep. And just try explaining that it is possible to write useful software in a language that has no variable assignment to a 20 year procedural programming coder and see how far you get. :)

<http://www.davidb.org/darcs/harchive/>

It's a networked content addressible backup system written almost entirely
in Haskell.  It works reliably, although I haven't maintained it.

I would consider it useful :-)

The big problem I have with it is when I move away from Haskell for a
while, it seems to take a long time before I can even understand the code
again.  With most other languages, I can still read code written in them
later.  It might take a little while to remember how to write it, though.

BTW, OCaml is another good language for someone wanting to understand
closures and that type of programming.  It is Hindley-Milner statically
typed (like Haskell).  It has a kind of quirky syntax that people seem to
either love or hate.  I've written quite a bit of code in ocaml as well.

Dave


--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to