[Haskell-beginners] How to think like a functional programmer?

Amy de Buitléir amy at nualeargais.ie
Thu May 26 19:20:02 CEST 2011


On 26 May 2011 17:27, Costello, Roger L. <costello at mitre.org> wrote:

> How did you “flip the switch” in your brain to the functional mindset?
>
>
For me, one thing that changed is that I now tend to focus more on the data
*transformations* rather than on the data itself. I tend now to group
similar transformations into modules. (Before, as an OO programmer, I would
have thought of each module as a class of objects, so I would have grouped
everything that acts on that object or that the object does into one class.)
Eventually you want to build a chain of transformations that takes the input
and produces the output you want.

Another way to visualise it: Instead of thinking of the steps to solve a
problem, think of the solution as a series of definitions. Write a
definition (an equationof of the result you want in terms of simpler things.
Write definitions of those simpler things in terms of things that are even
simpler. And so on, until you can build a pyramid of definitions that
defines the final output in terms of the input.

I found it helpful to post a few small code samples on this forum, and to
ask for suggestions for a better implementation.

Good luck!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110526/c6bbae4e/attachment-0001.htm>


More information about the Beginners mailing list