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

wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
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
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
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
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New
pferriby
Introductory paragraph I’ll be looking for a keen junior or someone that has a couple of years experience in the real world (so you’ve be...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews