ex_type
ex_type copied to clipboard
Maybe support inline type hint
We should already be able to do type hint with T.assert( expr :: type ). For example,
map = %{}
# type is empty map
T.assert(map :: %{optional(String.t) => integer})
# type is updated to %{optional(String.t) => integer} now.
if we support inline type hint like expr ~> type annotation. it may be easier (syntax sugar) to do type declaration, especially in pattern match.
we can do
{first ~> integer(), second ~> String.t} = something_untyped
instead of
{first, second} = something_untyped
T.assert first :: integer
T.assert second :: String.t
^^ benefit is to avoid write first and second twice.
Implementation concern
need to do some hacky thing to make it work. not sure if it worths the cost.