Just for your fun and horror

Elke Kasimir elke.kasimir@catmint.de
Sat, 17 Feb 2001 12:24:03 +0100 (CET)

Another good exam question (Hmm!):

What does last (last (map return [1..])) lastly return given that
last (return (not True))?

I also would prefer "unit". "return" makes sense  for me as syntactic 
sugar in the context of a "do"-expression (and then please like an 
unary prefix-operat or with low binding power...).

An alternative sugary would be "compute": When a monad represents
a computation, "init" returns a computation with a result, not 
just the result:

foo x = if x > 0 then compute x*x else compute -x*x 

By the way, an alternative for "do" would be "seq" (as in occam) to
indicate that operations are sequenced:

getLine = seq
                    c <- readChar
                    if c == '\n'
                      then compute ""
                      else  seq
                                 l <- getLine
                                 compute c:l

But such a discussion has probably already been taken place some years
ago. It would be interesting for me to know the arguments that led to
the choice of "return" (and "do").


"If you have nothing to say, don't do it here..."

Elke Kasimir
Skalitzer Str. 79
10997 Berlin (Germany)
fon:  +49 (030) 612 852 16
mail: elke.kasimir@catmint.de>  
see: <http://www.catmint.de/elke>

for pgp public key see: