Gleam, a statically typed language for the Erlang VM

Has a Language Server for IDEs been started yet, or is it too early in Gleam’s development?

1 Like

It has not been started but there is an issue tracking it. For me there are other features that are higher priority at present.

2 Likes

Very cool stuff! Is Agent akin to Elixir’s Agent (a state holding specialization of GenServer) or more to gen_server in general?

1 Like

The interface is close to Elixir’s Agent than to GenServer. It is similar to GenServer as that this abstraction can be a good building block for Gleam OTP applications (as GenServer doesn’t fit as well with Gleam).

Is it the statically-typed nature or some other aspect of Gleam that makes GenServers fit less well? What approaches would you take when building an OTP application with Gleam?

Yes, it’s the type system. It’s possible to make a type-safe wrapper around gen_server but I was unable to make one that was nice to use. The main problem was with the call message type- you’ll likely want to be able to send multiple different variants to the process and get a corrosponding type back, but I was unable to find a good way to have each message get back a specific type, the return message type wasn’t specific enough.

Right now I’m seeing it as being similar to with Erlang, except we’d be using agent instead of gen_server, and we might want a new implementation of supervisor that allows the programmer to pass the pids of older siblings to a new process as it being created.

Currently Gleam has no first class typed modules so hot code upgrades won’t work in a type safe manner and the libraries I’m making don’t have any way to update the state during upgrades. Currently I don’t think it’s possible to have hot code upgrades and type safety so I’m sacrificing hot upgrades in favour of more robust typing and a stronger core language. We may some up with a better story here later :slight_smile:

1 Like

Very interesting! I seems like an alternative to a GenServer, where each of the handle_call function clauses instead is its own function with its own return type would indeed be much better suited for a statically typed language. :thinking: Implementing something like that in a generic, re-usable way seems like a tough but interesting challenge. :blush:

1 Like

I saw that there are some editor plugins, which is great.

Is the code for TypedElxiir public somewhere? I’d love to have a read :slight_smile:

@lpil have you ever though of having a bidirectional typesystem? It does require some annotations (especially in places where you’d want them to be, like named function definitions), and it supports recursive functions effortlessly. Just lookup the type signature in the type environment from the function name.

It also has the advantage that it’s much easier to add “advanced” features, like (haskell) typeclasses and (rust) traits (which I believe to be similar to typeclasses). In HM you have to design your whole language around the lambda calculus HM supports, while in a bidirectional typesystem, you can more easily add new rules to support new syntax/semantics and the rules will usually be consistent with the ones you already have.

DISCLAIMER: I have nevr written a bidirectional typesystem in practice;; I’m writing one, but I don’t have anything complete to show

1 Like

Hi @tmbb! I’ve not been thinking specifically about bidirectional type systems but I have been thinking about making type annotations mandatory in places in order to enable better typing and error messages. Discussion here -> https://github.com/gleam-lang/gleam/issues/360

HM is the only system I know really and I’d be very interested in reading any material you have on other systems you think might be a good fit :slight_smile:

I would also be interested in reading more about the benefits and drawbacks of such a system.

1 Like

It’s on a bitbucket repo that’s private currently, it’s my ‘sandbox’ app that has about 80 disjoint testing things. ^.^;

It’s modeled a lot on the OCaml compiler, which is very readable. I highly recommend looking over it. :slight_smile:

I’ve never ran across that yet, do you have some good recommended links about it? :slight_smile:

This seems to be the main paper https://www.cl.cam.ac.uk/~nk480/bidir.pdf, I’ve not read it yet

1 Like

Windows version?

1 Like

Hi @mchean, the compiler unit tests run on windows and we do compile it for Windows too, but I’m not sure we have any Windows users. I’d love to hear how you find it and any problems you come across on Windows!

3 Likes

Thank you for your response @lpil. I hope to look at it this month. I’m very much a beginner so I doubt I can contribute much to the project.

Just giving it a go and sharing your feedback would be great help, whatever your experience is :slight_smile:

1 Like

Hi gang! I’ve just pushed a release candidate for v0.7.0, and assuming no problems are found the v0.7.0 release will follow shortly.

Please do give it a try and see if you can find any bugs :slight_smile:

The changelog can be found here: https://github.com/gleam-lang/gleam/blob/master/CHANGELOG.md#v070-rc1---2020-02-28

7 Likes

And now the v0.7 release is out! Check out the release post here -> https://lpil.uk/blog/gleam-v0.7-released/

13 Likes

Looking forward to trying this on Windows!

2 Likes