# How to define Macro for a new Type?

**URL:** <https://forum.devtalk.com/t/how-to-define-macro-for-a-new-type/47300>\
**Category:** Backend Questions/Help\
**Tags:** elixir, types\
**Created:** [28 March 2022 09:09 UTC](https://forum.devtalk.com/t/how-to-define-macro-for-a-new-type/47300 "2022-03-28T09:09:17Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Fl4m3Ph03n1x](https://forum.devtalk.com/user_avatar/forum.devtalk.com/fl4m3ph03n1x/32/3808_2.png) [@Fl4m3Ph03n1x](https://forum.devtalk.com/u/Fl4m3Ph03n1x)\
**Post date:** [29 March 2022 07:46 UTC](https://forum.devtalk.com/t/how-to-define-macro-for-a-new-type/47300/4 "2022-03-29T07:46:08Z")

</div>

This is what I would ideally like to go for, but using a macro. The macro would convert this “type” to a tuple, and then Dialyzer would be able to pick up miss matches.

I understand the pattern of NewType as is commonly defined is mostly applicable to static languages, but that does not mean we can not learn good lessons from it and adapt to Elixir, in a way that accomplishes the same 😃

---

_[View the full topic](https://forum.devtalk.com/t/how-to-define-macro-for-a-new-type/47300)._
