Consider the following extension to Haskell syntax:
let { foo = ... } in let { foo NR= ... foo ... ; ... } in ...
NR= ("Non Recursive Equals") is a new keyword which acts like = except does not introduce a recursive binding for the symbol(s) on the left hand side. So the call to foo
inside the inner let
refers to the outer foo
, not a recursive call to itself.
Instead of many nested let
blocks, let letseq
be syntactic sugar in which the order matters. letseq { foo = 0 ; foo NR= foo + 1 ; foo NR= foo + 1 } in foo
.
Similarly, we want NR<- within do
notation.
This feature allows an imperative coding style, an illusion of modifying data in place, for situations that want it. Nowadays, the same effect is achieved with foo foo' foo'' foo'''
and pray you don't miscount the number of primes.
2 comments :
You don't need NR<- in do as that is the default semantics in the absence of mdo/do rec.
The common way to do this for let is to use case instead of let.
case ... foo ... of
foo -> ...
Then no language feature is required for either use case.
Thanks for the information! I did not know this.
Post a Comment