News for hackers. Stuff that matters.
Re:Expresso: A simple expressions language with polymorphic ... by daanx on Saturday November 17, 2018 @04:06PM (#18477402)
Looks like a fun project, very nice :-)

For those interested in more of the beautiful theory on extensible row types, this project seems to be based on an earlier paper I wrote on scoped labels: https://www.microsoft.com/en-us/research/wp-content/uploads/...

Re:Expresso: A simple expressions language with polymorphic ... by jimmyhmiller on Saturday November 17, 2018 @05:48PM (#18477786)
Thanks for the reference. Espresso doesn't support recursive records. Does system in your paper allow for those? Is there anything particularly tricky about supporting them?
Re:Expresso: A simple expressions language with polymorphic ... by willtim on Saturday November 17, 2018 @05:58PM (#18477837)
Hi, author here, yes your paper was a huge inspiration and I really should add a references section in the readme. The row types in Expresso use very simple lacks constraints, similar to the old Hugs TREX system, and don't permit duplicate/scoped labels. I felt this was also a pretty good sweet spot.
Re:Expresso: A simple expressions language with polymorphic ... by daanx on Sunday November 18, 2018 @12:39AM (#18479022)
Thanks :-) TREX (by Mark Jones and Benedict Gaster) is great. The beauty is that a lacks constraints can get translated to fields offsets at runtime making it super efficient!

E.g. a type like:

foo :: r/x => { x :: int | r } -> int

foo r = r.x

Gets translated at runtime to a function where the lacks constraint r/x becomes an actual offset parameter.

Re:Expresso: A simple expressions language with polymorphic ... by CuriousSkeptic on Saturday November 17, 2018 @08:58PM (#18478481)
I’ve toyed with the idea of doing a language like this. With a small difference, records would be the only way to express values and bindings.

There would be no need to think of currying and partial application of functions as it would naturally follow from partially evaluating incomplete record inputs.

Another (nice?) property would be that a value always comes with a name binding. This no need to encode semantics of values purely as positions in lists and tuples.

So a question then to an implementer, is this something you considered? Is feasible?

Re:Expresso: A simple expressions language with polymorphic ... by mafm on Wednesday November 28, 2018 @10:56PM (#18557956)
Late reply, but telescopes seem to be based on a similar thought:

(http://www.nuprl.org/documents/Constable/Automath-35years.pd...)

RECENT RESULTS IN TYPE THEORY AND THEIR RELATIONSHIP TO AUTOMATH, ROBERT L. CONSTABLE

Re:Expresso: A simple expressions language with polymorphic ... by willtim on Sunday November 18, 2018 @04:25AM (#18479524)
I have considered using pattern bindings to easily create "field pun" bindings.

For example, one can already introduce all the fields of a record as local bindings, e.g.

let {..} = import "List.x"

or just a subset using, e.g.

let {reverse} = import "List.x"

Similarly for function argument bindings, e.g.

f {x, y} = x - y

The above is just syntactic sugar for:

f r = r.x - r.y

Such named arguments of course prevent arguments with the same type being passed in the wrong order, e.g.

f {x=2, y=1}

There is still some minor work to be done to better support inline type annotations on such patterns to make them more usable.

Your idea of unifying bindings with records is interesting and not something I have considered.

Re:Expresso: A simple expressions language with polymorphic ... by CuriousSkeptic on Sunday November 18, 2018 @01:35PM (#18481777)
Actually I even thought of unifying records and lambdas. Which could end up with a concatenative language, where application is commutative.

Couldn’t find a syntax that made sense though...

Re:Expresso: A simple expressions language with polymorphic ... by garmaine on Monday November 19, 2018 @05:15PM (#18490211)
Do you have any notes on this? It is something I’m actively researching.
Re:Expresso: A simple expressions language with polymorphic ... by CuriousSkeptic on Wednesday November 21, 2018 @02:33PM (#18505341)
Not much. But basically a bit inspired by Cat (a stack based, typed, concatenative language), and a thought that stacks could be replaced by first class environments and rewriting, so you could have a concatenative language with partial evaluation. Instead of the usual ordered parameter lists, and/or curried functions with partial application, functions take environments and produce environments. A program like "{a=1}{b=2}{c=a+b}" would evaluate to "{c=3}". While "{b=2}{c=a+b}" evaluates to "{c=a+2}"
Re:Expresso: A simple expressions language with polymorphic ... by garmaine on Wednesday November 21, 2018 @04:38PM (#18506309)
So the values in the environment are single use? I’m going to think on this...
Re:Expresso: A simple expressions language with polymorphic ... by acjohnson55 on Saturday November 17, 2018 @11:22PM (#18478868)
I've felt for a while that something like this would be superior to the positional way of working, in most cases. But I don't know whether this would result in an elegant system in reality, or not. What if positional were just sugar for records indexed by natural numbers?
Re:Expresso: A simple expressions language with polymorphic ... by CuriousSkeptic on Sunday November 18, 2018 @03:51AM (#18479447)
There are some precedence in SQL. Which seems to work out ok for the most part. But then in SQL functions are not relations, and do use positional parameters, so not entirely pure either.

Som help from type/name inference might help in wiring things togetger.

Re:Expresso: A simple expressions language with polymorphic ... by garmaine on Monday November 19, 2018 @05:18PM (#18490230)
It would also make the entire runtime environment (code and data) a homoiconic relational database.
Re:Expresso: A simple expressions language with polymorphic ... by chombier on Saturday November 17, 2018 @08:09PM (#18478312)
Nice! I like how unit/void arise naturally from empty record/sum types.
Re:Expresso: A simple expressions language with polymorphic ... by acjohnson55 on Saturday November 17, 2018 @11:42PM (#18478911)
It seems like there's just a global namespace of labels. This reminds me of the situation in Javascript before symbols were introduced. I'm curious why this choice was made?
Re:Expresso: A simple expressions language with polymorphic ... by willtim on Sunday November 18, 2018 @04:12AM (#18479496)
Labels in Expresso are just type-level symbols. Label names can be re-used over and over again in different records and variants. This works fine because a name is not tired to any particular nominal type (like a constructor in Haskell or Java).
Re:Expresso: A simple expressions language with polymorphic ... by acjohnson55 on Tuesday November 20, 2018 @09:36PM (#18499784)
But it seems like it would be an error to concatenate two records with a name clash, though, right?
Re:Expresso: A simple expressions language with polymorphic ... by willtim on Friday November 30, 2018 @02:40AM (#18567436)
Yes because duplicate labels are not allowed within the scope of a single record (you can specify which one overrides the other, but perhaps we also need a convenient rename syntax). This point was that different records can happily contain the same field names. The situation is the same as SQL.
Re:Expresso: A simple expressions language with polymorphic ... by titanix2 on Saturday November 17, 2018 @09:18PM (#18478542)
Any chance that such kind of records will land in a mainstream language such as C# or F# in less than a decade?
Re:Expresso: A simple expressions language with polymorphic ... by CuriousSkeptic on Sunday November 18, 2018 @03:53AM (#18479453)
C#8 will have a kind of records. Not fully this kind of records, but perhaps close enough to put pressure in that direction.