Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

i love haskell, what do?

Name: Anonymous 2012-01-23 7:24

/program/, help me. I'm learning Haskell, and I love it. What can I do to rectify my correct opinion that functional programming is a wonderful and powerful tool?

Name: Anonymous 2012-01-23 8:59

>>1
A declarative style of programming sounds specious. It seems all you have to do is provide a description of the problem without having to worry about details of how it is solved. In practice though, performance matters and you can't just give any description. You have to pick a specific description based on the imperative program it corresponds to. In the end you have to create both an imperative and a declarative program. The declarative program may look more elegant and concise than the imperative one would have, but it's a leaky abstraction.

Take this example of memoization from haskellwiki

memoized_fib = (map fib [0 ..] !!)
   where fib 0 = 0
         fib 1 = 1
         fib n = memoized_fib (n-2) + memoized_fib (n-1)

This works, because the listmap fib [0 ..] is cached between subsequent calls to the function and because !! will evaluate the elements of the list up to the one requested (and no others) in the right order.

Because the memoization relies on the imperative program the haskell compiler generates, if you want to write or understand such code, you must know the imperative program it compiles to.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List