Python-based monads essay (Re: Assignment versus binding)

Marko Rauhamaa marko at pacujo.net
Fri Oct 14 01:01:23 EDT 2016


Gregory Ewing <greg.ewing at canterbury.ac.nz>:

> Marko Rauhamaa wrote:
>> This suggests even the promoters of functional programming
>> intuitively prefer imperative programming, but that's ok as long as
>> it's all functional under the hood.
>
> You make it sound like functional programmers like functional
> programming because it gives them a warm fuzzy feeling. I don't think
> that's true -- there are specific reasons they like it, and those
> reason still apply when I/O is expressed using a monadic structure.
>
> Read Part 2 - I have something to say about that at the end.

I've read it. This looks awfully imperative to me:

   main = do
     putStrLn "Hi, what's your name?"
     name <- getLine
     putStrLn ("Aren't monads great, " ++ name ++ "?")

Scheme programmers have (begin ...) for sequential blocks and (do ...)
and (for-each ...) for loops.

As your Part 2 indicates, Haskell's use of monads to implement I/O is
not pure functional programming. The order of execution is significant
and functions have side effects.

Nothing wrong with any of this. I'm all for mixed paradigms.


Marko



More information about the Python-list mailing list