[Haskell-cafe] Wow Monads!
Richard A. O'Keefe
ok at cs.otago.ac.nz
Wed Apr 19 09:10:15 UTC 2017
> On 19/04/2017, at 5:05 PM, MigMit <migmit at gmail.com> wrote:
> I think the problem with macros in general is that their semantics is defined purely in terms of code they generate. Not in terms of what that code actually does. As for me, I want to think about the things I need to achieve, not about the code to write.
I find this a rather baffling comment.
Let's take SRFI-8, for example, which defines the syntax
(receive <variables> <expression> <body>)
which the SRFI defines *semantically* (paraphrased):
- the <expression> is evaluated
- the values are bound to the <variables>
- the expressions in the <body> are evaluated sequentially
- the values of the last <body> expression are the values
of the (receive ...) expression.
The syntax is *implemented* thus:
((receive formals expression body ...)
(call-with-values (lambda () expression)
(lambda formals body ...)))))
but the semantics is *defined* by the specification.
The whole point of a macro such as this is for the user
*NOT* to "think about the code to write". The code that
gets generated is of no interest to the ordinary programmer
(Reflecting on the subject of this thread,
'receive' is actually pretty close to >>= .)
More information about the Haskell-Cafe