Hi,
(I also asked on Stackoverflow, I hope cross-posting is ok.)
I expected it to be documented in Module
, probably with references to struct
s, but no joy. Seen it used with a single or a list of arguments. All the variations I could find so far:
-
list of module names such as
@derive [MyProtocol, Another]
(e.g.,
Kernel.defstruct/1
macro doc,
line 65 inProtocolTest
(v1.7.4)) -
module name such as
@derive Inspect
-
tuple in the form of
@derive {Protocol, key1: :val1, :others}
(e.g., line 550 in
InspectTest
(v1.8.0-rc.0),
Phoenix.Param
protocol doc) -
list of tuples such as
@derive [{Prot1, :options}, {Prot2, key: :val}]
The only places I found mentions of @derive
:
-
“Deriving” section in the documentation of
Kernel.defstruct/1
macro - New (i.e., v1.8.0-rc.0) “Deriving” section of
Inspect
- Documentation of
Protocol.derive/3
macro (added in #7019)
(This was extremely helpful because using the example snippets one can test all the combinations above.)
Wasn’t sure whether I’m not just overlooking something, therefore didn’t open an issue or pull request.