[Haskell-cafe] Please allow beginners to vocalize code. >>= :: -> &&& <- -<

Richard Kelsall r.kelsall at millstream.com
Tue Jan 8 15:36:52 EST 2008


Derek Elkins wrote:
> I don't why you think, "[t]here [is] a misconception that it somehow
> helps beginners to understand things if they are not told how to 'say'
> these strange new symbols."  If you had said, "it doesn't help beginners
> to be told how to 'say' these symbols", I would have less of an issue.

Sorry, I got a bit convoluted there. I suppose what I'm trying to
say is that I struggle when I am not given direct words to attach to
symbols. A word for the symbol allows me to read the program. Imagine
two experienced Haskell programmers on the phone, one reading a Haskell
program snippet to the other.

For example Hutton first uses the  =>  symbol on p.7

"In Haskell, every function has a type that specifies the nature of
its arguments and results, which is automatically inferred from the
definition of the function. For example, the function sum has the
following type:
Num a => [a] -> a
This type states that for any type a of numbers, sum is a function that
maps a list of such numbers to a single such number."

This is a good description, but doesn't seem a likely way for an
experienced programmer to read that statement over the phone to
somebody else. I am guessing things like

"For all Num a, list of a to a."
"Num a implies, list of a to a."

In appendix B at the back of the book I find the 'meaning' of  =>  is
'class constraint', but again this doesn't seem a likely way of 'saying'
it.

Now supposing you were on the phone to a Haskell programmer and you
wanted to say this

f :: Int -> Int

I imagine you might say "f maps Int to Int" or "function f has type
Int to Int". Both symbols have been translated directly to words. Nobody
would say "f, colon colon, Int, dash greater than, Int".

> I don't think anyone thinks that it is helpful not to provide a reading,
> and in my experience, a reading is usually provided, directly or
> indirectly, when such things are introduced in (larger)
> introductions/tutorials/textbooks.  However, as you've already found,
> some things don't seem to have meaningful readings.  E.g. you list -< in
> the title, but the motivation of that notation has nothing to do with it
> having a clear "reading", but rather comes from a graphical perspective,
> x <- f -< y 
> I.e. that looks like an arrow pointing left with -< the tail.  That
> said, two readings are indirectly provided in
> http://www.haskell.org/arrows/sugar.html
> 



More information about the Haskell-Cafe mailing list