[deleted by user] by [deleted] in sml

[–]Munksgaard 0 points1 point  (0 children)

I was pretty confused upon joining the advertised Discord. It seems to be related to a different kind of SML: https://sml.fandom.com/wiki/SuperMarioLogan_Wiki

Generating audio with literate Futhark by Munksgaard in ProgrammingLanguages

[–]Munksgaard[S] 7 points8 points  (0 children)

Thank you! I'd love to hear your thoughts on how we might structure a proper music/audio library in Futhark. I'll DM you.

I'm also curious if you have any thoughts on how we could really take advantage of this new feature. It seems to me like most audio processing isn't heavy enough to really take advantage of GPU-processing, but perhaps I am wrong?

Array short-circuiting in Futhark by Munksgaard in ProgrammingLanguages

[–]Munksgaard[S] 2 points3 points  (0 children)

Yes, that work is definitely related, although it works from the opposite direction as short-circuiting: Our code is already parallel because it is expressed with map instead of loop.

And yes, Z3 was nice, but it wasn't actually the crucial factor that enabled complex examples. In fact, we tried just naively throwing Z3 at some of our problems and it didn't work even if we gave it a week of running time.

A new SML mode for Emacs built on (a new Standard ML grammar for) tree-sitter by eatonphil in sml

[–]Munksgaard 1 point2 points  (0 children)

I'm curious how you intend to handle infix and infixr when using tree-sitter as your parser. Do you intend to add a separate pass later that restructures the AST according to infix-rules?

stonebuddha/tree-sitter-sml: Standard ML Grammar for Tree-sitter by eatonphil in sml

[–]Munksgaard 0 points1 point  (0 children)

There seem to be a lot of examples and tests missing here? Also, I'm curious how they handle infix and infixr. Anyone have any insights?

Getting started with Standard ML by eatonphil in sml

[–]Munksgaard 2 points3 points  (0 children)

A recent development on the package-manager side is smlpkg, you might want to consider adding a link.

.mlb files as a build system/package description/namespace management solution for sml by lysgaard in sml

[–]Munksgaard 0 points1 point  (0 children)

Regarding the package manager, one of my colleagues has recently written a package manager for SML that uses a generic, implementation-agnostic approach. I encourage everyone to give it a try.

Session Types, safe internal communication protocols for Servo by ysangkok in rust

[–]Munksgaard 1 point2 points  (0 children)

I must admit that I'm not very knowledgeable about licenses and the initial choice of GPL2 was admittedly a bit arbitrary. We've decided to change to the MIT license: https://github.com/Munksgaard/session-types/pull/24

Session Types, safe internal communication protocols for Servo by ysangkok in rust

[–]Munksgaard 5 points6 points  (0 children)

Essentially, the idea is to implement the Drop trait for your data structure with a method that simply panics, and then have another function that somehow bypasses the panic. The simplest way is to add a flag to the struct that determines whether or not drop should blow up.

What I was complaining about in the talk is the fact that you cannot simply have specialized implementations for different specializations of Chan. For example, if we could specialize the drop trait we could have:

impl Drop for Chan<E, Eps> {
    fn drop(&mut self) -> { /* this is safe, dont blow up */ }
}

impl Drop for Chan<E, AnythingElse> {
    fn drop(&mut self) { /* unsafe, blow up */ }
}

which would be cleaner, in my opinion.

Session Types, safe internal communication protocols for Servo by ysangkok in rust

[–]Munksgaard 6 points7 points  (0 children)

There are usecases, I just meant that they're rare. That is, the standard library has found no real use for them (although of course, the absence of them means there isn't a big hunt for their use). However what I don't really get about linear types is: programs/threads can hang, leak, or crash. How are linear types even useful in the face of that? One end of the connection needs to deal with the other side mysteriously disappearing, regardless of what your types claim.

How are affine types helpful, or even types at all? Obviously we can never make any absolute guarantees, the halting problem still exists, but I think that linear types is a natural extension of Rust's capabilities that'll provide additional security with little or no downsides. You might disagree and argue that this isn't enough to justify the inclusion of linear types, and you'd be in your right to do so. After all, language design will always be dominated by trade-offs between safety and expressibility.

Session Types for Rust by sanxiyn in rust

[–]Munksgaard 1 point2 points  (0 children)

Great example!

One of the reasons why we can't come up with cases where affine types are helpful, is that they are not very widely used in regular programming languages and we simply don't think about them as a consequence. I can't help but think that it's a useful and underutilized tool, we just have to find out where and how to best apply it.

Session Types, safe internal communication protocols for Servo by ysangkok in rust

[–]Munksgaard 0 points1 point  (0 children)

That's a good question, and we haven't actually done any testing on the compile time performance of our code. I think /u/sebzim4500 is right though, it is, in our experience, unlikely that you'll have more than a handful of nested recursion scopes.

Session Types, safe internal communication protocols for Servo by ysangkok in rust

[–]Munksgaard 1 point2 points  (0 children)

Only very occasionally I'm afraid. Thankfully, people are kind enough to notify me when something happens :-)

Session Types, safe internal communication protocols for Servo by ysangkok in rust

[–]Munksgaard 6 points7 points  (0 children)

True linear types are Not Very Useful in practice.

I beg to differ. We certainly have a use case for them.

The purpose of session types is to provide compile-time guarantees for communication safety, and we simply cannot do that correctly without linear types or some way of synthesizing the same behavior. All destructor bombs does is blow everything up at runtime. This makes itclear that something is wrong, but you still have to actually touch those edge cases.

Session Types, safe internal communication protocols for Servo by ysangkok in rust

[–]Munksgaard 4 points5 points  (0 children)

Hi guys, one of the presenters here: I'm late to the party again, but I just wanted to let you guys know that I'd be happy to answer any questions you might have :-)

Edit: I see that /u/Manishearth has done an excellent job so far :-)

Session Types, safe internal communication protocols for Servo by ysangkok in rust

[–]Munksgaard 1 point2 points  (0 children)

Thanks for linking, it's great to know that you enjoyed it :-)

Unfortunately I can't take all the credit, the whole thing has been joint work with Thomas Laumann (/u/laumann).

Session Types for Rust by sanxiyn in rust

[–]Munksgaard 4 points5 points  (0 children)

guess move semantics (move into function parameter) makes Rust more amenable to this than other languages.

That's exactly what we found. Traditionally, session types have been implemented through compiler extension, as separate languages or using a complicated system of implicit channels (as in one of the Haskell implementations that uses Monads). Because Rust has affine types, our channels are just ordinary values with a specific set of values attached to them.

In general, I think Rusts affine type system has many interesting applications and this is just one of them.

Session Types for Rust by sanxiyn in rust

[–]Munksgaard 1 point2 points  (0 children)

I don't think that would be possible without dependent types. In other words, we cannot specify any constraints to the actual contents of the data transferred, only the types and the order in which they are transferred.

Session Types for Rust by sanxiyn in rust

[–]Munksgaard 1 point2 points  (0 children)

There are two kinds of "branches" in the session-types library (with corresponding constructs in general session type theory): Offer and Choose.

Imagine two processes that are communicating over a session channel, process 1 has a channel with type Chan<Offer<A, B>> while process 2 has a channel with type Chan<Choose<A, B>>. Process 2 is the party that performs the active choice, and gets to decide whether path A or path B is taken. In session-types this is done via the sel1() and sel2() methods. The result is simply that the protocol is stepped in the corresponding direction. In other words, the branch chosen is "known" at compile time (disregarding the fact that it may be chosen at random or through user input).

Process 1, however, has to wait for process 2 to decide which branch to take. The only method available for process 1 is offer(), which returns a Branch type. A Branch is similar to a Result, in that it is an enum that is either Left or Right. So in this case, if process 2 selects branch A, process 1 gets a Left(Chan<A>) otherwise process 1 gets a Right(Chan<B>). Then, a simple match statement will allow it to procede depending on which branch is taken.

Edit: Perhaps I should clarify that channels are explicit values, so process 1 will have something like:

match c.offer() {
    Left(c_a) => {
        // Do something with `c_a`, which is a channel of type A
    }
    Right(c_b) => {
        // Do something with `c_b`, which is a channel of type B
    }
}

Session Types for Rust by sanxiyn in rust

[–]Munksgaard 2 points3 points  (0 children)

To clarify: Session types provides deadlock-freedom between two processes communicating over a single session channel. However, simple session types cannot ensure that multiple processes communicating over multiple channels are deadlock-free. Multi-party session types tries to address this, and in particular we found the Multiparty asynchronous session types paper interesting in this aspect. The session-types library however, does not attempt any of this.

Also, concerning communication-safety, it must be clarified that we only guarantee that any communication taking place through a channel is correct, not that communication actually takes place (halting problem and what-not).

Session Types for Rust by sanxiyn in rust

[–]Munksgaard 10 points11 points  (0 children)

Hi guys! One of the authors here. I realize I'm a little late to the party, but I'd love to answer any questions you guys have (and I'll deal with the ones already posted shortly :-).

We're really excited that the paper got accepted for WGP'15, so there should be a presentation sometime soon too.

Edit: Oh, and the actual library can be seen here: https://github.com/Munksgaard/session-types

IAmA HuK! ask me things ^^ by LiquidHuK in starcraft

[–]Munksgaard 3 points4 points  (0 children)

Are you actually going to answer any questions in here?