Re: updating labelled fields
Hello.
I like this idea, but I think it will cause ambiguity in parsing. Consider:
blah = do {foo} ...
should foo be parsed as a statement list (under the assumption that the open brace is instead of using layout) or as an assignment, as in:
blah = do {foo} x <- bar
(which probably wouldn't typecheck, but we don't know that at parsing.) i could be wrong and it might be able to be made work, but i'm not convinced...
I don't think this is ambigous -- do is a keyword, so no record field update can be assumed after it. Zdenek _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com
[SNIP]
I don't think this is ambigous -- do is a keyword, so no record field update can be assumed after it.
Okay, I thought about it some more and I agree. So, as it stands the proposal is to add the following pieces of sugar: 1) ({assignments}) becomes \x->x{assignments} 2) x{as, field =, bs} becomes \y->x{as, field = y, bs} 3) x{as, field, bs} becomes \f->x{as, field = f (field x), bs} So then if we see: ({field=}) this gets desugared to \x -> x{field=} which gets again desugared to \x -> \y -> x{field = y} Similarly, ({field}) becomes \x -> x{field} becomes \x -> \f -> x{field = f (field x)} The only "problem" i see with this is that I would probably want the lambda terms to be in the other order, so, just as you would write: apField f x you would write: ({field}) f x But this is backwards...putting a call to flip in sort of defeats the purpose. One thing that could be done would be to rewrite the rules as: 1) {field=} becomes \y -> ({field=y}) 2) {field} becomes \f -> ({field $= f}) -- assuming $= exists 3) {stuff} becomes \x -> x{stuff} where "stuff" has no dangling = and $= and stuf flike that If we go this route, I would suggest that instead of just {field} in #2, we make it {field $=} to keep parallelism with the $= thingy and to make it clear that we're doing function application. So, again, {field =} ==> \y -> {field=y} -- rule 1, there's a dangling = ==> \y -> \x -> x{field=y} -- rule 3, no dangling things and similarly: {field $=} ==> \f -> {field $= f} -- rule 2, there's a dangling $= ==> \f -> \x -> x{field $= f}-- rule 3, no dnagling things I believe this is still amenable to fitting in the syntax without pouncing on anything. Assuming I can ever get my cvs'd copy of ghc to compile (sigh), I would be willing to implement this if there are no objections... - Hal
participants (2)
-
Hal Daume III -
Zdenek Dvorak