mudasobwa

mudasobwa

Creator of Cure

I know I put the cart before the horse, but AI providers started this race, not me.

Welcome Typle, the library that leverages a modern Elixir type system to discover types given the bunch of Elixir code.

The real application is my credo add-ons. In our team there are people who sometimes get lazy and use Access everywhere like: container[:key] no matter what container is. Also there are assistants who always use Access, because container.key is less fancy, or who knows why. I personally find this quite disturbing. Let alone Access is slower, it absolutely does not belong here.

So I started to implement a credo check for that, and I realized I should issue a warning if and only if the container is a map (and a key is an atom literal, but that’s a no-brainer.)

That’s how Typle was born. It’s just a baby-lib, but it might be already quite useful for those linting their code.

iex|🌢|1 ▶ {:ok, type} = Typle.Inference.infer_file("test/support/sample_module.ex")
{:ok,
 %{
   exprs: %{
     {6, 11} => "a",
     {6, 14} => "b",
     {7, 5} => "a",
     {7, 7} => ":erlang.+(a, b)",
     {7, 9} => "b",
     {10, 13} => "name",
     {11, 0} => "<<\"Hello, \", name::binary>>",
     {14, 19} => "input",
     {15, 5} => "case Integer.parse(input) do\n  {num, _rest} -> {:ok, num}\n  :error -> {:error, :invalid}\nend",
     {15, 17} => "Integer.parse(input)",
     {15, 24} => "input",
     {16, 8} => "num",
     {16, 13} => "_rest",
     {16, 29} => "num",
     {21, 22} => "x",
     {21, 30} => "x",
     {22, 16} => "x",
     {22, 24} => "x"
   },
   types: %{
     {6, 11} => #Typle.Type<dynamic()>,
     {6, 14} => #Typle.Type<dynamic()>,
     {7, 5} => #Typle.Type<integer()>,
     {7, 7} => #Typle.Type<dynamic(float() or integer())>,
     {7, 9} => #Typle.Type<integer()>,
     {10, 13} => #Typle.Type<dynamic()>,
     {11, 0} => #Typle.Type<binary()>,
     {14, 19} => #Typle.Type<dynamic()>,
     {15, 5} => #Typle.Type<{:error, :invalid} or {:ok, dynamic(integer())}>,
     {15, 17} => #Typle.Type<dynamic(:error or {integer(), binary()})>,
     {15, 24} => #Typle.Type<dynamic()>,
     {16, 8} => #Typle.Type<dynamic(integer())>,
     {16, 13} => #Typle.Type<dynamic(binary())>,
     {16, 29} => #Typle.Type<dynamic(integer())>,
     ...
   }
 }}

mix tasks included.

Enjoy!

https://github.com/Oeditus/typle

Showing Posts 1 to 2

ycastor

ycastor

Ooooo, this is nice! Everything you build is gold. This will be useful for a lean-of-elixir toy-project i’m playing with.

mudasobwa

mudasobwa OP

Creator of Cure

:person_bowing:

— All posts loaded —

Where Next? Top

Trending in Announcing Top

type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
kip
I’ll shortly be launching Text, a nascent text analysis library. Current functionality In this early version (not ready for prime time) ...
New

Other Trending Topics Top

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
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews