Blog Entries tagged "typespecs"

Add a Little Safety to your Elixir Structs with TypedStruct

<p>I’m working on an Elixir app at the moment and really enjoying it, but some of my recent dabbling in the type-safe worlds of <a href="https://elm-lang.org">Elm</a> and <a href="https://crystal-lang.org">Crystal</a> have left me desiring a bit more structure in my code. The app I’m building involves a multi-step data transformation and so I have a data structure to properly represent this process. But since Elixir is a dynamically typed language, you can’t, for example, have a non-nillable field in a struct. The Elixir/Erlang ecosystem does, however, have a type-checking syntax called <a href="https://hexdocs.pm/elixir/typespecs.html">Type Specs</a>, along with a tool, <a href="http://erlang.org/doc/man/dialyzer.html">Dialyzer</a>,...</p>

Read More...