eksperimental

eksperimental

Types that you wish were in Elixir

Do you ever wish Elixir had more types?
Share some of the ones that you frequently use.

If the outcome is good I will compile them into a library.

Here are some:

@typedoc """
A non-positive integer.

That is, any integer `<= 0`.
"""
@type non_pos_integer :: 0 | neg_integer()


@typedoc """
A keyword list with `key` specified.

For example: `keyword(version :: atom(), map())`
"""
@type keyword(key, value) :: list({key, value})


@typedoc """
A non-empty keyword list.
"""
@type nonempty_keyword(value) :: nonempty_list({atom(), value})


@typedoc """
A non-empty keyword list with `key` specified.

For example: `nonempty_keyword(version :: atom(), map())`
"""
@type nonempty_keyword(key, value) :: nonempty_list({key, value})

Most Liked

ityonemo

ityonemo

This is my wishlist:

String literals:

@type my_string::"foo"

List literals:

@type my_list::[:foo, :bar]

Min-length tuples

@type my_tuple_at_least_two :: {any, any, ...}

dorgan

dorgan

Liveview handle_event callback is the first to come to mind

eksperimental

eksperimental

Hi @dimitrarvp, thanks for chiming in. Note that the intention of the post is not to make a proposal to the language. Just dream and list types that you find useful in your day-to-day development.

Where Next?

Popular in Discussions Top

blackode
Elixir Upgrading is so Simple in Ubuntu and It worked for me Ubuntu 16.04 git clone https://github.com/elixir-lang/elixir.git cd elixir...
New
mikl
I wanted to capitalize a string, and tried using String.capitalize(). That generally works well, until you try to capitalize a word like...
New
sashaafm
I’m trying to evaluate the best combo/stack for a BEAM Web app. Right now I’m exploring Yaws a bit, after having dealt with Phoenix for a...
New
Fl4m3Ph03n1x
Background A few days ago I was listening to The future of Elixir from Elixir Talks, with Dave Thomas (@pragdave ) and Brian Mitchell. I...
New
mmmrrr
Just saw that dhh announced https://hotwire.dev/ Is it just me or is this essentially live view? :smiley: Although I like the “iFrame-e...
New
AlexMcConnell
The reason that Rails is as popular as it is is because it’s very easy for relatively inexperienced developers to get a lot of work done....
588 19568 166
New
fireproofsocks
I’ve been working on an Elixir project that has required a lot of scripting. I usually reach for Elixir because I like it more (and in th...
New
AstonJ
Can you believe the first professionally published Elixir book was published just 8 years ago? Since then I think we’ve seen more books f...
New
griffinbyatt
Sobelow Sobelow is a security-focused static analysis tool for the Phoenix framework. For security researchers, it is a useful tool for g...
New
opsb
We’re considering our architecture from a viewpoint of scaling our traffic heavily over the next 6 months. Our current deployment is runn...
New

Other popular topics Top

New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement