I will humbly offer my opinion as a guy who is learning both D and Haskell.

Here are some of the finer points of Haskell that has directly improved my programming:

Referential Transparency takes away mutation and gives you reliable composition. To do anything useful in Haskell you have to at some point compose functions. To compose functions effectively you have to think about what your functions input/output are and how they relate. So instead of having a sink function that returns nothing and does magic inside you think in terms of testable individual components that focus only on one aspect of the computation.

Recursion and Breaking apart tough problems. When you are forced to think recursively you have to think of your base cases, your invariants, your pre and post conditions, and how you get from x[k] -> x[k+1] without violating your contract. Again it encourages deliberate design as opposed to empirical exploration.

Type Classes are an abstraction on types similar to those found in D and C++. It removes the idea that interfaces are an OOP construct instead shows you how you can design the basis of communication between data by supporting a set of functions.

Lastly, I found GHC really helpful in its brutal nit-picking of types, inferences, etc. This helps in making the transition from writing code for the compiler, to writing code with the compiler.

How this has benefited my view of D:

Think about the overall system as a series of composable components that have predictable behaviour. Think about the details of each component and how you can verify the output. Think about the base-case and the special-case when creating a procedure. Use the syntax to help the compiler understand what your intent is.

D helps with:

* uniform function syntax
* templates
* guards
* contracts: in, out, body
* built in unittest
* compile time assertions, conditionals, expressions

In closing, I don't think Haskell is meant to make you a better programmer by flexing your higher-order function manipulation or using FP idioms in an OOP/imperative context. It's strength, at least for me, has been the thought process behind functional programming and how to apply its view of data to your programming language.

Reply via email to