[Haskell-cafe] Is there a null statement that does nothing?

michael rice nowgate at yahoo.com
Sun Oct 25 06:26:22 EDT 2009


Hi Curt,

Thanks for the tips. Looks like return () would be a good candidate for that null statement I was seeking earlier.

Michael

--- On Sun, 10/25/09, Curt Sampson <cjs at starling-software.com> wrote:

From: Curt Sampson <cjs at starling-software.com>
Subject: Re: [Haskell-cafe] Is there a null statement that does nothing?
To: "michael rice" <nowgate at yahoo.com>
Cc: "haskell-cafe at haskell.org" <haskell-cafe at haskell.org>
Date: Sunday, October 25, 2009, 12:08 AM

On 2009-10-21 18:27 -0700 (Wed), michael rice wrote:

> Those nested IF/THEN/ELSEs are real killers. I kind of use them to
> sort out my thoughts, then end up with a nested mess. The restructuring
> to WHENs went smoothly and looks a lot cleaner besides.

Indeed. Monadic control flow is one of the basic keys to being able
to write nice code in Haskell; it's the moral equivalant of using
polymorphism rather than than "case" or "switch" in OO languages. (Well,
some would disagree, but that gets into the whole OO vs. functional
debate.)

You'll probably want to spend some time with one of the zillion monad
tutorials at some point (I like "All About Monads") to learn more about
these things.

BTW, look up the source code for "when". :-)

  http://haskell.org/ghc/docs/latest/html/libraries/base/src/Control-Monad.html#when

cjs
-- 
Curt Sampson       <cjs at starling-software.com>        +81 90 7737 2974
           Functional programming in all senses of the word:
                   http://www.starling-software.com



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091025/12232d97/attachment.html


More information about the Haskell-Cafe mailing list