James_E
I feel like this function is perfectly ergonomic:
# default value in effect: count \\ :all
@spec delete(t(e), e) :: t(e) when e: term()
@spec delete(t(e), e, :strict) :: t(e) when e: term()
# default value in effect: count \\ :all
@spec delete(t_lax(e), e) :: t_lax(e) when e: term()
@spec delete(t_lax(e), e, :lax) :: t_lax(e) when e: term()
@spec delete(t(e), e, :all | non_neg_integer()) :: t(e) when e: term()
@spec delete(t(e), e, :all | non_neg_integer(), :strict) :: t(e) when e: term()
@spec delete(t_lax(e), e, :all | non_neg_integer()) :: t_lax(e) when e: term()
@spec delete(t_lax(e), e, :all | non_neg_integer(), :lax) :: t_lax(e) when e: term()
So, is there any way to make the rendered exdoc actually reflect that?
I feel like the documentation tooling has produced a hideous, unreadable mess; it looks like it’s somehow crosswise of the overloads and defaults, having completely segregated all the different @spec directives by arity, rather than by semantic group… but I have no clue what I could to do improve it.
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 7 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
James_E
Hmm. After much tinkering, I found out that the OP’s function signature could, in fact, be explained to ExDoc, almost unmodified, with the correct arrangement of function heads.
The key was to just go all-in on the Elixir-native “default arguments”, and then add a few careful
deffor the 3-arity path to match on which argument was actually filled:@spec declarations
hawkyre
I would assume from the context that not passing count deletes all elements, but that’s unintuitive for someone using the library because I wouldn’t expect decreasing without a count to mean deletion. Perhaps making the default argument 1 and allowing it to also be set to
:max(which would act as a delete) could be more intuitive? Decreasing the max amount of elements seems semantically intuitive to me (I also thought of:all, but decreasing all elements makes less sense).eksperimental
Which could be grouped as:
James_E
Yes, per the blurb at the top of the moduledoc, it’s three functions:
If I were to, say, rename the current
strictparameter tomode :: (:default | :strict | :lax), would that be at all possible to integrate with a default parameter forcount :: (:all | non_neg_integer)in a way that doesn’t scare ExDoc so badly?sodapopcan
Definitely, it should otherwise this be reported as a bug
To be technically correct (the best kind of correct) these are two separate functions:
delete/2anddelete/3. When we say that arity is part of the function name, this is very literal. Elixir makes it possible to not group them though this is this more of a quirk of its syntax (and as mentioned it emits a warning and most people compile with--warnings-as-errors). In Erlang this isn’t even possible:martosaur
I feel like this is multiple functions in a trench coat
Eiji
As far as I know no and I don’t think there would be ever support for that not only in the documentation, but also in
Elixiritself. The compiler should warn you that functions with the same name and arity should be grouped together.You can give different names to all related functions. for example by simply adding
_laxsuffix and then you can group specific functions. For more information take a look at:Grouping functions, types, and callbacks | mix docs task @ ex_doc documentation