Compile-time validation of newtypes or at least static analysis

Hello, so I was wondering if something like newtypes is possible in Elixir and found something that does it but I THINK (correct me if I’m wrong) it only works at runtime. Just for my own learning purposes I was trying to work out how to use macros to do something like it at compile time. I basically just wanted warnings to show up on instances such as NonEmptyString.new("") . Something that worked with just the compiler was not too difficult to get running, but to work with the LSPs it was something I just couldn’t come up with a satisfactory solution for…

So I thought what if I work with dialyzer instead? It’s a popular enough tool so it could potentially work for a lot of people (not assuming there’s that much interest in it, but still). Is this something that can/has been done before?

1 Like