[Haskell-cafe] Rethinking OO idioms
zanesdad at bellsouth.net
Thu Sep 30 08:54:49 EDT 2004
John (and Haskell community),
I just subscribed to the Haskell mailing list the other day and this
posting grabbed my attention. I've been workin with Python for a few
years now and have recently decided to try to expand my horizons to
Haskell (and OCaml). I love Python, but I feel like I could learn a lot
that could be applied to Python from understanding FP languages like
Haskell (and OCaml). That being said, can you point me to any
documentation online or books that are more suited to a Python person
trying to understand Haskell (and OCaml)? Any help is appreciated.
John Goerzen wrote:
>I've worked with languages with object-oriented features for awhile now.
>Python and OCaml, the two with which I work the most, both have OO.
>One of my first projects in Haskell would be to write a Haskell version
>of Python's ConfigParser class. I wrote, a version of this for
>OCaml that works very well.
>In a nutshell, ConfigParser is a utility for working with sectioned
>configuration files in a style similar to the familiar .ini files from
>Windows. It has methods to read a configuration file, get/set the items
>that are being configured, and write a new file back out. This, then,
>is a fairly typical metaphor for OO programs: an instance of a class has
>some state that can be accessed or modified, and possibly stored and
>So I am thinking about a ConfigParser for Haskell. The first thing that
>occured to me is that Haskell has no OO features, so I'm not sure what
>is the best way to handle the "class" and its various methods.
>The next thing that occured to me is that, unlike OCaml and Python
>classes, Haskell has no mutable variables. A call like
>config.setOption("main", "initpath", "/usr") in Python -- which alters
>the state of the config object and returns nothing -- would be
>impossible in Haskell (unless perhaps the FiniteMaps are mutable
>I guess I'm having trouble translating this common OO language paradigm
>into the Haskell world.
>Thanks for any insight.
>BTW, if I get a working ConfigParser for Haskell, I will publish it
>under the GPL like all the rest of my code.
>Haskell-Cafe mailing list
>Haskell-Cafe at haskell.org
More information about the Haskell-Cafe