IvanR

IvanR

Folks, I’ve made a Domo library adding new/1 constructor function to a struct that automatically checks conformance to the struct’s type.

The library includes the custom compiler that works right after Elixir in the chain to prepare pattern matchings.

Library usage looks like the following:

defmodule Foo do
  use Domo
  defstruct [:title]
  @type t :: %__MODULE__{title: String.t()}
end

Foo.new(title: :hello)
** (ArgumentError) the following values should have types defined for fields of the Foo struct:
 * Invalid value :hello for field :title of %Foo{}. Expected the value matching the <<_::_*8>> type.

I’m looking for the codebases with lots of structs to check the compilation times without/with use Domo in structures via the following command.
mix deps.compile && mix clean && time mix compile

Can you, please, share if you know one or two open-source projects that has as many structs with defined @type t() as possible?

P.S. Is it an absurd idea to ask you to test on a proprietary codebase? Please, DM if you can do such a measurement; I can send concrete steps in reply :grinning_face_with_smiling_eyes:

Showing Posts 1 to 2

mudasobwa

mudasobwa

Creator of Cure

I would go with a single file defining thousands of structs. Somewhat alongside the following lines.

defmodule Structs do
  for i <- 1..1000, name = Module.concat(["S#{i}"]) do
    defmodule name do
      defstruct foo: 42
    end
  end
end

That way nothing else would affect the benchmark, all the code is at fingers etc.

IvanR

IvanR OP

Thanks, it seems like a property-based test and works for a synthetic check :smile:

Same time, I’m curious about production targeted codebases because it gives the most interesting combinations of structs and types.

— All posts loaded —

Where Next? Top

Trending in Questions Top

itzmidinesh
Hi all, I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
yarrichar
I’m very new to Elixir, so sorry if this is a silly question: I am wondering what happens to the mailbox of a process when the machine i...
New
Hellowman
Hello everyone! I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++. Does anyone ...
New
pragdave
How do I tell Hologram not to escape HTML when substituting into templates? {Textile.render(@product.long_description)} escapes the HTM...
New
Fl4m3Ph03n1x
Background When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error: * assembling mark...
New
rlipscombe
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
saleyn
Is there a way to import record definitions in the iex shell for pretty printing (similar to the rr command in the erl shell)? This woul...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews