dex-lang
dex-lang copied to clipboard
Use < > brackets for effects
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:
- implicit quantification
- records
- 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.
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.
Oh yeah, I forgot about the angle bracket in ->
.
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
Oh, I guess I need to look at real Koka code, I was basing my assertion on the old 2016 Koka paper
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!