-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add type parameters #34
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with just a few naming nits. Thanks for showing me how it's done :)
(note: I'm not a maintainer, just commenting)
lib/typed_struct.ex
Outdated
# A arg named :int | ||
arg :int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# A arg named :int | |
arg :int | |
# A type parameter named int | |
arg :int |
README.md
Outdated
use TypedStruct | ||
|
||
typedstruct do | ||
arg :state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I would call it parameter
:
- to match the style of
field
andplugin
, which are not abbreviated - to match the documentation, which talks about "parameterized types"
lib/typed_struct.ex
Outdated
end | ||
|
||
def __arg__(name, _env) do | ||
raise ArgumentError, "a arg name must be an atom, got #{inspect(name)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise ArgumentError, "a arg name must be an atom, got #{inspect(name)}" | |
raise ArgumentError, "a parameter name must be an atom, got #{inspect(name)}" |
lib/typed_struct.ex
Outdated
@@ -155,6 +172,22 @@ defmodule TypedStruct do | |||
end | |||
end | |||
|
|||
@doc """ | |||
Defines a argument for a typed struct. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defines a argument for a typed struct. | |
Defines a type parameter for a typed struct. |
Hello, thank you for your PR! @flupke, I’ve also read your comments on the other PR, sorry that both of you have worked on the same subject. I’m still quite loaded on non-OSS personal duties this week, and not available this week-end, but I will review it next week, along with other pending PRs. As stated in the CONTRIBUTING.md, work should be based and merged back to develop. Could you then just rebase your PR on top of Note that I have disabled Elixir 1.14 from the CI as of now, as there is a bug in Elixir 1.14.0 breaking |
2a33f4f
to
b31b509
Compare
@flupke Thanks for your suggestions that makes sense. @ejpcmac Thanks for your reply, and I’ve updated the PR according to the CONTRIBUTING. |
This is an awesome package that saves me a ton of boilerplate. Thanks @ejpcmac! Unfortunately, I really need parameterized types. Is this still being considered, or am I better off forking/creating a plugin? Thanks! |
I am extremely grateful to @ejpcmac for providing this package, which has performed excellently in my projects. However, it lacked some features I needed, and it appeared that the repo was not being maintained actively. I rewrite this package with some new functionalities, including those introduced in this PR. For those interested in these enhancements, you are welcome to visit https://github.com/elixir-typed-structor/typed_structor or https://hexdocs.pm/typed_structor/readme.html. Once again, many thanks to @ejpcmac . |
related pr #28