Skip to content
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

Use < > brackets for effects #787

Open
duvenaud opened this issue Mar 10, 2022 · 5 comments
Open

Use < > brackets for effects #787

duvenaud opened this issue Mar 10, 2022 · 5 comments
Labels

Comments

@duvenaud
Copy link
Contributor

With the introduction of using {} in type signatures to implicitly quantify over variables, there are now 3 distinct uses of curly braces that all show up in type signatures:

  1. implicit quantification
  2. records
  3. effects

The effect syntax also uses vertical bars |, which make their syntax confusingly close to that of variants. For example, here are two different type signatures in the prelude:

One to do with effects:

def liftState {a b c h eff} (ref: Ref h c) (f:a -> {|eff} b) (x:a) : {State h|eff} b =

One to do with variants:

Iso {foo: a | ...b} (a | {|...b}))

So I suggest we use angle brackets < > for effects. They aren't used at all in the current syntax. They would also give a more explicit nod to Koka for developing some of these ideas.

@dougalm
Copy link
Collaborator

dougalm commented Mar 10, 2022

I'd be in favor of that. I think the reason I went with {} rather than <> initially was that <> looks strange when you write a function's type, because it conflicts with the -> arrow a bit: a -> <eff> b. But I don't think it's a major problem, and we almost exclusively use def syntax these days anyway.

@duvenaud
Copy link
Contributor Author

Oh yeah, I forgot about the angle bracket in ->.

@tscholak
Copy link
Contributor

tscholak commented Mar 14, 2022

For reference,

Unison uses curly braces as well, https://www.unison-lang.org/learn/language-reference/ability-declaration/.
Koka uses nothing or <> when necessary, https://koka-lang.github.io/koka/doc/book.html#sec-effect-types.
Eff uses =>, https://www.eff-lang.org/handlers-tutorial.pdf, I think (unclear due to absence of docs).
Frank uses [], https://github.com/frank-lang/frank/blob/master/examples/exception.fk.

You may want to add Dex to the list here: https://en.wikipedia.org/wiki/Effect_system :D

@duvenaud
Copy link
Contributor Author

Oh, I guess I need to look at real Koka code, I was basing my assertion on the old 2016 Koka paper

@apaszke
Copy link
Collaborator

apaszke commented Mar 15, 2022

I think we can't do what Koka does today, because that's too similar to function application. Koka uses parens, which makes their current syntax unambiguous. But I've been wanting to switch us to angle brackets for a while, so let's do it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants