[Haskell-beginners] single responsibility principle vs functional programming

Isaac Dupree ml at isaac.cedarswampstudios.org
Tue Jan 26 21:30:17 EST 2010


Joe Van Dyk wrote:
> So I'm still pretty new to functional programming.
> 
> In OOP, you have the concept of each class having a
> single-responsibility (or reason for changing).  See
> http://en.wikipedia.org/wiki/Single_responsibility_principle
> 
> I'm having problems seeing how that concept maps to functional
> programming.  Perhaps it doesn't?

It's called "modularity" in my book, and it even works in C.  You put 
functions/data-structures/etc. that are related* to each other in the 
same file, or directory-of-files, or entire library. (*a quite similar 
concept to your single-responsibility principle)

In Haskell, there is a module system that lets you choose what to export 
/ not export from which files (in a more principled way than in C). 
Think of it as "private"(a la OOP) implementation details if you like.

-Isaac


More information about the Beginners mailing list