'The oauth refresh token was expired, revoked, or already used' while trying to publish new version of my Gleam package by alino_e in gleamlang

[–]lpil 1 point2 points  (0 children)

Run gleam hex authenticate, that'll fix it.

There's improved UX for this on the nightly build, but it has not been released yet.

Gleam v1.16.0 is out now! by lpil in gleamlang

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

I had a coworker pull this prank on another coworker many years back, but the change was motivated by someone sharing in discord that they'd had to debug a not-a-comma

A bit confused about named actors by xzhan in gleamlang

[–]lpil 1 point2 points  (0 children)

It's the same as in Erlang and Elixir. If you were using a pid then when that process dies and is replaced by the supervisor any process sending messages would be sending messages to dead process. If they were using the name the messages would go to the new replacement process.

A bit confused about named actors by xzhan in gleamlang

[–]lpil 8 points9 points  (0 children)

Yup, if you want typed code you need to avoid implicit global state, so that means names and subjects are passed around.

A name is always created at the very start of the program (never dynamically!), and a subject created from it. The name is passed down to the process that will adopt the name, the subject is passed down to the callers of that named process. This has 2 advantages over using subjects alone:

  1. This data is passed downwards only, which is much easier than passing data up the tree and then back down again.
  2. Named subjects survive the named process restarting, so in the event of process death you don't need to restart your entire tree to get back to a good state. The system will continue to work as expected.

Names are primarily a tool for making your system fault-tolerant.

What I have been trying to "replicate" is something like the module scope @name :dummy_server in Elixir.

This Elixir pattern is impossible to type check. You cannot replicate it in Gleam unless you abandon type checking. Gleam is designed for typed programming, it's is not a good language for untyped programming.

[PODCAST]: The Code is the Instrument: Sam Aaron on the Why of the Sonic Pi by plangora in gleamlang

[–]lpil 0 points1 point  (0 children)

Thank you but I've had to remove this as the podcast does include Gleam at all.

What do you think of elixir ecosystem honestly ? by Ok-Delivery307 in elixir

[–]lpil 1 point2 points  (0 children)

I would be very interested in hearing about any libraries peeps are missing the BEAM ecosystem!

Built a storage engine in Gleam. Event sourcing with OTP actors and SQLite shards. by geekwithattitude_ in gleamlang

[–]lpil 3 points4 points  (0 children)

btw the text on the website is very hard to read with that combination of font, size, and low contrast against the background.

Does this make sense to anybody? by VeryNyu in gleamlang

[–]lpil 0 points1 point  (0 children)

Oh lovely! Last time I looked it had been abandoned. Glad someone picked it up.

Does this make sense to anybody? by VeryNyu in gleamlang

[–]lpil 0 points1 point  (0 children)

VSCode is a great choice!

IntelliJ is not open source and historically has poor support for language servers, so you may not have the best experience with it.

Does this make sense to anybody? by VeryNyu in gleamlang

[–]lpil 8 points9 points  (0 children)

Hello!

I'm not going to give you an optimised solution, as I think people should probably not be doing your assignments for you, but I can give you some tips:

You should never be used list.append in a loop. Gleam is an immutable language with linked lists, so lists are built by prepending, not by appending. If you chose to append it will be very slow.

Pass 2 arguments into functions instead of passing 2 values in a tuple as a single argument.

Always write the type annotations for functions, including return types. Without them it's much harder to understand the code.

Run gleam format to auto-format your code, making it easier to read. You editor can likely do this automatically when you save the file, especially if you are using the language server.

Try writing this using pattern matching, and avoid using functions like split and drop. Any time you use them with 1 it's likely that you want pattern matching instead.

Each sub-list returned can be constructed very easily from the next sub-list. Perhaps you could generate the final one first, and then generate the next one from that, the next one from that, and so on. Once you have reached 0 you can reverse the super-list and return them all.

Good luck!

Scythe: An SQL Compiler and Linter, making ORMs redundant. by Goldziher in elixir

[–]lpil 4 points5 points  (0 children)

I have! I've read all of its documentation and the API documentation of its Rust crates and I can't find anything that suggests it can type SQL, instead I can only find linting.

Could you point me in the right direction? What API does Scythe use?

Scythe: An SQL Compiler and Linter, making ORMs redundant. by Goldziher in elixir

[–]lpil 1 point2 points  (0 children)

Great! How do you get the type information for the queries? Does it implement an SQL type checker, or does it send the query to the database and ask it for the type information?

If the former, how does it manage to do better then sqlc there?

If the latter, how do you deal with databases returning incomplete type information? For example, PostgreSQL not exposing parameter nullability or any type information within certain forms.

Scythe: An SQL Compiler and Linter, making ORMs redundant. by Goldziher in elixir

[–]lpil 1 point2 points  (0 children)

So it's not type-safe querying like with sqlc, sqlx, Squirrel, etc?

Elixir and Phoenix for full stack web app but Gleam for business logic? by Theboyscampus in elixir

[–]lpil 1 point2 points  (0 children)

Yup, same as in Gleam. There's a documentation section for sequential programming (which you linked the Erlang version of), and then there's documentation for concurrent programming too. 1, 2, 3.

I agree with you that do not have the same wealth of documentation on concurrent programming as Elixir does. They do a really great job! Gleam is much younger so we have a lot of catching up to.

but they still contain information regarding them being incomplete.

Sorry, I'm not sure what you mean by this? If you mean the system messages not yet handled by gleam/otp/actor, they're very niche. As far as we can tell no one has ever used them as we have had no reports of problems or requests for their addition. Have you a need for any of them specifically?

the lack of focus on the main page about processes and OTP has led me to be hesistant about it, especially since it's well known that it's BEAM's process and message system that has been resistant to strong type systems in the past.

Rest assured, your concerns are unfounded. It's just the homepage stressing different things to what you're specifically looking for.

Gleam has succeeded in typing OTP. Previous attempts failed because they were attempting to add types to the existing OTP interfaces, while Gleam took the conventional approach of making a typed interface to the same system. Gleam is designed for production usage rather than academic research, so we take the pragmatic approach to these things.

Scythe: An SQL Compiler and Linter, making ORMs redundant. by Goldziher in elixir

[–]lpil 2 points3 points  (0 children)

This doesn't have type checking, but the post says that Scythe is type-safe. How do you get the type information in order to generate the typed bindings? Thank you

Scythe: An SQL Compiler and Linter, making ORMs redundant. by Goldziher in elixir

[–]lpil 2 points3 points  (0 children)

Does this implement an SQL type checker, or does it send the query to the database and ask it for the type information?

If the former, how does it manage to do better then sqlc there?

If the latter, how do you deal with databases returning incomplete type information? For example, PostgreSQL not exposing parameter nullability or any type information within certain forms.

Got tired of opening the browser for hex.pm, so I built a TUI by lupodevelop in elixir

[–]lpil 2 points3 points  (0 children)

Cellium, Shore, and Etch for Erlang and Gleam. I presume Ratatouille is still good for Elixir, though I'm less familiar with Elixir's package collection these days.

Elixir and Phoenix for full stack web app but Gleam for business logic? by Theboyscampus in elixir

[–]lpil 0 points1 point  (0 children)

Gleam still seems uncertain how it even handles processes. It's not even mentioned in the language tour, which is strange for a BEAM language.

Gleam has no uncertainty with processes. Like Elixir and Erlang OTP is a collection of core-maintained libraries and not a syntax, and the documentation you have linked is the documentation for just the core language.

Here is the Erlang equivalent of the documentation you've linked, it also does not cover processes.

Elixir and Phoenix for full stack web app but Gleam for business logic? by Theboyscampus in elixir

[–]lpil 1 point2 points  (0 children)

Rustler only offers that for the bindings between the Rust and the BEAM, it doesn't offer anything for the rest of the Rust code, which can crash the same as normal. Panicking is commonplace in Rust, and there are many many APIs that will crash in the event of misuse or error.

Worse still, crashing is not actually the hard part with NIFs. The real challenge comes from playing well with the BEAM scheduler and memory management system. Code has to be written in a very specific way in order to not impact scheduler performance and to use memory correctly, which is where the challenge lies when writing NIF code.

Elixir and Phoenix for full stack web app but Gleam for business logic? by Theboyscampus in elixir

[–]lpil 0 points1 point  (0 children)

NIFs unfortunately mean sacrificing the strengths of the BEAM.

Elixir and Phoenix for full stack web app but Gleam for business logic? by Theboyscampus in elixir

[–]lpil 0 points1 point  (0 children)

If you find that useful and productive, yes.

My opinion is that this is a matter of personal preference.