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

David Virebayre dav.vire+haskell at gmail.com
Thu Jan 21 08:49:53 EST 2010

On Thu, Jan 21, 2010 at 11:20 AM, Stephen Blackheath [to
Haskell-Beginners] <mutilating.cauliflowers.stephen at blacksapphire.com>

> All Haskell functions are pure without exception.  For example:

> greet :: String -> IO ()
> greet name = putStrLn $ "Hello, "++name

> This is a pure function from String to IO ().  This function (like all
> Haskell functions) has no side effects.  Its return value of type IO ()
> merely _represents_ an IO action.  The runtime system knows how to act
> on this representation.

> This also means that there is no such thing in Haskell as marking a
> function as side-effecting.

> This distinction may be subtle, but it's important.

Coming from an imperative background, I have found that distinction to
be confusing.
I like to understand how things work. For example, haskell's lazyness
confused me a lot until I heard about thunks.

Back to IO. What exactly would be the representation of an IO action,
if not an abstract notion ? Hopefully that is optimised out by the
compiler. Indeed, If I look at the compiled output of a simple
program, it looks to me like the effects are executed within the
function, and no special structure is returned.


More information about the Beginners mailing list