3 ms·
I found it interesting that you tag the types like that. I’m working on a small language idea right now where I wanted to treat bindings as first class, and ha
by CuriousSkeptic 7y ago
I found it interesting that you tag the types like that.
I’m working on a small language idea right now where I wanted to treat bindings as first class, and having them combine with row polymorphism into a construct subsuming tuples, argument lists, and environments into a kind of unified thing, with a similar result in mind. Even to the point of perhaps demoting scalars from first class status actually, point being that where there is a value there should be a name (borrowing the rdf model here)
So (n1: v1) might be a value v1 bound to n1. And (n2: v2) another. (n1: v1)(n2: v2) = (n1: v1, n2: v2), and one could even imagine (n1: v1, n2: v2)(n3: n1+n2) as a valid expression. Which of course is equivalent to
(
n1: v1,
n2: v2,
n3: n1+n2,
) not entirely unlike a let-expression
(I’m thinking of unifying terms and types so a lambda would simply be such an expression where v1 and v2 are types)
Oh well just a toy in my head at the moment. Just found it interesting to see similar tag combining semantics.
(As for namespace I was thinking to borrow the plan9 approach of binding things dynamically, using something like Scalas implicits, for evaluation to do a kind of dependency injection thing, but a global lexically scoped tree for typing it)
- ben509 7y agoMy motivation was to try to accommodate the way I've seen people think and work. So the type system lets you describe anything using literal expressions, and if you match everything up, it should Just Work, or at least have intelligent complaints. (I hope.) So a discriminated union is just a tag stuck in front of something else. > Even to the point of perhaps demoting scalars from first class status actually, point being that where there is a value there should be a name In theory, an integer is just an uncountable enumerated type. I haven't done that to treat it as opaque / atomic, but you could imagine it essentially being 1~~, 2~~, 3~~, etc. But that might come back if I want to have sane semantics of floats, as in not treating NaN as a magic value that doesn't equal itself. > I wanted to treat bindings as first class, and having them combine with row polymorphism into a construct subsuming tuples, argument lists, and environments into a kind of unified thing, with a similar result in mind. This might be helpful just as something to think about, but there is already an example of One Structure to Rule Them All: relations from the relational algebra. (You want to consider the mathematical definition; SQL tables break stuff because of legacy.) A relation can naturally represent any container, but also any function if you allow them to be infinite. So if you have a relation that states all values of y = cos(x), you can join it with an existing expression to apply the `cos` function. (Or `acos` if the system is clever enough.) And that, obviously would get translated into actual function calls. > So (n1: v1) might be a value v1 bound to n1. ... I had to read that a couple of times, but I think I get it. I think being able to combine structures makes a lot of sense, and it's one of those ideas that's not implemented in most languages (as the OP mentions) so we people tend to engineer around the lack of it, so it'd be interesting what idioms develop with it. > As for namespace I was thinking to borrow the plan9 approach Thanks, I'll have to look into that!
- CuriousSkeptic 7y agoYeah, must confess to being inspired by the relational model. Re: plan9, this is in the context of language I imagine as a kind of interactive environment (think small talk) and where partial evaluation would be the means to construct deployable artifacts. In this environment i expect to support metaprogramming and reflection, typing and unit-tests as something very dynamic and integrated, but purely design time thing. Again, not entierly unlike how you work with a relational dbms system and its schema.