ityonemo

ityonemo

Introducing Mavis, a comprehensive Typing Library for Elixir:

Mavis fully utilizes Elixir’s Protocol system to create a fluent and composable type analysis library for erlang and Elixir’s types. The type analysis logic is hand-crafted to fit the pragmatic choices that were made when the BEAM was designed (and extended, e.g. with the map type), and does not attempt to square the BEAM’s types to a preexisting type-theoretical framework. Because of the operations that it supports, I expect it to be able to be more powerful than Dialyzer or Gradualyzer.

Hex:

Github:
https://github.com/ityonemo/mavis/

This is the first stage in my “Selectrix” project which is a shot at bringing compile-time type analysis to Elixir as an optional add-in library.

I’d love it if the community could play around with the library to get a sense of what it can do (and hopefully also find bugs!)

Showing Posts 1 to 10

ityonemo

ityonemo OP

@Qqwy Since you are doing some typing stuff extensively I’d love your input on the API interface, or some of the more interesting choices that I’ve made (e.g. with Maps Type.Map — mavis v0.0.6)

baldwindavid

baldwindavid

Woo…you’ve been putting in some work!
Random question: Is there a reason why isa? is not is_a?? It seems like you’ve used snake case mostly throughout so that one popped out at me. Perhaps there is precedent for that in other languages and I am just not used to seeing it or it is reserved in some way.

ityonemo

ityonemo OP

because is_ typically indicates “guard” and I don’t like confusing people. Looks like it had the opposite effect. I struggled a lot with that one, maybe I should just steal the javascript keyword.

baldwindavid

baldwindavid

Maybe kind_of??

axelson

axelson

Scenic Core Team

Excited to try this out! Do you have a sample project that is using Mavis that we could take a look at?

ityonemo

ityonemo OP

it only does the type analysis, so not really =D. I gotta build that library. i don’t think there are too many use cases for this except for compile-time tools, since the type system is not typically used at runtime.

axelson

axelson

Scenic Core Team

That makes sense :+1:

Qqwy

Qqwy

TypeCheck Core Team

Thank you for directing me to your project! It looks very interesting. I am very happy that different points in the design space of typing are being explored by these various Elixir projects now :smiley:.

With your project I can already see that you are pushing somewhat against the same boundaries as my run-time type checker project is, in that Erlang’s built-in typespecs have certain odd limitations (compare for instance [integer] (“list of 0 or more ints”), [integer, float] (does not compile), [foo: integer] (“a keyword list containing keyword :foo with an integer”), [foo: integer, bar: float] (“a keyword list with :foo containing an integer and :bar containing a float in any order but both need to be in there somewhere”).

I really like what you are doing with checks for unioning, intersecting and checking for subtypes of types. I think these operations can be very useful for practical purposes :+1:.

About Type.Map specifically:

  • What is the reason for the deviation: ?
  • Built-in Elixir maps used in typespecs do not do the same: map() assumes ‘any map’, but %{} assumes the empty map. I do agree that %{} meaning “empty” in types and values, but ‘any map’ in patterns might be confusing, but I do not fully understand how you are deviating here.

Other than that, I think you mostly nailed the interface for Type.Map. :slight_smile:

ityonemo

ityonemo OP

I think the list wierdness is elixir’s syntatic sugar over the typespecs. It does make sense that [integer, float] does not compile; but [integer, …] has to be a special case, and [foo: integer, bar: integer] is just sugar for [{:foo, integer} | {:bar, integer}] because who’s got time in life to write all those symbols? They’re so far away from the home row! (j/k the elixir type syntax does cut down on line noise and i like it, if it does poke a bit at the OCD in me).

Point #1 - I do get that we want there to be a ‘required’ type of map element, for structs and the like, but I don’t know what this means: %{required(integer) => integer}. Another slight complication is that we can’t have nice things like %{required("my_field") => String.t} for json specs =(, the best we can do is %{required(String.t) => String.t}, but like the integer case, I don’t know what that means. I think something that maybe should be possible with mavis is to make that sort of thing possible via plugin, but I don’t want to push beyond the boundaries of the type system until at least Selectrix exists.

Maybe someone can explain to me what it means to have a required type that is an aggregate, non-singleton type, and, in particular, how I can do typechecking with those types?

Point taken on #2. Perhaps it shouldn’t be called a “deviation” in the docs. so much as a clarification.

baldwindavid

baldwindavid

@Qqwy - Not that you’re looking for another dependency, but would there be any cause for consideration to use Mavis for specific low-level checking in your TypeCheck library?

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
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
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
woylie
Phoenix components for pagination, sortable tables and filter forms with Flop and (optionally) Ecto. pagination cursor pagination sorta...
New

Other Trending Topics Top

mudasobwa
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
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
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
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
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
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews