-
Notifications
You must be signed in to change notification settings - Fork 0
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
Contributing to syntax tools? #11
Comments
Sure. |
I haven't had time to look closer, so I'm more interested in the reverse question: while working on this, which things did you think should definitely have been part of syntax tools to begin with? You could extract those one by one and turn them into PRs, if you have the time for it. |
Theses are mainly four step features of this application
These features make code look cleaner.
Other features are
I will make a plan |
Here is my plan:
|
Hi, I'm a bit late to the party but want to chime in. As it happens I've also written a parse transform library, but with a different design. I thought we could compare notes and see which parts best fit in OTP. Mine builds on merl, hence the name merlin, but like yours it uses a phase parameter for entering/exiting nodes. I used I did some cleanup and pushed what I got, but it might still have a few rough edges. I've also written a couple of everyday use transforms using it to get a feel for what you need in the real world™️ . As far as I can see you use attributes and magical functions, where as I use macros. I do that so that the reader knows something is happening compile time, even though it does way more then a vanilla. macro can. Speaking of which, we both implemented hygienic/procedural variants. But again, I prefer to start as a vanilla macro while you use plain old function calls. Here's eval: %% The repetition of the macro name is for error reporting purposes
%% since there's no other way to figure out the calling macros name
-define(eval(Expression), ?procedural(eval(Expression),
erl_parse:abstract(Expression, ?LINE)
)).
%% If I understood it correctly this is somewhat equivalent
-use_macro({eval/1, []}).
eval(Term) ->
quote(Term). This became a wall of text, but I hope it's ok. Love to hear your feedback 😃 Edit: My biggest worry is that introducing monads into OTP might be a bit much for the average developer. On the other hand it has a proven track record in other functional languages. Also in Rust, the Result type comes to mind, and JavaScripts Promises. |
monads it's hidden by this function: astranaut_traverse:mapfold/4 |
I read the docs from the README, and this seems mostly true. Except for some of the return types, although I assume those could be removed.
If you look into astranaut/src/traverse/astranaut_traverse.erl Line 218 in 2fb9ec8
Which indicates that you could Bring Your Own Monad, but looking at the astranaut/src/traverse/astranaut_traverse.erl Lines 28 to 35 in 2fb9ec8
Is it just some leftover code, or can you actually BYOM?
But it's not just about the end users, it's also (maybe more so) about the maintainers. Does the OTP maintainers know monads? Are they comfortable writing monadic code? This is especially true when using the [ maybe ||
User <- users:get(123),
#{ id := UserId } = User,
Comments <- comments:get(#{ user_id => UserId),
{User, Comments}
] with maybe:'>>='(users:get(123), fun(User) ->
#{ id := UserId } = User,
maybe:'>>='(comments:get(#{ user_id => UserId), fun(Comments) ->
{User, Comments}
end)
end) But the I did also noticed you haven't been using the
This I totally understand. Both that the code can get quite gnarly, and that you write code you yourself understand/feel comfortable with. When Write I just finished my own rebinder. Much simpler then yours, and mine probably have some subtle bugs. But it might be an interesting comparison. You use an attribute, I require special variable naming (e.g. The point I'm trying to make is that code written for a large, long term, project must be optimized for maintainability. Speed is also something you must think about, but in the end there will be bugs and someone has to take care of them. Thus it's best if as many developers as possible can chip in. Erlang just isn't ready for monads IMO. If you look at the discussion about @richcarl addition of the pinning operator, you can get a sense how much resistance there seems to be in the Erlang community. I don't argue that we shouldn't try to introduce new concepts. On the contrary, if there's anything constant in our line of work is the constant change. But they need to be introduced one small step at a time. Perhaps in the future Erlang gets first class support for monads, but right now I'm not so sure. |
This is a simple reply from phone,I will modify it later. about moand,You are right, |
Looking forward to see what you come up with. And again, I hope we can join forces to get the best in OTP. Have you looked at merlin? |
I remove this attributes because it's already processed in map_m, no need to do the duplicated thing, It's more proper to move it to map_m function astranaut/src/traverse/astranaut_traverse.erl Line 218 in 2fb9ec8
and monad and monad_class is depricated, I forget to remove it. astranaut_traverse_m work the same way as So I have seen no base difference between your traverse and my traverse.
for macro, because parse_transform could do everything
for rebinder, variables in case and variables in functions works different |
Just opening an issue here to have a little chat. You seem to have some interesting features here, and I'm wondering if you have at all considered submitting some PRs to make some of those features directly available as part of syntax_tools?
The text was updated successfully, but these errors were encountered: