Last active
July 18, 2022 23:31
-
-
Save kipcole9/6771533e88d199bc15bcd521021b4274 to your computer and use it in GitHub Desktop.
Create a union type from a list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Converts a list of atoms into a typespec | |
type = &Enum.reduce(&1, fn x, acc -> {:|, [], [x, acc]} end) | |
@grammatical_gender [ | |
:animate, | |
:inanimate, | |
:personal, | |
:common, | |
:feminine, | |
:masculine, | |
:neuter | |
] | |
@type grammatical_gender :: unquote(type.(@grammatical_gender)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment