tcoopman

tcoopman

I discovered this link on bluesky, and it was a bit of an accidental thing, but I think it contains some nice information that’s worth checking out if you’re interested in the type checking future of Elixir.

Showing Posts 1 to 10

Eiji

Eiji

@tcoopman Keep in mind that changes even in nearest Elixir version would not affect whole community immediately. There would be months if not years of delay. That’s because many projects supports few Elixir versions back, so at best they may have both systems implemented (assuming the new one would not cause compilation errors in earlier versions) and in worst case they would replace new system after a longer time.

If said change would happen in ecto, phoenix, credo, excoveralls and many, many other most popular packages then the change to new type system would be rapid as there would be no sense to maintain both systems in long term especially if they are completely different while covering same things.

That’s said … new projects or those who focused on support latest Elixir versions would most likely switch to new system immediately as long as @type, @typep and @opaque would not be hard deprecated (if any). Unlike in packages shared on hex those projects would not cause problems with other projects and if they do (umbrella apps, internal dependencies) then most likely all related projects would have such changes soon as well.

However it would progress I would take a deep look from the very beginning as I wrote tons of typespecs and I’m willing to migrate asap (even if it would be 100% manual). I only wonder if Elixir core team plans to work in future on cover replacement. Similarly to dialyzer coverage does not works as good as it could (especially with macros) and modules with only types and struct definitions that have 0 relevant lines which is equal to 0% coverage!

jswny

jswny

One thing I don’t understand from Jose’s comment is this:

It calls modules/functions defined in the same project. We have no plans to introduce the [this] option. It is not complex to do, we are just not sure it will provide good UX, specifically when it comes to compilation times. And then we would rather focus on type annotations rather than inferring everything. Note none of the above apply to actual type checking, only the inference bits.

Does that mean there will be no type inference or checking within the same project?

cevado

cevado

it actually says in the part you quote

type check will be done whenever you do the annotations, inference only for external stuff.

cevado

cevado

i think the semantics for @type @typep and @opaque will never go away once its used for docs, even in erlang ecosystem… deprecation of those things seems to be a big departure of the tools of the ecosystem, i’d think it would happen on a possible elixir 2.0 at some point.

jswny

jswny

Right but that means you can’t do much type checking if there are no explicit type annotations in the project code right?

Maybe I’m misunderstanding, but it seems like the following would happen:

defmodule MyApp do
  def foo(x), do: IO.puts(x)

  def bar(), do: foo(123)

  def baz(), do: IO.puts(123)
end

In this example, the compiler would throw a compilation error on baz but not on bar because the type of foo is not being inferred therefore it doesn’t know that foo(123) is not valid

tcoopman

tcoopman OP

Type inference will work inside a module, not across modules. If I understand correctly, you can read more about it here: elixir/lib/elixir/pages/references/gradual-set-theoretic-types.md at main · elixir-lang/elixir · GitHub

tcoopman

tcoopman OP

I tried to search for an issue for this on github, but couldn’t find any immediately. Did you report this problem?

Eiji

Eiji

Except that I checked it on a project I currently work on, I wrote this from memory … I have read about it years ago and obviously don’t remember the source. :sweat_smile:

tcoopman

tcoopman OP

If you have a real issue, I’d say open a bug report. That’s the way issues get fixed :slight_smile:

josevalim

josevalim

Creator of Elixir

If you don’t have a type signature, we will infer one for you and use it when type checking remote calls. The inferred signature can understand everything about your code, except calls to other modules in the same project. So they are a good approximation and give valuable benefit for whoever wants to be lazy and not type anything. If you want proper type checking, then you have to write the signatures for your public functions.

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
_mfierro
Hello, I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New
marciol
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
durvia
Anyone running long-lived stateful processes on BEAM? We’re building an AI agent runtime and would love to compare notes. We’re a small ...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews