-
Notifications
You must be signed in to change notification settings - Fork 42
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
Concatenative type syntax #197
Comments
It's not very readable. In the language I'm (very slowly) developing, there's some sugar: This sugar is universal, so you can use it not only in types, but also in code:
You can even write something like |
At least you're using square brackets - after many years of Rust I'm very much over the angle brackets! Hoping most newer languages dodge this syntactic bullet! |
Yeah, I considered this a while ago (#132), and the syntax still has an opening for this notation. It’s still something I’d like to do, especially if users end up wanting to do type-level programming or factoring of type expressions (#162). I just haven’t gotten around to working on it because I haven’t figured out a lot of the details—for example, how to get the same sort of syntactic sugar that type signatures have currently, or whether/how user-defined functions are available at the type level. You could get universal quantification by “running” a type expression on a stack of fresh type variables. For example, the type of the identity function could be |
I actually do this for consistency. This syntax is space dependend though, |
@suhr As an aside, the overloading of |
My bad, it should be
It's hard to write something that will turn |
By the way, I wonder that's the good way to provide type parameters. From the one side, they are just parameters, so |
@brendanzab Angle brackets aren’t a problem because Kitten’s syntax generally separates types clearly from values. We just lex them as distinct tokens and parse them as brackets or operators based on whether we’re parsing a type or an expression. It doesn’t require any other hacks like a stateful parser, and it looks more familiar to people. When I don’t have a compelling reason to do things differently, my policy is to fall back on C(++). These aren’t yet implemented, but the cost is using the “turbofish” operator |
On a purely subjective level it's the painful syntactic weight (ugly pointiness) of angle brackets that I'm objecting to, especially when working with more interesting types. Semantics-wise, using the same syntax for application at the value level and the type level is an investment in future 'aha!' moments for your users. |
I'm noticing that you're using an applicative style for types, with the
<>
angle brackets to denote type applications. Have you thought of going completely crazy and concatenative at the type level? This would lead to the nice parallel between the type syntax and the value syntax that you see in Haskell, Idris, etc. Eg.Would be:
Kind of reminds me of what the MLs do with
'a list
, although it makes more sense in the context of a concatenative lang. Would be interested to see what universal quantification (or even pi types) would look like in that world!The text was updated successfully, but these errors were encountered: