NullOranje

NullOranje

While working on a work project, I found I needed a more Elixir-like queue versus the Erlang :queue module. So I decided to write one. I liked what I did, so I’m sharing it with others.

Yaq (Yet another queue) is a double-ended queue that supports both the Enumerable and Collectable protocols. I wanted something I could use with the pipe operator, since with my use case I found myself having to write a lot of functions to make :queue work correctly.

This is my first library I’m sharing with the community. I not only wanted a library I could use in my day job, but something I could take an opportunity to learn how to “do things right” so with regards to Elixir.

Source code is available on Github: GitHub - NullOranje/yaq: Yet another queue module for Elixir · GitHub
Hex package: yaq | Hex
Documentation: API Reference — yaq v1.2.0

Any and all feedback is welcome.

Showing Posts 1 to 10

NobbZ

NobbZ

I get a 404 for the GitHub repository.

Also from the examples in the documentation, I really do not like that its inspection shows the length of the queue but not the contents…

Oh, and I just realise, Yaq.value/0 is nil | term, term includes nil, so why is nil mentioned extra here?

Why is there no Yaq.t/1 which would allow us to specify the members types as well?

kip

kip

ex_cldr Core Team

Congratulations on your first library, its a big milestone and will be much appreciated I’m sure. I’ll check it out. @NobbZ is more direct and to the point than I am and his feedback is always very valuable, if sometimes a bit abrupt.

NobbZ

NobbZ

I really should try polishing this :smiley:

thojanssens1

thojanssens1

Thank you for sharing your work. By the way, are there other libraries like yaq? If so, what are the main differences?

What happened to the GitHub repo?

Isn’t it interesting to know whether the passed atom may be expected to be nil or not?

NobbZ

NobbZ

What if is I want to store nil? Is that not allowed?

thojanssens1

thojanssens1

Sorry, in this specific case it makes no sense to me too. I thought you meant as a general rule that nil | term is useless, as term includes nil; but I thought maybe sometimes it is useful to know that the library can expect nil.
Again, in this case I don’t see why this needs to be clarified indeed.

NobbZ

NobbZ

Yes, I’m pretty sure a @typedoc would help.

mat-hek

mat-hek

Membrane Core Team

Hmm, seems very similar to Qex. Have you tried that one?

NullOranje

NullOranje OP

That’s my fault. The repo is public now.

This was a deliberate choice. I can show the size of the

It probably shouldn’t be.

Mostly because I’m still figuring out how typespecs work.

This is probably an artifact of some thinking. The :queue module I drew inspiration from returned an :empty atom if you tried to dequeue an empty list. I guess I didn’t like the specific atom, so I think that’s why it became a nil. My own limited knowledge probably had me explicitly describe this case.

Thinking back, I’m wondering if an atom would be a better empty queue return value.

NullOranje

NullOranje OP

I did, but because it is mostly wrapper for :quque, it has some of the same issues. :quque (deliberately) does not track the size of the queue, so that is an O(N) operation, which was too slow for my use case.

Where Next? Top

Trending in Announcing Top

wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 11030 135
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New

Other Trending Topics Top

mudasobwa
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
lawik
I was thinking since Goatmire Elixir turned out pretty good I should maybe do another one. 30th of Sep - 2nd of Oct this year./ The firs...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews