Conversation
31efcd0 to
ede5fdb
Compare
|
Previously: #2435. Seems to have been closed for lack of a proper proposal; having a proof of concept changes that, presumably..? |
|
@hdgarrood I think so, yes. This PR implements exactly what was discussed in that issue. I can write up a proposal that matches it and then we can see how it works out immediately. |
|
I think this documents the behavior of this PR quite well, with rationale for each deviation from GHC (which is quite a lot lol): Applicative do-notationThe benefits of applicative do-notation are documented elsewhere. This proposal is about the specific implementation in PureScript. This proposal uses Differences from GHCGHC implements applicative do-notation. This proposal adds applicative do-notation to PureScript, with two important differences:
SyntaxThe syntax of applicative do-notation differs from that of monadic do-notation in two aspects. It is otherwise the same. Opt-in applicative desugaringDue to strict evaluation, it is not preferred to transform any f 0 = pure 0
f n = do
x <- a
y <- f (n - 1)
pure $ x + yIf this were translated to applicative combinators, Therefore this proposal adds a new keyword No special interpretation of
|
|
Thanks for the PR and the detailed explanation! I have a few comments:
And one random thought:
This is a relatively benign change, but we should be sure to test it thoroughly. It's also breaking since it reserves a new keyword, so it'd have to go into 1.0 at the earliest. |
|
@paf31 Thank you for the comments. I will now comment on them.
|
|
I figured out a way to get something like ApplicativeDo using just rebindable syntax: http://try.purescript.org/?gist=91c8c58419ec2683d46b8d83eb88614c So we should consider whether it's worth new code in the compiler if we can get 90% of the feature as a library. To compare the two, this approach requires you to rebind Edit: actually, this code illustrates exactly why ApplicativeDo is useful, since the name and email fields are the wrong way round :( |
|
@rightfold Could you please rebase this one? |
|
@paf31 On it! |
b765cdb to
de95bbb
Compare
|
Thanks! |
Usually we discuss this stuff before PRing but I was bored so here it is anyway. If I've done it totally wrong I'd be glad to hear that, if not that's great! 😅
Bindings are only in scope in the
pure'd result and inletstatements.