How to declare type variables using elixir/dialyixir?

A prime simple example in OCaml’ize is:

type EscapedString = EscapedString string

let escape_string str = EscapedString (escape_whatever str)

let to_string (EscapedString str) = str

let render (EscapedString str) = do_render str

And so forth. Essentially it just enforces you to make sure that you run something through, say, a validator before it can be used, in the above case it is to make sure the string is escaped before it is rendered for example.

EDIT: Or for things like tagging integers to keep them distinct for memory arrays for a text-adventure engine emulator so you can’t accidentally use the wrong value in the wrong memory chunk. :slight_smile:

It’s basically Manually Made Refined Typing… ^.^;