#Protocol implementation for an existing record.
15 messages · Page 1 of 1 (latest)
have you looked at https://hexdocs.pm/elixir/1.14.5/Record.html
I sure have looked at it, but I haven't seen a way to achieve what I hope for.
i thought extract with :from_lib might be what you want
You can implement protocols for Tuples, but you can only do it for all tuples or none of them, right?
You can't pattern match against a specific group of tuples and only implement a protocol for them, right?
yeah, I am using that! But it doesn't help much, at implementing a protocol for the extracted record.
put all the record types into a module attribute, and use that in your protocol to see if you want to mess with it? sounds like it could produce unintended consequences though
You cannot implement protocols for records
If you want to do so, then you need to create wrapper struct
can you for Tuple? or is it restricted to the ones in elixir already
You can implement it for tuples, but all tuples, without distinction.
yeah so could you not load all the record types at compile time and then if it matches {User, _, _, _} {Project, _, _, _, _, _} for example. do some manipulation, otherwise just pass it through as is
feels like it should work but i dont have the time/effort in me to try it out
did that work or what?
I packed the record in a struct