[Haskell-beginners] Re: testing and the culture of Haskell

Heinrich Apfelmus apfelmus at quantentunnel.de
Wed Jan 20 15:48:29 EST 2010


Stephen Tetley wrote:
> Heinrich Apfelmus wrote:
>> Static typing is a great help, it is not uncommon for Haskell code to be
>> correct on the first try once you convinced GHC that it's type correct.
>> There is much less need for TDD than in other languages.
> 
> Ah, maybe the type checker is given all credit here, when perhaps it
> should be shared?
> 
> With functional programming languages you are largely programming with
> expressions - Scheme has the (begin ... ...) form for sequencing and
> ML has sequence control structure (;), but there is simply less
> control flow in typical functional programs than imperative ones
> (there is also less use of assignment but that's hardly news of
> course).
> 
> Figuratively speaking, functional programs have 'fewer movable parts'
> to go wrong (vis-a-vis incrementing variable for loop indexes etc.
> whereas map, fold, unfold, ... can be written once and used anywhere),
> hence static-typing + control-flow reduction (+ limited use of side
> effects) hopefully leads to first-time correctness.

Fair enough.

However, in a sense, one can interpret the pure in purely functional as
a property of the type constructor (->) , i.e. a function of type  (a ->
b)  is guaranteed to not have side effects. In this light, ML and Scheme
are lacking a very important type: they only have functions with side
effects. Or more precisely, their type system does not distinguish
between functions with and without side effects.


Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



More information about the Beginners mailing list