-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Generalised dot syntax for postfix application #342
base: master
Are you sure you want to change the base?
Conversation
I have a love/hate relationship with this proposal. But mostly love. |
If we do this, we should tell the elaborator not to generalise names after dots to avoid |
I expect |
I'm a bit scared of this one, although I do kind of like it... I think... maybe if we are going to have it, it should be hidden behind a I think we've overdone syntactic trickery and experimentation in the past, but somehow I still want to play with this... |
I'll feel a bit awkward if they're identical:
|
Here's a more radical idea:
.(expr) and .name
are postfix applications ofexpr
/name
that bind tighter than application.Some examples:
printLn user.name.length
"hello".length.(+3).printLn
map (.length.show) ["foo", "booo"]
mySet.(insert "hello").(insert "world") <+> otherSet
5 .div 3
5 .(div {ty=Int}) 3
foo .(NS.(>>=) {lin = True}) bar
This patch did not require any changes to the existing code in the stdlib and tests (other than the recent record test).
One issue I see with this is that idiomatic functions put the main arguments last so you can't write
myList.map (+1)
and you have to writemyList.(map (+1))
instead. There ismyList.for printLn
but that works only inApplicative
contexts.